@micha.bigler/ui-core-micha 4.22.0 → 4.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.24.0 - UCM-CHAT-11
4
+
5
+ Visible change in every app: the chat thread no longer shows the "N earlier messages left out" chip. The server
6
+ still trims the history and still sends the `history_trimmed` notice; `ChatWorkspace` ignores it. Removed with it:
7
+ the `ChatThread` prop `trimmedCount` (an old caller passing it sees no effect), the export `CHAT_THREAD_TRIMMED_SX`,
8
+ the public kit-sx registry entry `ChatThread.trimmed` in `CHAT_KIT_SX_REGISTRY`, `CHAT_NOTICE_CODES`, and the keys
9
+ `Chat.historyTrimmed_one` / `_other`. No consuming app (maana, cockpit, hram, survey_app) referenced any of them.
10
+
11
+ ## 4.23.0 - UCM-CHAT-10
12
+
13
+ `ChatWorkspace` (and `ChatThread`) accept an optional `renderTurnError({ turn, chat, retry })`. For a failed or
14
+ cancelled turn with an error code, a returned node replaces the generic "answer could not be completed" alert; `null`
15
+ (or no prop) keeps the generic alert. `retry` re-sends the turn and is `undefined` where the thread is read-only.
16
+ Interrupted turns and every other state are unchanged.
17
+
3
18
  ## 4.22.0 - UCM-CHAT-9
4
19
 
5
20
  Chat pieces for the DCM-CHAT-16 server data; without that data nothing changes. `ChatWorkspace` reads the per-user
package/README.md CHANGED
@@ -208,6 +208,19 @@ Since 4.22.0, with django-core-micha's DCM-CHAT-16 data:
208
208
  app's router, which keeps the chat panel open. External http(s) links open in a new tab, and other schemes stay text.
209
209
  `MarkdownReply` takes the same `onNavigate`.
210
210
 
211
+ ## Shared chat: the app's own failed-turn message
212
+
213
+ Since 4.23.0 `renderTurnError({ turn, chat, retry })` lets an app replace the generic failed-turn alert for the error
214
+ codes it knows; return `null` for everything else:
215
+
216
+ ```jsx
217
+ <ChatWorkspace
218
+ renderTurnError={({ turn, retry }) => (turn.error_code === 'prompt_too_long'
219
+ ? <Alert severity="warning" action={retry ? <Button onClick={retry}>Erneut versuchen</Button> : null}>Gib weniger Interviews frei.</Alert>
220
+ : null)}
221
+ />
222
+ ```
223
+
211
224
  ## Shared chat: host controls
212
225
 
213
226
  `ChatWorkspace` (from `@micha.bigler/ui-core-micha/chat`) takes optional props for apps that put UI around the surface;
@@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next';
5
5
  import MarkdownReply from './MarkdownReply';
6
6
  export const CHAT_THREAD_TOOL_CHIP_SX = { alignSelf: 'flex-start' };
7
7
  export const CHAT_THREAD_NOTICE_SX = { mb: 2 };
8
- export const CHAT_THREAD_TRIMMED_SX = { mb: 1.5 };
9
8
  export const CHAT_THREAD_TOOL_STEPS_SX = { alignItems: 'flex-start' };
10
9
  const selectionLine = (turn, t) => [turn.model, turn.effort && t(`Chat.effort.${turn.effort}`)].filter(Boolean).join(' · ');
11
10
  const sameSelection = (a, b) => a.driver === b.driver && a.model === b.model && a.effort === b.effort;
@@ -15,12 +14,16 @@ function SourceChips({ sources }) {
15
14
  return null;
16
15
  return (_jsx(Stack, { direction: "row", flexWrap: "wrap", gap: 0.75, role: "list", "aria-label": t('Chat.sources'), children: sources.map((source, index) => (_jsx(Tooltip, { title: source.reference || '', describeChild: true, children: _jsx(Chip, { role: "listitem", size: "small", variant: "outlined", label: source.label }) }, `${source.label}-${index}`))) }));
17
16
  }
