@micha.bigler/ui-core-micha 4.23.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,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 4.23.0 - UCM-CHAT-10
|
|
4
12
|
|
|
5
13
|
`ChatWorkspace` (and `ChatThread`) accept an optional `renderTurnError({ turn, chat, retry })`. For a failed or
|
package/dist/chat/ChatThread.js
CHANGED
|
@@ -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;
|
|
@@ -39,7 +38,7 @@ function Answer({ turn, tool, onRetry, chat, renderAnswerExtra, renderTurnError,
|
|
|
39
38
|
* The turns of one chat. The streaming answer is simply the last turn in state `generating`; the caller keeps its text
|
|
40
39
|
* up to date. `notice` is a connection or limit message shown under the last turn. `readOnly` (an archived chat) hides Retry.
|
|
41
40
|
*/
|
|
42
|
-
export function ChatThread({ turns = [], tool = null, notice = null, hasOlder = false, olderBusy = false, onLoadOlder, onRetry, readOnly = false, sx, chat, renderAnswerExtra, renderTurnError,
|
|
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 }) {
|
|
43
42
|
var _a, _b;
|
|
44
43
|
const { t } = useTranslation();
|
|
45
44
|
const end = useRef(null);
|
|
@@ -86,6 +85,6 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
|
|
|
86
85
|
var _a;
|
|
87
86
|
const previous = turns[index - 1];
|
|
88
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));
|
|
89
|
-
}), !summaryRendered ? renderSummary() : null,
|
|
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 })] }));
|
|
90
89
|
}
|
|
91
90
|
export default ChatThread;
|
|
@@ -116,7 +116,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
116
116
|
const focusPending = useRef(false);
|
|
117
117
|
const [problem, setProblem] = useState(null);
|
|
118
118
|
const [unavailableReason, setUnavailableReason] = useState(null);
|
|
119
|
-
const [trimmedCount, setTrimmedCount] = useState(null);
|
|
120
119
|
const [sidePanelOpen, setSidePanelOpen] = useState(false);
|
|
121
120
|
const turnsRef = useRef(turns);
|
|
122
121
|
useEffect(() => { turnsRef.current = turns; }, [turns]);
|
|
@@ -312,7 +311,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
312
311
|
setOlderCursor(null);
|
|
313
312
|
setTool(null);
|
|
314
313
|
setProblem(null);
|
|
315
|
-
setTrimmedCount(null);
|
|
316
314
|
setSidePanelOpen(false);
|
|
317
315
|
setDraft('');
|
|
318
316
|
setOpenedOnce(false);
|
|
@@ -347,8 +345,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
347
345
|
const running = turnsRef.current.findLast(isGenerating);
|
|
348
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 });
|
|
349
347
|
}
|
|
350
|
-
else if (frame.type === 'notice' && frame.code === 'history_trimmed')
|
|
351
|
-
setTrimmedCount(frame.left_out || 0);
|
|
352
348
|
else if (frame.type === 'notice' && frame.code === 'summarised') {
|
|
353
349
|
api.listTurns(chatId).then((page) => { if (shownChatId.current === chatId)
|
|
354
350
|
setSummary(page.summary || null); }).catch(() => { });
|
|
@@ -583,7 +579,7 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
583
579
|
if (unavailable) {
|
|
584
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') }) }));
|
|
585
581
|
}
|
|
586
|
-
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,
|
|
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`) ? {
|
|
587
583
|
id: 'long-chat', text: t('Chat.longChatShort'), action: t('Chat.newChat'), onAction: createChat,
|
|
588
584
|
onDismiss: () => setDismissedComposerNotices((current) => new Set(current).add(`${chat.id}:long-chat`)),
|
|
589
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
|
|
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.' },
|