@micha.bigler/ui-core-micha 4.25.0 → 4.27.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 +20 -0
- package/dist/chat/ChatComposer.js +29 -7
- package/dist/chat/ChatThread.js +20 -6
- package/dist/chat/ChatWorkspace.js +10 -6
- package/dist/chat/kitSxRegistry.js +7 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.27.0 - UCM-CHAT-14
|
|
4
|
+
|
|
5
|
+
Typing in a long chat relayouts only the composer. The thread's scroll region and the wide side panel are CSS
|
|
6
|
+
containment boundaries (`contain: strict`), the composer roots `contain: layout paint`, and each turn has
|
|
7
|
+
`content-visibility: auto` with `contain-intrinsic-size: auto 320px`, so the browser lays out only turns near the
|
|
8
|
+
viewport. Because off-screen turns take their real height only once rendered, the thread follows content growth with a
|
|
9
|
+
ResizeObserver while it is pinned to the bottom (opening a chat and streaming stay at the bottom). No visual change. In
|
|
10
|
+
the dev harness (`#chat-long-thread`, ~6,300 elements, dev build) a keystroke went from a 30-44 ms median to 6-7 ms and
|
|
11
|
+
the forced layout after a value change costs about 1 ms; the staging acceptance is measured after the consumer pin bump.
|
|
12
|
+
|
|
13
|
+
## 4.26.0 - UCM-CHAT-13
|
|
14
|
+
|
|
15
|
+
Typing in `ChatWorkspace` re-renders only the composer: the draft now lives in `ChatComposer`, so a keystroke no
|
|
16
|
+
longer re-renders the thread, `renderAnswerExtra`, `renderComposerContext` / `renderComposerExtra` or `sidePanel`
|
|
17
|
+
(Maana staging, 4.25.0: 780 ms median per keystroke in a ~50-turn chat with the side panel open). `ChatComposer` is
|
|
18
|
+
uncontrolled when `value` is not given — `onSend(text)` then receives the text and the draft clears when it returns
|
|
19
|
+
`true` — and new optional `draftRequest` (`{ seq, text }`) / `onDraftRequestApplied` carry a host prefill; with
|
|
20
|
+
`value`/`onChange` it stays controlled as before. Prefill, focus, send/clear, chat switch, Enter/Shift+Enter, Stop and
|
|
21
|
+
the blocked states are unchanged.
|
|
22
|
+
|
|
3
23
|
## 4.25.0 - UCM-CHAT-12
|
|
4
24
|
|
|
5
25
|
Visible change in every app: the chat model picker is a compact panel. Title "Modell"; a flat model list without
|
|
@@ -14,7 +14,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
14
14
|
* input row with an icon Send that becomes Stop while running. The default `standard` layout is unchanged.
|
|
15
15
|
*/
|
|
16
16
|
export const CHAT_COMPOSER_INPUT_SX = { flex: '1 1 12rem', minWidth: 0 };
|
|
17
|
-
export const CHAT_COMPOSER_COMPACT_ROOT_SX = { display: 'flex', flexDirection: 'column', gap: 0.75, p: { xs: 1, md: 1.5 }, borderTop: 1, borderColor: 'divider', minWidth: 0 };
|
|
17
|
+
export const CHAT_COMPOSER_COMPACT_ROOT_SX = { display: 'flex', flexDirection: 'column', gap: 0.75, p: { xs: 1, md: 1.5 }, borderTop: 1, borderColor: 'divider', minWidth: 0, contain: 'layout paint' };
|
|
18
|
+
export const CHAT_COMPOSER_STANDARD_ROOT_SX = { p: { xs: 1, md: 2 }, borderTop: 1, borderColor: 'divider', contain: 'layout paint' };
|
|
18
19
|
export const CHAT_COMPOSER_CONTEXT_ROW_SX = { display: 'flex', alignItems: 'center', gap: 0.75, minHeight: 30, minWidth: 0, flexWrap: 'nowrap' };
|
|
19
20
|
export const CHAT_COMPOSER_CONTEXT_SX = { minWidth: 0, flex: '1 1 auto', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' };
|
|
20
21
|
export const CHAT_COMPOSER_CONTEXT_ACTIONS_SX = { flex: '0 0 auto', minWidth: 0, whiteSpace: 'nowrap' };
|
|
@@ -48,14 +49,35 @@ function UsageLimit({ usageLimit, t, language }) {
|
|
|
48
49
|
? _jsxs(_Fragment, { children: [_jsx(Typography, { variant: "caption", color: "text.secondary", children: t(`Chat.limitReached.${usageLimit.period}`) }), _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('Chat.limitResets', { date: resetDate }) })] })
|
|
49
50
|
: _jsx(Typography, { variant: "caption", color: "text.secondary", children: usageText }), _jsx(LinearProgress, { variant: "determinate", "aria-label": usageText, value: reached ? 100 : Math.min(100, (usageLimit.usedUsdMicros / usageLimit.limitUsdMicros) * 100), sx: CHAT_COMPOSER_USAGE_METER_SX })] });
|
|
50
51
|
}
|
|
51
|
-
export function ChatComposer({ value
|
|
52
|
+
export function ChatComposer({ value, onChange, onSend, onStop, running = false, archived = false, connected = true, inputRef, sx, actions, layout = 'standard', context, notice, usageLimit = null, draftRequest, onDraftRequestApplied }) {
|
|
52
53
|
const { t, i18n } = useTranslation();
|
|
54
|
+
const [internalDraft, setInternalDraft] = React.useState('');
|
|
55
|
+
const appliedDraftRequest = React.useRef(undefined);
|
|
56
|
+
const controlled = value !== undefined;
|
|
57
|
+
const draft = controlled ? value : internalDraft;
|
|
58
|
+
React.useLayoutEffect(() => {
|
|
59
|
+
if (controlled || !draftRequest || draftRequest.seq === appliedDraftRequest.current)
|
|
60
|
+
return;
|
|
61
|
+
appliedDraftRequest.current = draftRequest.seq;
|
|
62
|
+
setInternalDraft(typeof draftRequest.text === 'string' ? draftRequest.text : '');
|
|
63
|
+
onDraftRequestApplied === null || onDraftRequestApplied === void 0 ? void 0 : onDraftRequestApplied(draftRequest.seq);
|
|
64
|
+
}, [controlled, draftRequest, onDraftRequestApplied]);
|
|
53
65
|
const limitReached = Boolean(usageLimit && usageLimit.usedUsdMicros >= usageLimit.limitUsdMicros);
|
|
54
66
|
const blocked = archived || !connected || limitReached;
|
|
55
67
|
const language = typeof (i18n === null || i18n === void 0 ? void 0 : i18n.language) === 'string' ? i18n.language.split('_')[0] || undefined : undefined;
|
|
56
|
-
const canSend = !running && !blocked &&
|
|
57
|
-
const
|
|
58
|
-
|
|
68
|
+
const canSend = !running && !blocked && draft.trim().length > 0;
|
|
69
|
+
const changeDraft = (next) => { if (controlled)
|
|
70
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
71
|
+
else
|
|
72
|
+
setInternalDraft(next); };
|
|
73
|
+
const submit = () => {
|
|
74
|
+
if (!canSend)
|
|
75
|
+
return;
|
|
76
|
+
if (controlled)
|
|
77
|
+
onSend === null || onSend === void 0 ? void 0 : onSend();
|
|
78
|
+
else if ((onSend === null || onSend === void 0 ? void 0 : onSend(draft)) === true)
|
|
79
|
+
setInternalDraft('');
|
|
80
|
+
};
|
|
59
81
|
const handleKeyDown = (event) => {
|
|
60
82
|
var _a;
|
|
61
83
|
if (event.key === 'Enter' && !event.shiftKey && !((_a = event.nativeEvent) === null || _a === void 0 ? void 0 : _a.isComposing)) {
|
|
@@ -64,9 +86,9 @@ export function ChatComposer({ value = '', onChange, onSend, onStop, running = f
|
|
|
64
86
|
}
|
|
65
87
|
};
|
|
66
88
|
if (layout === 'compact')
|
|
67
|
-
return (_jsxs(Stack, { sx: sx ? [CHAT_COMPOSER_COMPACT_ROOT_SX, sx] : CHAT_COMPOSER_COMPACT_ROOT_SX, children: [_jsx(CompactNotice, { notice: notice, t: t }), _jsx(UsageLimit, { usageLimit: usageLimit, t: t, language: language }), _jsxs(Stack, { direction: "row", alignItems: "center", sx: CHAT_COMPOSER_CONTEXT_ROW_SX, children: [_jsx(Box, { sx: CHAT_COMPOSER_CONTEXT_SX, children: context }), actions ? _jsx(Box, { sx: CHAT_COMPOSER_CONTEXT_ACTIONS_SX, children: actions }) : null] }), _jsxs(Stack, { direction: "row", alignItems: "flex-end", sx: CHAT_COMPOSER_INPUT_ROW_SX, children: [_jsx(TextField, { multiline: true, maxRows: 5, variant: "outlined", sx: CHAT_COMPOSER_COMPACT_FIELD_SX, size: "small", value:
|
|
89
|
+
return (_jsxs(Stack, { sx: sx ? [CHAT_COMPOSER_COMPACT_ROOT_SX, sx] : CHAT_COMPOSER_COMPACT_ROOT_SX, children: [_jsx(CompactNotice, { notice: notice, t: t }), _jsx(UsageLimit, { usageLimit: usageLimit, t: t, language: language }), _jsxs(Stack, { direction: "row", alignItems: "center", sx: CHAT_COMPOSER_CONTEXT_ROW_SX, children: [_jsx(Box, { sx: CHAT_COMPOSER_CONTEXT_SX, children: context }), actions ? _jsx(Box, { sx: CHAT_COMPOSER_CONTEXT_ACTIONS_SX, children: actions }) : null] }), _jsxs(Stack, { direction: "row", alignItems: "flex-end", sx: CHAT_COMPOSER_INPUT_ROW_SX, children: [_jsx(TextField, { multiline: true, maxRows: 5, variant: "outlined", sx: CHAT_COMPOSER_COMPACT_FIELD_SX, size: "small", value: draft, inputRef: inputRef, disabled: blocked, placeholder: t('Chat.message'), slotProps: { htmlInput: { 'aria-label': t('Chat.message') } }, onChange: (event) => changeDraft(event.target.value), onKeyDown: handleKeyDown }), running
|
|
68
90
|
? _jsx(IconButton, { "aria-label": t('Chat.stopAnswer'), title: t('Chat.stopAnswer'), sx: CHAT_COMPOSER_ACTION_SX, onClick: onStop, children: _jsx(StopIcon, {}) })
|
|
69
91
|
: _jsx(IconButton, { "aria-label": t('Chat.send'), sx: CHAT_COMPOSER_SEND_SX, onClick: submit, disabled: !canSend, children: _jsx(SendIcon, { fontSize: "small" }) })] })] }));
|
|
70
|
-
return (_jsxs(Stack, { direction: "row", alignItems: "flex-end", flexWrap: "wrap", gap: 1, sx: Object.assign({
|
|
92
|
+
return (_jsxs(Stack, { direction: "row", alignItems: "flex-end", flexWrap: "wrap", gap: 1, sx: Object.assign(Object.assign({}, CHAT_COMPOSER_STANDARD_ROOT_SX), sx), children: [usageLimit ? _jsx(Stack, { flexBasis: "100%", children: _jsx(UsageLimit, { usageLimit: usageLimit, t: t, language: language }) }) : null, _jsx(TextField, { multiline: true, maxRows: 6, sx: CHAT_COMPOSER_INPUT_SX, size: "small", value: draft, inputRef: inputRef, disabled: blocked, placeholder: t('Chat.message'), slotProps: { htmlInput: { 'aria-label': t('Chat.message') } }, onChange: (event) => changeDraft(event.target.value), onKeyDown: handleKeyDown }), actions ? _jsx(Stack, { direction: "row", alignItems: "flex-end", children: actions }) : null, running ? _jsx(Button, { variant: "outlined", onClick: onStop, children: t('Chat.stop') }) : null, _jsx(Button, { variant: "contained", onClick: submit, disabled: !canSend, children: t('Chat.send') })] }));
|
|
71
93
|
}
|
|
72
94
|
export default ChatComposer;
|
package/dist/chat/ChatThread.js
CHANGED
|
@@ -3,6 +3,8 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { Alert, Box, Button, Chip, Stack, Tooltip, Typography } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import MarkdownReply from './MarkdownReply';
|
|
6
|
+
export const CHAT_THREAD_SCROLL_SX = { minHeight: 0, flex: 1, overflowY: 'auto', p: { xs: 1.5, md: 2.5 }, contain: 'strict' };
|
|
7
|
+
export const CHAT_THREAD_TURN_SX = { mb: 3, contentVisibility: 'auto', containIntrinsicSize: 'auto 320px' };
|
|
6
8
|
export const CHAT_THREAD_TOOL_CHIP_SX = { alignSelf: 'flex-start' };
|
|
7
9
|
export const CHAT_THREAD_NOTICE_SX = { mb: 2 };
|
|
8
10
|
export const CHAT_THREAD_TOOL_STEPS_SX = { alignItems: 'flex-start' };
|
|
@@ -49,6 +51,18 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
|
|
|
49
51
|
// Follow the stream, but only when new content arrives at the end (not when older turns are prepended).
|
|
50
52
|
useEffect(() => { var _a, _b; if (pinned.current)
|
|
51
53
|
(_b = (_a = end.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'end' }); }, [last === null || last === void 0 ? void 0 : last.id, last === null || last === void 0 ? void 0 : last.assistant_text, last === null || last === void 0 ? void 0 : last.state]);
|
|
54
|
+
// Turns skip layout off-screen (content-visibility, UCM-CHAT-14) and take their real height only once rendered, so the
|
|
55
|
+
// content can still grow after the scroll above. While pinned, follow that growth to stay at the bottom.
|
|
56
|
+
const content = useRef(null);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const el = scroller.current;
|
|
59
|
+
if (!el || !content.current || typeof ResizeObserver === 'undefined')
|
|
60
|
+
return undefined;
|
|
61
|
+
const observer = new ResizeObserver(() => { if (pinned.current)
|
|
62
|
+
el.scrollTop = el.scrollHeight; });
|
|
63
|
+
observer.observe(content.current);
|
|
64
|
+
return () => observer.disconnect();
|
|
65
|
+
}, []);
|
|
52
66
|
// Keep the reader's position when older turns are prepended.
|
|
53
67
|
useLayoutEffect(() => {
|
|
54
68
|
const el = scroller.current;
|
|
@@ -76,15 +90,15 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
|
|
|
76
90
|
const summaryVisible = Boolean((_b = summary === null || summary === void 0 ? void 0 : summary.text) === null || _b === void 0 ? void 0 : _b.trim());
|
|
77
91
|
const renderSummary = () => summaryVisible ? _jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Button, { size: "small", "aria-expanded": summaryOpen, onClick: () => setSummaryOpen((value) => !value), children: [t('Chat.summaryUntilHere'), " ", summaryOpen ? '▾' : '▸'] }), summaryOpen ? _jsx(Typography, { component: "div", variant: "body2", sx: { whiteSpace: 'pre-wrap' }, children: summary.text }) : null] }) : null;
|
|
78
92
|
let summaryRendered = false;
|
|
79
|
-
return (
|
|
93
|
+
return (_jsx(Box, { ref: scroller, onScroll: (event) => {
|
|
80
94
|
const el = event.currentTarget;
|
|
81
95
|
pinned.current = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
|
|
82
96
|
if (hasOlder && !olderBusy && el.scrollTop <= 40)
|
|
83
97
|
loadOlder();
|
|
84
|
-
}, role: "log", "aria-live": "polite", "aria-label": t('Chat.thread'), sx: Object.assign({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
}, role: "log", "aria-live": "polite", "aria-label": t('Chat.thread'), sx: Object.assign(Object.assign({}, CHAT_THREAD_SCROLL_SX), sx), children: _jsxs("div", { ref: content, 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) => {
|
|
99
|
+
var _a;
|
|
100
|
+
const previous = turns[index - 1];
|
|
101
|
+
return (_jsxs(Box, { sx: CHAT_THREAD_TURN_SX, 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));
|
|
102
|
+
}), !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 })] }) }));
|
|
89
103
|
}
|
|
90
104
|
export default ChatThread;
|
|
@@ -64,6 +64,7 @@ const appendDelta = (turns, text) => {
|
|
|
64
64
|
* `preloadedChats` (optional active-list response `{ scope, results, next }` already loaded for that exact scope), `sx`,
|
|
65
65
|
* `renderTurnError({ turn, chat, retry })` (optional failed-turn message; return `null` to show the default alert).
|
|
66
66
|
*/
|
|
67
|
+
export const CHAT_WORKSPACE_SIDE_PANEL_SX = { borderLeft: 1, borderColor: 'divider', minHeight: 0, overflow: 'auto', contain: 'strict' };
|
|
67
68
|
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 }) {
|
|
68
69
|
var _a;
|
|
69
70
|
const { t } = useTranslation();
|
|
@@ -102,7 +103,8 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
102
103
|
const [olderCursor, setOlderCursor] = useState(null);
|
|
103
104
|
const [olderBusy, setOlderBusy] = useState(false);
|
|
104
105
|
const [tool, setTool] = useState(null);
|
|
105
|
-
const [
|
|
106
|
+
const [draftRequest, setDraftRequest] = useState(null);
|
|
107
|
+
const draftRequestSeq = useRef(0);
|
|
106
108
|
const composerInputRef = useRef(null);
|
|
107
109
|
const lastPrefillId = useRef(undefined);
|
|
108
110
|
const lastSendRequestId = useRef(undefined);
|
|
@@ -114,6 +116,9 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
114
116
|
sendRequestHandledRef.current = onSendRequestHandled;
|
|
115
117
|
const [focusRequest, setFocusRequest] = useState(0);
|
|
116
118
|
const focusPending = useRef(false);
|
|
119
|
+
const onDraftRequestApplied = useCallback((seq) => {
|
|
120
|
+
setDraftRequest((current) => (current === null || current === void 0 ? void 0 : current.seq) === seq ? null : current);
|
|
121
|
+
}, []);
|
|
117
122
|
const [problem, setProblem] = useState(null);
|
|
118
123
|
const [unavailableReason, setUnavailableReason] = useState(null);
|
|
119
124
|
const [sidePanelOpen, setSidePanelOpen] = useState(false);
|
|
@@ -312,7 +317,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
312
317
|
setTool(null);
|
|
313
318
|
setProblem(null);
|
|
314
319
|
setSidePanelOpen(false);
|
|
315
|
-
setDraft('');
|
|
316
320
|
setOpenedOnce(false);
|
|
317
321
|
setSummary(null);
|
|
318
322
|
}, [chat === null || chat === void 0 ? void 0 : chat.id]);
|
|
@@ -388,7 +392,9 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
388
392
|
lastPrefillId.current = composerPrefill.id;
|
|
389
393
|
if (!chat || isArchived)
|
|
390
394
|
return;
|
|
391
|
-
|
|
395
|
+
// A running counter: the request is cleared once applied, and the next one must still carry a new sequence number.
|
|
396
|
+
draftRequestSeq.current += 1;
|
|
397
|
+
setDraftRequest({ seq: draftRequestSeq.current, text: composerPrefill.text, chatId: chat.id });
|
|
392
398
|
focusPending.current = true;
|
|
393
399
|
setFocusRequest((count) => count + 1);
|
|
394
400
|
}, [composerPrefill, chat, isArchived, activeChatId]);
|
|
@@ -541,8 +547,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
541
547
|
const answerExtra = renderAnswerExtra
|
|
542
548
|
? (args) => renderAnswerExtra(Object.assign(Object.assign({}, args), { send: sendFromSlot, canSend: canSendFromSlot }))
|
|
543
549
|
: undefined;
|
|
544
|
-
const send = () => { if (startTurn(draft))
|
|
545
|
-
setDraft(''); };
|
|
546
550
|
const retry = (turn) => {
|
|
547
551
|
if (!socket.connected)
|
|
548
552
|
return;
|
|
@@ -582,6 +586,6 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
582
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, 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`) ? {
|
|
583
587
|
id: 'long-chat', text: t('Chat.longChatShort'), action: t('Chat.newChat'), onAction: createChat,
|
|
584
588
|
onDismiss: () => setDismissedComposerNotices((current) => new Set(current).add(`${chat.id}:long-chat`)),
|
|
585
|
-
} : null,
|
|
589
|
+
} : null, draftRequest: (draftRequest === null || draftRequest === void 0 ? void 0 : draftRequest.chatId) === chat.id ? draftRequest : null, onDraftRequestApplied: onDraftRequestApplied, onSend: (text) => startTurn(text), 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 }), balance: tokenBalance, shortLabel: composerLayout === 'compact' }) }, `composer-${chat.id}`)] })) : (_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: CHAT_WORKSPACE_SIDE_PANEL_SX, 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] }));
|
|
586
590
|
}
|
|
587
591
|
export default ChatWorkspace;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { createKitSxEntry } from '../theme/kitSxEntry';
|
|
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';
|
|
2
|
+
import { CHAT_COMPOSER_STANDARD_ROOT_SX, 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 } from './ChatThread';
|
|
4
|
+
import { CHAT_THREAD_NOTICE_SX, CHAT_THREAD_TOOL_CHIP_SX, CHAT_THREAD_TOOL_STEPS_SX, CHAT_THREAD_SCROLL_SX, CHAT_THREAD_TURN_SX } from './ChatThread';
|
|
5
|
+
import { CHAT_WORKSPACE_SIDE_PANEL_SX } from './ChatWorkspace';
|
|
5
6
|
import { CHAT_MODEL_TRIGGER_SX, CHAT_MODEL_TRIGGER_SHORT_SX, CHAT_MODEL_ENTRY_SX, CHAT_MODEL_ENTRY_CONTENT_SX, CHAT_MODEL_COST_SX, CHAT_MODEL_EFFORT_SX, CHAT_MODEL_CLOSE_SX, CHAT_MODEL_PANEL_SX, CHAT_MODEL_PANEL_SHEET_SX } from './ModelPicker';
|
|
6
7
|
export const CHAT_KIT_SX_REGISTRY = [
|
|
8
|
+
createKitSxEntry('ChatComposer.standardRoot', 'MuiStack', CHAT_COMPOSER_STANDARD_ROOT_SX, 'CHAT_COMPOSER_STANDARD_ROOT_SX'),
|
|
9
|
+
createKitSxEntry('ChatWorkspace.sidePanel', 'MuiBox', CHAT_WORKSPACE_SIDE_PANEL_SX, 'CHAT_WORKSPACE_SIDE_PANEL_SX'),
|
|
10
|
+
createKitSxEntry('ChatThread.scroll', 'MuiBox', CHAT_THREAD_SCROLL_SX, 'CHAT_THREAD_SCROLL_SX'),
|
|
11
|
+
createKitSxEntry('ChatThread.turn', 'MuiBox', CHAT_THREAD_TURN_SX, 'CHAT_THREAD_TURN_SX'),
|
|
7
12
|
createKitSxEntry('ChatComposer.input', 'MuiTextField', CHAT_COMPOSER_INPUT_SX, 'CHAT_COMPOSER_INPUT_SX'),
|
|
8
13
|
createKitSxEntry('ChatComposer.compactRoot', 'MuiStack', CHAT_COMPOSER_COMPACT_ROOT_SX, 'CHAT_COMPOSER_COMPACT_ROOT_SX'),
|
|
9
14
|
createKitSxEntry('ChatComposer.contextRow', 'MuiStack', CHAT_COMPOSER_CONTEXT_ROW_SX, 'CHAT_COMPOSER_CONTEXT_ROW_SX'),
|