18
- function Answer({ turn, tool, onRetry, chat, renderAnswerExtra, usageToTokens, onNavigate }) {
17
+ function Answer({ turn, tool, onRetry, chat, renderAnswerExtra, renderTurnError, usageToTokens, onNavigate }) {
19
18
  var _a;
20
19
  var _b;
21
20
  const { t, i18n } = useTranslation();
22
21
  const generating = turn.state === 'generating';
23
22
  const failed = ['failed', 'cancelled'].includes(turn.state) && turn.error_code;
23
+ const turnError = failed && renderTurnError
24
+ ? renderTurnError({ turn, chat, retry: onRetry ? () => onRetry(turn) : undefined })
25
+ : null;
26
+ const hasCustomTurnError = turnError !== null && turnError !== undefined && turnError !== false;
24
27
  const replyCaption = (turn) => {
25
28
  const tokens = turn.usage && (usageToTokens === null || usageToTokens === void 0 ? void 0 : usageToTokens(turn.usage));
26
29
  if (Number.isInteger(tokens) && tokens >= 0) {
@@ -29,13 +32,13 @@ function Answer({ turn, tool, onRetry, chat, renderAnswerExtra, usageToTokens, o
29
32
  }
30
33
  return selectionLine(turn, t);
31
34
  };
32
- return (_jsxs(Stack, { spacing: 1, "aria-busy": generating, children: [turn.assistant_text ? _jsx(MarkdownReply, { text: turn.assistant_text, onNavigate: onNavigate }) : null, generating && !turn.assistant_text && !tool ? _jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Chat.typing') }) : null, generating && tool ? _jsx(Chip, { size: "small", color: "primary", variant: "outlined", label: tool.label, sx: CHAT_THREAD_TOOL_CHIP_SX }) : null, !generating && ((_a = turn.tool_steps) === null || _a === void 0 ? void 0 : _a.length) ? _jsx(Stack, { direction: "row", flexWrap: "wrap", gap: 0.75, role: "list", "aria-label": t('Chat.toolSteps'), sx: CHAT_THREAD_TOOL_STEPS_SX, children: turn.tool_steps.map((step, index) => _jsx(Chip, { role: "listitem", size: "small", variant: "outlined", label: step.label, sx: CHAT_THREAD_TOOL_CHIP_SX }, `${step.name || step.label}-${index}`)) }) : null, _jsx(SourceChips, { sources: turn.sources }), !generating && replyCaption(turn) ? _jsx(Typography, { variant: "caption", color: "text.secondary", children: replyCaption(turn) }) : null, renderAnswerExtra ? _jsx(React.Fragment, { children: renderAnswerExtra({ turn, chat, appFrames: (_b = turn.appFrames) !== null && _b !== void 0 ? _b : [] }) }, chat === null || chat === void 0 ? void 0 : chat.id) : null, turn.state === 'interrupted' ? (_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, children: [_jsx(Chip, { size: "small", color: "warning", label: t('Chat.interrupted') }), onRetry ? _jsx(Button, { size: "small", onClick: () => onRetry(turn), children: t('Chat.retry') }) : null] })) : null, failed ? (_jsx(Alert, { severity: "error", action: onRetry ? _jsx(Button, { color: "inherit", size: "small", onClick: () => onRetry(turn), children: t('Chat.retry') }) : null, children: t('Chat.answerIncomplete') })) : null] }));
35
+ return (_jsxs(Stack, { spacing: 1, "aria-busy": generating, children: [turn.assistant_text ? _jsx(MarkdownReply, { text: turn.assistant_text, onNavigate: onNavigate }) : null, generating && !turn.assistant_text && !tool ? _jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Chat.typing') }) : null, generating && tool ? _jsx(Chip, { size: "small", color: "primary", variant: "outlined", label: tool.label, sx: CHAT_THREAD_TOOL_CHIP_SX }) : null, !generating && ((_a = turn.tool_steps) === null || _a === void 0 ? void 0 : _a.length) ? _jsx(Stack, { direction: "row", flexWrap: "wrap", gap: 0.75, role: "list", "aria-label": t('Chat.toolSteps'), sx: CHAT_THREAD_TOOL_STEPS_SX, children: turn.tool_steps.map((step, index) => _jsx(Chip, { role: "listitem", size: "small", variant: "outlined", label: step.label, sx: CHAT_THREAD_TOOL_CHIP_SX }, `${step.name || step.label}-${index}`)) }) : null, _jsx(SourceChips, { sources: turn.sources }), !generating && replyCaption(turn) ? _jsx(Typography, { variant: "caption", color: "text.secondary", children: replyCaption(turn) }) : null, renderAnswerExtra ? _jsx(React.Fragment, { children: renderAnswerExtra({ turn, chat, appFrames: (_b = turn.appFrames) !== null && _b !== void 0 ? _b : [] }) }, chat === null || chat === void 0 ? void 0 : chat.id) : null, turn.state === 'interrupted' ? (_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, children: [_jsx(Chip, { size: "small", color: "warning", label: t('Chat.interrupted') }), onRetry ? _jsx(Button, { size: "small", onClick: () => onRetry(turn), children: t('Chat.retry') }) : null] })) : null, failed ? (hasCustomTurnError ? turnError : _jsx(Alert, { severity: "error", action: onRetry ? _jsx(Button, { color: "inherit", size: "small", onClick: () => onRetry(turn), children: t('Chat.retry') }) : null, children: t('Chat.answerIncomplete') })) : null] }));
33
36
  }
34
37
  /**
35
38
  * The turns of one chat. The streaming answer is simply the last turn in state `generating`; the caller keeps its text
36
39
  * up to date. `notice` is a connection or limit message shown under the last turn. `readOnly` (an archived chat) hides Retry.
37
40
  */
38
- export function ChatThread({ turns = [], tool = null, notice = null, hasOlder = false, olderBusy = false, onLoadOlder, onRetry, readOnly = false, sx, chat, renderAnswerExtra, trimmedCount, summary = null, usageToTokens, onNavigate }) {
41
+ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder = false, olderBusy = false, onLoadOlder, onRetry, readOnly = false, sx, chat, renderAnswerExtra, renderTurnError, summary = null, usageToTokens, onNavigate }) {
39
42
  var _a, _b;
40
43
  const { t } = useTranslation();
41
44
  const end = useRef(null);
@@ -81,7 +84,7 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
81
84
  }, role: "log", "aria-live": "polite", "aria-label": t('Chat.thread'), sx: Object.assign({ minHeight: 0, flex: 1, overflowY: 'auto', p: { xs: 1.5, md: 2.5 } }, sx), children: [hasOlder ? (_jsx(Box, { sx: { textAlign: 'center', mb: 2 }, children: _jsx(Button, { size: "small", onClick: loadOlder, disabled: olderBusy, children: t('Chat.loadOlder') }) })) : null, turns.length === 0 ? (_jsx(Typography, { variant: "h6", color: "text.secondary", align: "center", sx: { mt: 6 }, children: t('Chat.emptyTitle') })) : null, turns.map((turn, index) => {
82
85
  var _a;
83
86
  const previous = turns[index - 1];
84
- return (_jsxs(Box, { sx: { mb: 3 }, children: [!summaryRendered && summaryVisible && turn.seq > summary.up_to_seq ? (summaryRendered = true, renderSummary()) : null, previous && !sameSelection(previous, turn) ? (_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: { mb: 2, color: 'text.secondary' }, role: "separator", children: [_jsx(Box, { sx: { flex: 1, borderTop: 1, borderColor: 'divider' } }), _jsx(Typography, { variant: "caption", children: t('Chat.modelChanged', { model: selectionLine(turn, t) }) }), _jsx(Box, { sx: { flex: 1, borderTop: 1, borderColor: 'divider' } })] })) : null, _jsx(Box, { sx: { display: 'flex', justifyContent: 'flex-end', mb: 1.5 }, children: _jsx(Typography, { sx: { maxWidth: '85%', whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', bgcolor: 'action.hover', borderRadius: 2, px: 1.5, py: 1 }, children: turn.user_text }) }), _jsx(Answer, { turn: turn, tool: index === turns.length - 1 ? tool : null, onRetry: readOnly ? undefined : onRetry, chat: chat, renderAnswerExtra: renderAnswerExtra, usageToTokens: usageToTokens, onNavigate: onNavigate })] }, (_a = turn.id) !== null && _a !== void 0 ? _a : index));
85
- }), !summaryRendered ? renderSummary() : null, trimmedCount ? _jsx(Chip, { size: "small", variant: "outlined", label: t(trimmedCount === 1 ? 'Chat.historyTrimmed_one' : 'Chat.historyTrimmed_other', { count: trimmedCount }), sx: CHAT_THREAD_TRIMMED_SX }) : null, notice ? (_jsx(Alert, { severity: notice.severity || 'warning', sx: CHAT_THREAD_NOTICE_SX, action: notice.action ? _jsx(Button, { color: "inherit", size: "small", onClick: notice.action.onClick, children: notice.action.label }) : null, children: notice.text })) : null, _jsx("div", { ref: end })] }));
87
+ return (_jsxs(Box, { sx: { mb: 3 }, children: [!summaryRendered && summaryVisible && turn.seq > summary.up_to_seq ? (summaryRendered = true, renderSummary()) : null, previous && !sameSelection(previous, turn) ? (_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: { mb: 2, color: 'text.secondary' }, role: "separator", children: [_jsx(Box, { sx: { flex: 1, borderTop: 1, borderColor: 'divider' } }), _jsx(Typography, { variant: "caption", children: t('Chat.modelChanged', { model: selectionLine(turn, t) }) }), _jsx(Box, { sx: { flex: 1, borderTop: 1, borderColor: 'divider' } })] })) : null, _jsx(Box, { sx: { display: 'flex', justifyContent: 'flex-end', mb: 1.5 }, children: _jsx(Typography, { sx: { maxWidth: '85%', whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', bgcolor: 'action.hover', borderRadius: 2, px: 1.5, py: 1 }, children: turn.user_text }) }), _jsx(Answer, { turn: turn, tool: index === turns.length - 1 ? tool : null, onRetry: readOnly ? undefined : onRetry, chat: chat, renderAnswerExtra: renderAnswerExtra, renderTurnError: renderTurnError, usageToTokens: usageToTokens, onNavigate: onNavigate })] }, (_a = turn.id) !== null && _a !== void 0 ? _a : index));
88
+ }), !summaryRendered ? renderSummary() : null, notice ? (_jsx(Alert, { severity: notice.severity || 'warning', sx: CHAT_THREAD_NOTICE_SX, action: notice.action ? _jsx(Button, { color: "inherit", size: "small", onClick: notice.action.onClick, children: notice.action.label }) : null, children: notice.text })) : null, _jsx("div", { ref: end })] }));
86
89
  }
87
90
  export default ChatThread;
@@ -61,9 +61,10 @@ const appendDelta = (turns, text) => {
61
61
  *
62
62
  * Props: `apiBase` and `wsUrl` (where the app mounted the chat routes), `api` (partial overrides of the REST
63
63
  * calls; every function not given keeps its default), `scope` (passed when creating a chat),
64
- * `preloadedChats` (optional active-list response `{ scope, results, next }` already loaded for that exact scope), `sx`.
64
+ * `preloadedChats` (optional active-list response `{ scope, results, next }` already loaded for that exact scope), `sx`,
65
+ * `renderTurnError({ turn, chat, retry })` (optional failed-turn message; return `null` to show the default alert).
65
66
  */
66
- export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloadedChats, sx, unavailableReasonText, sidePanel, sidePanelLabel, renderAnswerExtra, renderComposerExtra, composerLayout = 'standard', renderComposerContext, onAppFrame, onNavigate, activeChatId, onActiveChatChange, composerPrefill, getSendContext, sendRequest, onSendRequestHandled, layout = 'viewport', compactBelow = 720, tokenBalance = null, usageToTokens, longChatTokens = 40000 }) {
67
+ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloadedChats, sx, unavailableReasonText, sidePanel, sidePanelLabel, renderAnswerExtra, renderTurnError, renderComposerExtra, composerLayout = 'standard', renderComposerContext, onAppFrame, onNavigate, activeChatId, onActiveChatChange, composerPrefill, getSendContext, sendRequest, onSendRequestHandled, layout = 'viewport', compactBelow = 720, tokenBalance = null, usageToTokens, longChatTokens = 40000 }) {
67
68
  var _a;
68
69
  const { t } = useTranslation();
69
70
  const theme = useTheme();
@@ -115,7 +116,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
115
116
  const focusPending = useRef(false);
116
117
  const [problem, setProblem] = useState(null);
117
118
  const [unavailableReason, setUnavailableReason] = useState(null);
118
- const [trimmedCount, setTrimmedCount] = useState(null);
119
119
  const [sidePanelOpen, setSidePanelOpen] = useState(false);
120
120
  const turnsRef = useRef(turns);
121
121
  useEffect(() => { turnsRef.current = turns; }, [turns]);
@@ -311,7 +311,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
311
311
  setOlderCursor(null);
312
312
  setTool(null);
313
313
  setProblem(null);
314
- setTrimmedCount(null);
315
314
  setSidePanelOpen(false);
316
315
  setDraft('');
317
316
  setOpenedOnce(false);
@@ -346,8 +345,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
346
345
  const running = turnsRef.current.findLast(isGenerating);
347
346
  (_a = appFrameCallback.current) === null || _a === void 0 ? void 0 : _a.call(appFrameCallback, { name: frame.name, payload: frame.payload, chatId, turnId: running === null || running === void 0 ? void 0 : running.id });
348
347
  }
349
- else if (frame.type === 'notice' && frame.code === 'history_trimmed')
350
- setTrimmedCount(frame.left_out || 0);
351
348
  else if (frame.type === 'notice' && frame.code === 'summarised') {
352
349
  api.listTurns(chatId).then((page) => { if (shownChatId.current === chatId)
353
350
  setSummary(page.summary || null); }).catch(() => { });
@@ -582,7 +579,7 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
582
579
  if (unavailable) {
583
580
  return (_jsx(Stack, { alignItems: "center", justifyContent: "center", spacing: 1, sx: Object.assign({ minHeight: 320, p: 3, textAlign: 'center' }, sx), children: _jsx(Typography, { color: "text.secondary", children: unavailableText || t('Chat.notAvailableHere') }) }));
584
581
  }
585
- return (_jsxs(Box, { ref: rootRef, sx: Object.assign({ display: 'grid', gridTemplateColumns: narrow ? 'minmax(0, 1fr)' : `minmax(240px, 320px) minmax(0, 1fr)${chat && sidePanel ? ' minmax(240px, 320px)' : ''}`, height: '100%', minHeight: 480, border: 1, borderColor: 'divider', borderRadius: 1, overflow: 'hidden', bgcolor: 'background.paper' }, sx), children: [narrow ? null : _jsx(Box, { sx: { borderRight: 1, borderColor: 'divider', minHeight: 0 }, children: list }), _jsxs(Stack, { sx: { minWidth: 0, minHeight: 0 }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: { px: 1.5, py: 0.5, borderBottom: 1, borderColor: 'divider', minHeight: 56 }, children: [narrow ? _jsx(Button, { color: "inherit", onClick: () => setListOpen(true), children: t('Chat.chats') }) : null, _jsx(Typography, { noWrap: true, sx: { flex: 1, fontWeight: 600 }, children: chat ? (chat.title || t('Chat.untitled')) : '' }), socket.status === 'connecting' && openedOnce ? _jsx(Chip, { size: "small", color: "warning", variant: "outlined", label: t('Chat.reconnecting') }) : null, isArchived ? _jsx(Chip, { size: "small", label: t('Chat.archived') }) : null, isArchived ? _jsx(Button, { size: "small", onClick: () => updateChat(chat, { archived: false }), children: t('Chat.restore') }) : null, chat && sidePanel && narrow ? _jsx(Button, { color: "inherit", onClick: () => setSidePanelOpen(true), children: sidePanelLabel || t('Chat.sidePanel') }) : null] }), chat ? (_jsxs(_Fragment, { children: [_jsx(ChatThread, { turns: turns, chat: chat, renderAnswerExtra: answerExtra, trimmedCount: trimmedCount, tool: tool, notice: noticeFor(), hasOlder: Boolean(olderCursor), olderBusy: olderBusy, onLoadOlder: loadOlder, onRetry: retry, readOnly: isArchived, summary: summary, usageToTokens: usageToTokens, onNavigate: onNavigate }), isArchived ? _jsx(Typography, { variant: "caption", color: "text.secondary", sx: { px: 2, pb: 1 }, children: t('Chat.archivedReadOnly') }) : null, renderComposerExtra ? _jsx(Box, { children: renderComposerExtra({ chat }) }, chat.id) : null, composerLayout !== 'compact' && longChat ? _jsx(Alert, { severity: "info", action: _jsx(Button, { color: "inherit", size: "small", onClick: createChat, children: t('Chat.newConversation') }), children: t('Chat.longChat') }) : null, _jsx(ChatComposer, { layout: composerLayout, context: composerLayout === 'compact' ? renderComposerContext === null || renderComposerContext === void 0 ? void 0 : renderComposerContext({ chat }) : undefined, notice: composerLayout === 'compact' && longChat && !dismissedComposerNotices.has(`${chat.id}:long-chat`) ? {
582
+ return (_jsxs(Box, { ref: rootRef, sx: Object.assign({ display: 'grid', gridTemplateColumns: narrow ? 'minmax(0, 1fr)' : `minmax(240px, 320px) minmax(0, 1fr)${chat && sidePanel ? ' minmax(240px, 320px)' : ''}`, height: '100%', minHeight: 480, border: 1, borderColor: 'divider', borderRadius: 1, overflow: 'hidden', bgcolor: 'background.paper' }, sx), children: [narrow ? null : _jsx(Box, { sx: { borderRight: 1, borderColor: 'divider', minHeight: 0 }, children: list }), _jsxs(Stack, { sx: { minWidth: 0, minHeight: 0 }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: { px: 1.5, py: 0.5, borderBottom: 1, borderColor: 'divider', minHeight: 56 }, children: [narrow ? _jsx(Button, { color: "inherit", onClick: () => setListOpen(true), children: t('Chat.chats') }) : null, _jsx(Typography, { noWrap: true, sx: { flex: 1, fontWeight: 600 }, children: chat ? (chat.title || t('Chat.untitled')) : '' }), socket.status === 'connecting' && openedOnce ? _jsx(Chip, { size: "small", color: "warning", variant: "outlined", label: t('Chat.reconnecting') }) : null, isArchived ? _jsx(Chip, { size: "small", label: t('Chat.archived') }) : null, isArchived ? _jsx(Button, { size: "small", onClick: () => updateChat(chat, { archived: false }), children: t('Chat.restore') }) : null, chat && sidePanel && narrow ? _jsx(Button, { color: "inherit", onClick: () => setSidePanelOpen(true), children: sidePanelLabel || t('Chat.sidePanel') }) : null] }), chat ? (_jsxs(_Fragment, { children: [_jsx(ChatThread, { turns: turns, chat: chat, renderAnswerExtra: answerExtra, renderTurnError: renderTurnError, tool: tool, notice: noticeFor(), hasOlder: Boolean(olderCursor), olderBusy: olderBusy, onLoadOlder: loadOlder, onRetry: retry, readOnly: isArchived, summary: summary, usageToTokens: usageToTokens, onNavigate: onNavigate }), isArchived ? _jsx(Typography, { variant: "caption", color: "text.secondary", sx: { px: 2, pb: 1 }, children: t('Chat.archivedReadOnly') }) : null, renderComposerExtra ? _jsx(Box, { children: renderComposerExtra({ chat }) }, chat.id) : null, composerLayout !== 'compact' && longChat ? _jsx(Alert, { severity: "info", action: _jsx(Button, { color: "inherit", size: "small", onClick: createChat, children: t('Chat.newConversation') }), children: t('Chat.longChat') }) : null, _jsx(ChatComposer, { layout: composerLayout, context: composerLayout === 'compact' ? renderComposerContext === null || renderComposerContext === void 0 ? void 0 : renderComposerContext({ chat }) : undefined, notice: composerLayout === 'compact' && longChat && !dismissedComposerNotices.has(`${chat.id}:long-chat`) ? {
586
583
  id: 'long-chat', text: t('Chat.longChatShort'), action: t('Chat.newChat'), onAction: createChat,
587
584
  onDismiss: () => setDismissedComposerNotices((current) => new Set(current).add(`${chat.id}:long-chat`)),
588
585
  } : null, value: draft, onChange: setDraft, onSend: send, onStop: () => socket.send({ type: 'stop' }), running: running, archived: isArchived, connected: socket.connected, inputRef: composerInputRef, usageLimit: usageLimit, actions: _jsx(ModelPicker, { entries: catalogue.entries, selection: selection, disabled: isArchived || running || (catalogueLoading && catalogueChatId !== chat.id), open: pickerOpen, onOpenChange: setPickerOpen, onChange: (next) => updateChat(chat, { selection: next }), sheet: narrow, balance: tokenBalance, longChat: longChat, onNewChat: createChat, shortLabel: composerLayout === 'compact' }) })] })) : (_jsxs(Stack, { alignItems: "center", justifyContent: "center", spacing: 2, sx: { flex: 1, p: 3 }, children: [_jsx(Typography, { color: "text.secondary", align: "center", children: t('Chat.selectChat') }), _jsx(Button, { variant: "contained", onClick: createChat, children: t('Chat.newChat') })] }))] }), chat && sidePanel && !narrow ? _jsx(Box, { sx: { borderLeft: 1, borderColor: 'divider', minHeight: 0, overflow: 'auto' }, children: sidePanel(chat) }, chat.id) : null, narrow && chat && sidePanel ? _jsx(Drawer, { anchor: "right", open: sidePanelOpen, onClose: () => setSidePanelOpen(false), slotProps: { paper: { 'aria-label': sidePanelLabel || t('Chat.sidePanel') } }, children: _jsx(Box, { children: sidePanel(chat) }, chat.id) }) : null, narrow ? _jsx(Drawer, { open: listOpen, onClose: () => setListOpen(false), slotProps: { paper: { sx: { width: 'min(320px, 86vw)' } } }, children: list }) : null] }));
@@ -1,7 +1,7 @@
1
1
  import { createKitSxEntry } from '../theme/kitSxEntry';
2
2
  import { CHAT_COMPOSER_INPUT_SX, CHAT_COMPOSER_COMPACT_ROOT_SX, CHAT_COMPOSER_CONTEXT_ROW_SX, CHAT_COMPOSER_CONTEXT_SX, CHAT_COMPOSER_CONTEXT_ACTIONS_SX, CHAT_COMPOSER_INPUT_ROW_SX, CHAT_COMPOSER_COMPACT_FIELD_SX, CHAT_COMPOSER_ACTION_SX, CHAT_COMPOSER_SEND_SX, CHAT_COMPOSER_NOTICE_SX, CHAT_COMPOSER_NOTICE_TEXT_SX, CHAT_COMPOSER_NOTICE_ACTION_SX, CHAT_COMPOSER_NOTICE_CLOSE_SX, CHAT_COMPOSER_USAGE_METER_SX, } from './ChatComposer';
3
3
  import { CHAT_LIST_ARCHIVED_ACTION_SX, CHAT_LIST_ROW_ACTION_SX } from './ChatList';
4
- import { CHAT_THREAD_NOTICE_SX, CHAT_THREAD_TOOL_CHIP_SX, CHAT_THREAD_TOOL_STEPS_SX, CHAT_THREAD_TRIMMED_SX } from './ChatThread';
4
+ import { CHAT_THREAD_NOTICE_SX, CHAT_THREAD_TOOL_CHIP_SX, CHAT_THREAD_TOOL_STEPS_SX } from './ChatThread';
5
5
  import { CHAT_MODEL_TRIGGER_SX, CHAT_MODEL_TRIGGER_SHORT_SX, CHAT_MODEL_ENTRY_SX, CHAT_MODEL_EFFORT_SX, CHAT_MODEL_CLOSE_SX } from './ModelPicker';
6
6
  export const CHAT_KIT_SX_REGISTRY = [
7
7
  createKitSxEntry('ChatComposer.input', 'MuiTextField', CHAT_COMPOSER_INPUT_SX, 'CHAT_COMPOSER_INPUT_SX'),
@@ -27,6 +27,5 @@ export const CHAT_KIT_SX_REGISTRY = [
27
27
  createKitSxEntry('ChatList.archivedAction', 'MuiButton', CHAT_LIST_ARCHIVED_ACTION_SX, 'CHAT_LIST_ARCHIVED_ACTION_SX'),
28
28
  createKitSxEntry('ChatThread.toolChip', 'MuiChip', CHAT_THREAD_TOOL_CHIP_SX, 'CHAT_THREAD_TOOL_CHIP_SX'),
29
29
  createKitSxEntry('ChatThread.toolSteps', 'MuiStack', CHAT_THREAD_TOOL_STEPS_SX, 'CHAT_THREAD_TOOL_STEPS_SX'),
30
- createKitSxEntry('ChatThread.trimmed', 'MuiChip', CHAT_THREAD_TRIMMED_SX, 'CHAT_THREAD_TRIMMED_SX'),
31
30
  createKitSxEntry('ChatThread.notice', 'MuiAlert', CHAT_THREAD_NOTICE_SX, 'CHAT_THREAD_NOTICE_SX'),
32
31
  ];
package/dist/chat/wire.js CHANGED
@@ -6,4 +6,3 @@ export const chatApiUrls = (base = '/api/assistant/') => {
6
6
  };
7
7
  export const defaultChatWsUrl = (chatId) => (window.location.protocol === 'https:' ? 'wss:' : 'ws:') + '//' + window.location.host + '/ws/assistant/chats/' + encodeURIComponent(chatId) + '/';
8
8
  export const CHAT_FRAME_TYPES = { APP: 'app', NOTICE: 'notice' };
9
- export const CHAT_NOTICE_CODES = { HISTORY_TRIMMED: 'history_trimmed' };
@@ -63,8 +63,6 @@ export const chatTranslations = {
63
63
  'Chat.toolSteps': { de: 'Verwendete Werkzeuge', en: 'Tools used', fr: 'Outils utilisés', sw: 'Zana zilizotumika' },
64
64
  'Chat.answerIncomplete': { de: 'Die Antwort konnte nicht abgeschlossen werden.', en: 'The answer could not be completed.', fr: 'La réponse n’a pas pu être terminée.', sw: 'Jibu halikuweza kukamilishwa.' },
65
65
  'Chat.notAvailableHere': { de: 'Der Assistent ist hier nicht verfügbar.', en: 'The assistant is not available here.', fr: 'L’assistant n’est pas disponible ici.', sw: 'Msaidizi hapatikani hapa.' },
66
- 'Chat.historyTrimmed_one': { de: '{{count}} frühere Nachricht wurde ausgelassen', en: '{{count}} earlier message left out', fr: '{{count}} message précédent omis', sw: 'Ujumbe {{count}} wa awali umeachwa' },
67
- 'Chat.historyTrimmed_other': { de: '{{count}} frühere Nachrichten wurden ausgelassen', en: '{{count}} earlier messages left out', fr: '{{count}} messages précédents omis', sw: 'Ujumbe {{count}} wa awali umeachwa' },
68
66
  'Chat.sidePanel': { de: 'Details', en: 'Details', fr: 'Détails', sw: 'Maelezo' },
69
67
  'Chat.unavailable': { de: 'Chat ist nicht verfügbar', en: 'Chat is not available', fr: 'Le chat n’est pas disponible', sw: 'Mazungumzo hayapatikani' },
70
68
  'Chat.noModel': { de: 'Auf diesem Server ist kein Sprachmodell konfiguriert.', en: 'No language model is configured on this server.', fr: 'Aucun modèle de langage n’est configuré sur ce serveur.', sw: 'Hakuna modeli ya lugha iliyosanidiwa kwenye seva hii.' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {