Skip to content

Commit

Permalink
Merge branch 'alerting/cache-partitions' of github.com:doakalexi/kiba…
Browse files Browse the repository at this point in the history
…na into alerting/cache-partitions
  • Loading branch information
doakalexi committed Jul 30, 2024
2 parents dd4aac5 + e8df1a5 commit 74bdf34
Show file tree
Hide file tree
Showing 54 changed files with 661 additions and 241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { BehaviorSubject } from 'rxjs';
import {
DndContext,
Expand Down Expand Up @@ -98,64 +98,84 @@ export function ControlGroup({
};
}, [controlGroupApi]);

const ApplyButtonComponent = useMemo(() => {
return (
<EuiButtonIcon
size="m"
disabled={!hasUnappliedSelections}
iconSize="m"
display="fill"
color={'success'}
iconType={'check'}
data-test-subj="controlGroup--applyFiltersButton"
aria-label={ControlGroupStrings.management.getApplyButtonTitle(hasUnappliedSelections)}
onClick={applySelections}
/>
);
}, [hasUnappliedSelections, applySelections]);

return (
<EuiPanel borderRadius="m" paddingSize="none" color={draggingId ? 'success' : 'transparent'}>
<EuiFlexGroup alignItems="center" gutterSize="s" wrap={true}>
<EuiPanel
borderRadius="m"
paddingSize="none"
color={draggingId ? 'success' : 'transparent'}
className="controlsWrapper"
>
<EuiFlexGroup
gutterSize="s"
direction="row"
responsive={false}
data-test-subj="controls-group"
>
{!isInitialized && <EuiLoadingChart />}
<DndContext
onDragStart={({ active }) => setDraggingId(`${active.id}`)}
onDragEnd={onDragEnd}
onDragCancel={() => setDraggingId(null)}
sensors={sensors}
measuring={{
droppable: {
strategy: MeasuringStrategy.BeforeDragging,
},
}}
>
<SortableContext items={controlsInOrder} strategy={rectSortingStrategy}>
{controlsInOrder.map(({ id, type }) => (
<ControlRenderer
key={id}
uuid={id}
type={type}
getParentApi={() => controlGroupApi}
onApiAvailable={(controlApi) => {
controlsManager.setControlApi(id, controlApi);
}}
isControlGroupInitialized={isInitialized}
/>
))}
</SortableContext>
<DragOverlay>
{draggingId ? (
<ControlClone
key={draggingId}
labelPosition={labelPosition}
controlApi={controlsManager.getControlApi(draggingId)}
/>
) : null}
</DragOverlay>
</DndContext>
{!autoApplySelections && (
<EuiFlexItem grow={false}>
<EuiToolTip
content={ControlGroupStrings.management.getApplyButtonTitle(hasUnappliedSelections)}
>
<EuiButtonIcon
size="m"
disabled={!hasUnappliedSelections}
iconSize="m"
display="fill"
color={'success'}
iconType={'check'}
data-test-subj="controlGroup--applyFiltersButton"
aria-label={ControlGroupStrings.management.getApplyButtonTitle(
hasUnappliedSelections
)}
onClick={applySelections}
/>
</EuiToolTip>
<EuiFlexItem>
<DndContext
onDragStart={({ active }) => setDraggingId(`${active.id}`)}
onDragEnd={onDragEnd}
onDragCancel={() => setDraggingId(null)}
sensors={sensors}
measuring={{
droppable: {
strategy: MeasuringStrategy.BeforeDragging,
},
}}
>
<SortableContext items={controlsInOrder} strategy={rectSortingStrategy}>
<EuiFlexGroup className="controlGroup" alignItems="center" gutterSize="s" wrap={true}>
{controlsInOrder.map(({ id, type }) => (
<ControlRenderer
key={id}
uuid={id}
type={type}
getParentApi={() => controlGroupApi}
onApiAvailable={(controlApi) => {
controlsManager.setControlApi(id, controlApi);
}}
isControlGroupInitialized={isInitialized}
/>
))}
</EuiFlexGroup>
</SortableContext>
<DragOverlay>
{draggingId ? (
<ControlClone
key={draggingId}
labelPosition={labelPosition}
controlApi={controlsManager.getControlApi(draggingId)}
/>
) : null}
</DragOverlay>
</DndContext>
</EuiFlexItem>
{isInitialized && !autoApplySelections && (
<EuiFlexItem grow={false} className="controlGroup--endButtonGroup">
{hasUnappliedSelections ? (
ApplyButtonComponent
) : (
<EuiToolTip content={ControlGroupStrings.management.getApplyButtonTitle(false)}>
{ApplyButtonComponent}
</EuiToolTip>
)}
</EuiFlexItem>
)}
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.timeSlider-playToggle:enabled {
background-color: $euiColorPrimary !important;
.timeSlider-playToggle {
height: 100%;
&:enabled {
background-color: $euiColorPrimary !important;
}
}

.timeSlider-prependButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export function PlayButton(props: Props) {
/>
);
return props.disablePlayButton ? (
<EuiToolTip content={TimeSliderStrings.control.getPlayButtonDisabledTooltip()}>
<EuiToolTip
display="block"
anchorClassName="timeSlider-playToggle"
content={TimeSliderStrings.control.getPlayButtonDisabledTooltip()}
>
{Button}
</EuiToolTip>
) : (
Expand Down
2 changes: 0 additions & 2 deletions examples/response_stream/common/api/reducer_stream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
*/

export { reducerStreamReducer } from './reducer';
export { reducerStreamRequestBodySchema } from './request_body_schema';
export type { ReducerStreamRequestBodySchema } from './request_body_schema';
2 changes: 1 addition & 1 deletion examples/response_stream/server/routes/reducer_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
deleteEntityAction,
ReducerStreamApiAction,
} from '../../common/api/reducer_stream/reducer_actions';
import { reducerStreamRequestBodySchema } from '../../common/api/reducer_stream';
import { reducerStreamRequestBodySchema } from './schemas/reducer_stream';
import { RESPONSE_STREAM_API_ENDPOINT } from '../../common/api';

import { entities, getActions } from './shared';
Expand Down
2 changes: 1 addition & 1 deletion examples/response_stream/server/routes/redux_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
error,
type ReduxStreamApiAction,
} from '../../common/api/redux_stream/data_slice';
import { reducerStreamRequestBodySchema } from '../../common/api/reducer_stream';
import { reducerStreamRequestBodySchema } from './schemas/reducer_stream';
import { RESPONSE_STREAM_API_ENDPOINT } from '../../common/api';

import { entities, getActions } from './shared';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export { reducerStreamRequestBodySchema } from './request_body_schema';
export type { ReducerStreamRequestBodySchema } from './request_body_schema';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import type { IRouter, Logger } from '@kbn/core/server';
import { streamFactory } from '@kbn/ml-response-stream/server';

import { simpleStringStreamRequestBodySchema } from '../../common/api/simple_string_stream';
import { simpleStringStreamRequestBodySchema } from './schemas/simple_string_stream';
import { RESPONSE_STREAM_API_ENDPOINT } from '../../common/api';

function timeout(ms: number) {
Expand Down
8 changes: 4 additions & 4 deletions fleet_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
},
{
"name": "elastic_agent",
"version": "1.20.0"
"version": "2.0.1"
},
{
"name": "endpoint",
"version": "8.14.0"
"version": "8.15.0"
},
{
"name": "fleet_server",
Expand All @@ -52,10 +52,10 @@
},
{
"name": "synthetics",
"version": "1.2.1"
"version": "1.2.2"
},
{
"name": "security_detection_engine",
"version": "8.14.3"
"version": "8.15.1"
}
]
2 changes: 1 addition & 1 deletion packages/kbn-cli-dev-mode/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "shared-common",
"type": "shared-server",
"id": "@kbn/cli-dev-mode",
"devOnly": true,
"owner": "@elastic/kibana-operations"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/console/public/styles/_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
* The highlighting for the selected requests in the monaco editor
*/
.console__monaco_editor__selectedRequests {
background: transparentize($euiColorLightShade, .3);
background: transparentize($euiColorPrimary, .9);
}
/*
* The z-index for the autocomplete suggestions popup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { OpenAiProviderType } from '@kbn/stack-connectors-plugin/public/common';
import { noop } from 'lodash/fp';
import { PromptResponse } from '@kbn/elastic-assistant-common';
import { QueryObserverResult } from '@tanstack/react-query';
import { Conversation } from '../../../..';
import * as i18n from './translations';
import * as i18nModel from '../../../connectorland/models/model_selector/translations';
Expand All @@ -37,6 +38,7 @@ export interface ConversationSettingsEditorProps {
React.SetStateAction<ConversationsBulkActions>
>;
onSelectedConversationChange: (conversation?: Conversation) => void;
refetchConversations?: () => Promise<QueryObserverResult<Record<string, Conversation>, unknown>>;
}

/**
Expand All @@ -53,6 +55,7 @@ export const ConversationSettingsEditor: React.FC<ConversationSettingsEditorProp
conversationsSettingsBulkActions,
setConversationsSettingsBulkActions,
onSelectedConversationChange,
refetchConversations,
}) => {
const { data: connectors, isSuccess: areConnectorsFetched } = useLoadConnectors({
http,
Expand Down Expand Up @@ -276,6 +279,7 @@ export const ConversationSettingsEditor: React.FC<ConversationSettingsEditorProp
conversation={selectedConversation}
isDisabled={isDisabled}
onSystemPromptSelectionChange={handleOnSystemPromptSelectionChange}
refetchConversations={refetchConversations}
selectedPrompt={selectedSystemPrompt}
isSettingsModalVisible={true}
setIsSettingsModalVisible={noop} // noop, already in settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ const ConversationSettingsManagementComponent: React.FC<Props> = ({
conversationsSettingsBulkActions={conversationsSettingsBulkActions}
http={http}
isDisabled={isDisabled}
refetchConversations={refetchConversations}
selectedConversation={selectedConversation}
setConversationSettings={setConversationSettings}
setConversationsSettingsBulkActions={setConversationsSettingsBulkActions}
Expand Down
15 changes: 13 additions & 2 deletions x-pack/packages/kbn-elastic-assistant/impl/assistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ const AssistantComponent: React.FC<Props> = ({
conversations[WELCOME_CONVERSATION_TITLE] ??
getDefaultConversation({ cTitle: WELCOME_CONVERSATION_TITLE });

// updated selected system prompt
setEditingSystemPromptId(
getDefaultSystemPrompt({
allSystemPrompts,
conversation: conversationToReturn,
})?.id
);
if (
prev &&
prev.id === conversationToReturn.id &&
Expand All @@ -273,6 +280,7 @@ const AssistantComponent: React.FC<Props> = ({
});
}
}, [
allSystemPrompts,
areConnectorsFetched,
conversationTitle,
conversations,
Expand Down Expand Up @@ -647,6 +655,7 @@ const AssistantComponent: React.FC<Props> = ({
actionTypeId: (defaultConnector?.actionTypeId as string) ?? '.gen-ai',
provider: apiConfig?.apiProvider,
model: apiConfig?.defaultModel,
defaultSystemPromptId: allSystemPrompts.find((sp) => sp.isNewConversationDefault)?.id,
},
});
},
Expand All @@ -665,14 +674,14 @@ const AssistantComponent: React.FC<Props> = ({

useEffect(() => {
(async () => {
if (areConnectorsFetched && currentConversation?.id === '') {
if (areConnectorsFetched && currentConversation?.id === '' && !isLoadingPrompts) {
const conversation = await mutateAsync(currentConversation);
if (currentConversation.id === '' && conversation) {
setCurrentConversationId(conversation.id);
}
}
})();
}, [areConnectorsFetched, currentConversation, mutateAsync]);
}, [areConnectorsFetched, currentConversation, isLoadingPrompts, mutateAsync]);

const handleCreateConversation = useCallback(async () => {
const newChatExists = find(conversations, ['title', NEW_CHAT]);
Expand Down Expand Up @@ -791,6 +800,7 @@ const AssistantComponent: React.FC<Props> = ({
isSettingsModalVisible={isSettingsModalVisible}
setIsSettingsModalVisible={setIsSettingsModalVisible}
allSystemPrompts={allSystemPrompts}
refetchConversations={refetchResults}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down Expand Up @@ -823,6 +833,7 @@ const AssistantComponent: React.FC<Props> = ({
handleOnSystemPromptSelectionChange,
isSettingsModalVisible,
isWelcomeSetup,
refetchResults,
]);

return (
Expand Down
Loading

0 comments on commit 74bdf34

Please sign in to comment.