@micha.bigler/ui-core-micha 4.28.0 → 4.29.1

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,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.29.1 - UCM-CHAT-17
4
+
5
+ New optional `ChatWorkspace` prop `isChatInUse(chat)`: an app returns `true` for a chat without messages that it created on purpose
6
+ (Maana: a chat with released excerpts). Since 4.29.0 a chat without a turn is hidden from the list and reused by "New chat"; a chat
7
+ marked in use stays listed, is never read as empty and is never reused, also when it becomes in use while it is open and empty (a
8
+ release into the open new chat). Read at every render and decision. Without the prop nothing changes from 4.29.0. Found by the
9
+ independent review of the Maana pin bump to 4.29.0. Also: a whitespace fix in `CHAT_WORKSPACE_SIDE_PANEL_SX` (no change of value).
10
+
11
+ ## 4.29.0 - UCM-CHAT-16
12
+
13
+ Chat opens at its end, no empty chat entries, usable thread on phones. Found in the Maana staging acceptance of 2026-11-03.
14
+
15
+ - **Opening position.** The thread's bottom pin could be lost on open: the scroll event of the first move to the (still estimated)
16
+ bottom arrives a frame later, when off-screen turns (`content-visibility`) have taken their real height, and was read as the
17
+ reader leaving the bottom. The thread now remembers the position it set itself and ignores that event; only the reader moving
18
+ away unpins, being near the bottom pins again. The scroll region sets `overflow-anchor: none` (browser scroll anchoring would
19
+ move it a second time). Position-on-prepend and follow-only-at-bottom are unchanged.
20
+ - **Empty chats.** `ChatWorkspace` does not list a chat that has no turn. "New chat" creates the chat as before but lists it only
21
+ from its first message on; pressing it while an empty chat is open (or exists) shows that chat instead of creating another.
22
+ Chats that still carry the server's default title ("New chat", not named by the person) are read once (first page of turns) and
23
+ hidden when empty; a failed read keeps the chat listed, a chat with a streaming or failed first turn is listed from the send.
24
+ - **Narrow screens (the workspace's narrow layout).** The thread keeps at least 45 % of the screen height, the header is 44 px, and
25
+ the composer notice (long-conversation banner) wraps below the small breakpoint instead of being cut mid-word; its action stays
26
+ beside it. From the small breakpoint up the notice is the one-line ellipsis as before.
27
+
28
+ No new props, no API change.
29
+
3
30
  ## 4.28.0 - UCM-CHAT-15
4
31
 
5
32
  New optional `ChatWorkspace` prop `onComposeStart({ chatId })`: called when the composer of a shown chat gains focus
package/README.md CHANGED
@@ -229,6 +229,12 @@ focus of the composer and when the draft goes from empty to non-empty, again aft
229
229
  something before the send (for example a context-size check), not per keystroke. A shown chat requests its catalogue
230
230
  once; the general catalogue is only requested while no chat is shown.
231
231
 
232
+ ## Shared chat: chats without messages
233
+
234
+ Since 4.29.0 a chat without a message is not listed and "New chat" reuses it. Since 4.29.1 an app can pass
235
+ `isChatInUse(chat)` and return `true` for a chat without messages that it created on purpose (for example with released
236
+ excerpts): such a chat stays listed and is never reused, also when it becomes in use while it is open and empty.
237
+
232
238
  ## Shared chat: host controls
233
239
 
234
240
  `ChatWorkspace` (from `@micha.bigler/ui-core-micha/chat`) takes optional props for apps that put UI around the surface;
@@ -25,7 +25,8 @@ export const CHAT_COMPOSER_ACTION_SX = { width: 36, height: 36, flex: '0 0 36px'
25
25
  // Send is the filled primary action of the input row, as in the prototype; Stop keeps the plain icon button.
26
26
  export const CHAT_COMPOSER_SEND_SX = Object.assign(Object.assign({}, CHAT_COMPOSER_ACTION_SX), { bgcolor: 'primary.main', color: 'primary.contrastText', '&:hover': { bgcolor: 'primary.dark' }, '&.Mui-disabled': { bgcolor: 'action.disabledBackground', color: 'action.disabled' } });
27
27
  export const CHAT_COMPOSER_NOTICE_SX = { display: 'flex', alignItems: 'center', gap: 0.75, minWidth: 0, minHeight: 32, px: 1, color: 'text.secondary', bgcolor: 'action.hover', borderRadius: 1 };
28
- export const CHAT_COMPOSER_NOTICE_TEXT_SX = { minWidth: 0, flex: '1 1 auto', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' };
28
+ // One line from the small breakpoint up; on a phone the text wraps instead of being cut mid-word, and its action stays beside it.
29
+ export const CHAT_COMPOSER_NOTICE_TEXT_SX = { minWidth: 0, flex: '1 1 auto', overflow: { xs: 'visible', sm: 'hidden' }, whiteSpace: { xs: 'normal', sm: 'nowrap' }, overflowWrap: 'anywhere', textOverflow: 'ellipsis', fontSize: { xs: '0.8125rem', sm: 'inherit' }, lineHeight: 1.3, py: { xs: 0.5, sm: 0 } };
29
30
  export const CHAT_COMPOSER_NOTICE_ACTION_SX = { flex: '0 0 auto', minWidth: 0, p: 0.25, whiteSpace: 'nowrap' };
30
31
  export const CHAT_COMPOSER_NOTICE_CLOSE_SX = { width: 28, height: 28, flex: '0 0 28px' };
31
32
  export const CHAT_COMPOSER_USAGE_METER_SX = { height: 3 };
@@ -3,7 +3,9 @@ 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' };
6
+ // overflowAnchor: the thread keeps its own position (bottom, or the reader's place after older turns are prepended); the browser's scroll anchoring
7
+ // would move it a second time whenever an off-screen turn takes its real height.
8
+ export const CHAT_THREAD_SCROLL_SX = { minHeight: 0, flex: 1, overflowY: 'auto', p: { xs: 1.5, md: 2.5 }, contain: 'strict', overflowAnchor: 'none' };
7
9
  export const CHAT_THREAD_TURN_SX = { mb: 3, contentVisibility: 'auto', containIntrinsicSize: 'auto 320px' };
8
10
  export const CHAT_THREAD_TOOL_CHIP_SX = { alignSelf: 'flex-start' };
9
11
  export const CHAT_THREAD_NOTICE_SX = { mb: 2 };
@@ -47,10 +49,21 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
47
49
  const scroller = useRef(null);
48
50
  const heightBeforeOlder = useRef(null);
49
51
  const pinned = useRef(true); // follow the stream only while the reader is at the bottom
52
+ // The scroll position this component set itself. The scroll event of such a move arrives a frame later, when off-screen turns may have
53
+ // taken their real height and the bottom moved away: that event must not be read as the reader leaving the bottom (UCM-CHAT-16).
54
+ const ownTop = useRef(null);
55
+ const scrollToEnd = () => { const el = scroller.current; if (!el)
56
+ return; el.scrollTop = el.scrollHeight; ownTop.current = el.scrollTop; };
50
57
  const last = turns[turns.length - 1];
51
58
  // Follow the stream, but only when new content arrives at the end (not when older turns are prepended).
52
- useEffect(() => { var _a, _b; if (pinned.current)
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]);
59
+ useEffect(() => {
60
+ var _a, _b;
61
+ if (!pinned.current)
62
+ return;
63
+ (_b = (_a = end.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'end' });
64
+ if (scroller.current)
65
+ ownTop.current = scroller.current.scrollTop;
66
+ }, [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
67
  // Turns skip layout off-screen (content-visibility, UCM-CHAT-14) and take their real height only once rendered, so the
55
68
  // content can still grow after the scroll above. While pinned, follow that growth to stay at the bottom. The scroll
56
69
  // region itself is observed too: a thread mounted in a hidden host panel gets its real size only when shown.
@@ -60,7 +73,7 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
60
73
  if (!el || !content.current || typeof ResizeObserver === 'undefined')
61
74
  return undefined;
62
75
  const observer = new ResizeObserver(() => { if (pinned.current)
63
- el.scrollTop = el.scrollHeight; });
76
+ scrollToEnd(); });
64
77
  observer.observe(content.current);
65
78
  observer.observe(el);
66
79
  return () => observer.disconnect();
@@ -97,7 +110,12 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
97
110
  let summaryRendered = false;
98
111
  return (_jsx(Box, { ref: scroller, onScroll: (event) => {
99
112
  const el = event.currentTarget;
100
- pinned.current = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
113
+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
114
+ const own = ownTop.current !== null && Math.abs(el.scrollTop - ownTop.current) < 1;
115
+ if (atBottom)
116
+ pinned.current = true;
117
+ else if (!own)
118
+ pinned.current = false; // only the reader moving away leaves the bottom, not content growing under a move of ours
101
119
  if (hasOlder && !olderBusy && el.scrollTop <= 40)
102
120
  loadOlder();
103
121
  }, 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) => {
@@ -62,10 +62,15 @@ const appendDelta = (turns, text) => {
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
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
+ * `renderTurnError({ turn, chat, retry })` (optional failed-turn message; return `null` to show the default alert),
66
+ * `isChatInUse(chat)` (optional, UCM-CHAT-17: return `true` for a chat without messages that the app created on purpose, for example with
67
+ * released excerpts; such a chat stays listed and "New chat" never reuses it. Read at every render and decision, so it also holds for a chat
68
+ * that becomes in use while it is open and empty. Without it a chat without messages is hidden and reused, as in 4.29.0).
66
69
  */
70
+ // On a phone the thread keeps at least half the screen: composer, notice and header take what is left (UCM-CHAT-16).
71
+ const CHAT_WORKSPACE_NARROW_THREAD_SX = { minHeight: '50vh' };
67
72
  export const CHAT_WORKSPACE_SIDE_PANEL_SX = { borderLeft: 1, borderColor: 'divider', minHeight: 0, overflow: 'auto', contain: 'strict' };
68
- export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloadedChats, sx, unavailableReasonText, sidePanel, sidePanelLabel, renderAnswerExtra, renderTurnError, renderComposerExtra, composerLayout = 'standard', renderComposerContext, onAppFrame, onNavigate, activeChatId, onActiveChatChange, onComposeStart, composerPrefill, getSendContext, sendRequest, onSendRequestHandled, layout = 'viewport', compactBelow = 720, tokenBalance = null, usageToTokens, longChatTokens = 40000 }) {
73
+ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloadedChats, sx, unavailableReasonText, sidePanel, sidePanelLabel, renderAnswerExtra, renderTurnError, renderComposerExtra, composerLayout = 'standard', renderComposerContext, onAppFrame, onNavigate, activeChatId, onActiveChatChange, onComposeStart, composerPrefill, getSendContext, sendRequest, onSendRequestHandled, layout = 'viewport', compactBelow = 720, tokenBalance = null, usageToTokens, longChatTokens = 40000, isChatInUse }) {
69
74
  var _a;
70
75
  const { t } = useTranslation();
71
76
  const theme = useTheme();
@@ -99,6 +104,18 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
99
104
  // The chat the current catalogue was requested for: a general catalogue must never drive the stored selection of a chat.
100
105
  const [catalogueChatId, setCatalogueChatId] = useState(null);
101
106
  const [chats, setChats] = useState([]);
107
+ // Chats without a message are not listed (UCM-CHAT-16): the server creates the chat when "New chat" is pressed, the list shows it from its
108
+ // first message on. emptyIds are the chats known to be empty; emptyChecks remembers what was found per chat so each is read once.
109
+ const [emptyIds, setEmptyIds] = useState(() => new Set());
110
+ const inUseRef = useRef(isChatInUse);
111
+ inUseRef.current = isChatInUse;
112
+ const inUse = (item) => { var _a; return Boolean(item && ((_a = inUseRef.current) === null || _a === void 0 ? void 0 : _a.call(inUseRef, item))); };
113
+ const emptyChecks = useRef(new Map()); // id -> 'pending' | 'empty' | 'used'
114
+ const markUsed = (id) => {
115
+ emptyChecks.current.set(id, 'used');
116
+ setEmptyIds((current) => { if (!current.has(id))
117
+ return current; const next = new Set(current); next.delete(id); return next; });
118
+ };
102
119
  const [archived, setArchived] = useState([]);
103
120
  const [nextChats, setNextChats] = useState(null);
104
121
  const [chat, setChat] = useState(null);
@@ -360,6 +377,27 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
360
377
  setProblem('load_error'); });
361
378
  return () => { live = false; };
362
379
  }, [api, chat === null || chat === void 0 ? void 0 : chat.id]);
380
+ // Chats that still carry the server's default title may be empty ones left behind by earlier "New chat" presses: read their first
381
+ // page once and keep the empty ones out of the list. A failed read keeps the chat listed (never hide what might hold a conversation).
382
+ useEffect(() => {
383
+ const untitled = (item) => !item.title || (item.title === 'New chat' && item.title_source !== 'user');
384
+ [...chats, ...archived].filter(untitled).forEach((item) => {
385
+ if (emptyChecks.current.has(item.id) || inUse(item))
386
+ return; // a chat the app marked in use is never read as empty
387
+ emptyChecks.current.set(item.id, 'pending');
388
+ api.listTurns(item.id)
389
+ .then((page) => {
390
+ if (emptyChecks.current.get(item.id) !== 'pending')
391
+ return; // a first message was sent meanwhile
392
+ const empty = !((page === null || page === void 0 ? void 0 : page.results) || []).length && !(page === null || page === void 0 ? void 0 : page.next);
393
+ emptyChecks.current.set(item.id, empty ? 'empty' : 'used');
394
+ if (empty)
395
+ setEmptyIds((current) => new Set(current).add(item.id));
396
+ })
397
+ .catch(() => { if (emptyChecks.current.get(item.id) === 'pending')
398
+ emptyChecks.current.set(item.id, 'used'); });
399
+ });
400
+ }, [api, chats, archived]);
363
401
  const onFrame = useCallback((frame, chatId) => {
364
402
  var _a;
365
403
  if (chatId !== (chat === null || chat === void 0 ? void 0 : chat.id))
@@ -493,8 +531,21 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
493
531
  }
494
532
  };
495
533
  const selectChat = (next) => { setChat(next); setListOpen(false); };
534
+ // "New chat" while an empty chat is open (or exists) shows that one instead of creating another.
496
535
  const createChat = guarded(async () => {
536
+ var _a;
537
+ // Only a list of the current scope may offer a chat: after a scope change the old list stays until the new one has loaded.
538
+ const open = chat ? ((_a = chats.find((item) => item.id === chat.id)) !== null && _a !== void 0 ? _a : chat) : null; // the listed copy is the fresher one
539
+ const reusable = chat && emptyIds.has(chat.id) && !running && !inUse(open) ? chat : (listsLoaded ? chats.find((item) => emptyIds.has(item.id) && !inUse(item)) : undefined);
540
+ if (reusable) {
541
+ selectChat(reusable);
542
+ focusPending.current = true;
543
+ setFocusRequest((count) => count + 1);
544
+ return;
545
+ }
497
546
  const created = await api.createChat(scope !== undefined ? { scope } : {});
547
+ emptyChecks.current.set(created.id, 'empty');
548
+ setEmptyIds((current) => new Set(current).add(created.id));
498
549
  setChats((current) => [created, ...current]);
499
550
  selectChat(created);
500
551
  });
@@ -551,6 +602,8 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
551
602
  if (!socket.send(built.frame))
552
603
  return false;
553
604
  setProblem(null);
605
+ if (chat)
606
+ markUsed(chat.id);
554
607
  setTurns((current) => [...current, {
555
608
  id: PENDING_ID, user_text: message, assistant_text: '', state: 'generating', sources: [],
556
609
  driver: activeEntry === null || activeEntry === void 0 ? void 0 : activeEntry.driver, model: (activeEntry === null || activeEntry === void 0 ? void 0 : activeEntry.label) || (activeEntry === null || activeEntry === void 0 ? void 0 : activeEntry.model), effort: selection === null || selection === void 0 ? void 0 : selection.effort,
@@ -595,7 +648,7 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
595
648
  return { text: t(texts[problem]), severity: 'warning' };
596
649
  return null;
597
650
  };
598
- const list = (_jsx(ChatList, { chats: chats, archivedChats: archived, activeId: chat === null || chat === void 0 ? void 0 : chat.id, hasMore: Boolean(nextChats), onSelect: selectChat, onNew: createChat, onRename: (target, title) => updateChat(target, { title }), onArchive: (target) => updateChat(target, { archived: true }), onRestore: (target) => updateChat(target, { archived: false }), onDelete: deleteChat, onLoadMore: loadMoreChats }));
651
+ const list = (_jsx(ChatList, { chats: chats.filter((item) => !emptyIds.has(item.id) || inUse(item)), archivedChats: archived.filter((item) => !emptyIds.has(item.id) || inUse(item)), activeId: chat === null || chat === void 0 ? void 0 : chat.id, hasMore: Boolean(nextChats), onSelect: selectChat, onNew: createChat, onRename: (target, title) => updateChat(target, { title }), onArchive: (target) => updateChat(target, { archived: true }), onRestore: (target) => updateChat(target, { archived: false }), onDelete: deleteChat, onLoadMore: loadMoreChats }));
599
652
  const notConfigured = status === 'not_configured' || problem === 'not_configured';
600
653
  const unavailable = status === 'unavailable' || problem === 'unavailable';
601
654
  const unavailableText = typeof unavailableReasonText === 'function' ? unavailableReasonText(unavailableReason) : unavailableReasonText === null || unavailableReasonText === void 0 ? void 0 : unavailableReasonText[unavailableReason];
@@ -609,7 +662,7 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
609
662
  if (unavailable) {
610
663
  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') }) }));
611
664
  }
612
- 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, onComposeStart: composeStart, context: composerLayout === 'compact' ? renderComposerContext === null || renderComposerContext === void 0 ? void 0 : renderComposerContext({ chat }) : undefined, notice: composerLayout === 'compact' && longChat && !dismissedComposerNotices.has(`${chat.id}:long-chat`) ? {
665
+ 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: narrow ? 44 : 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, { sx: narrow ? CHAT_WORKSPACE_NARROW_THREAD_SX : undefined, 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, onComposeStart: composeStart, context: composerLayout === 'compact' ? renderComposerContext === null || renderComposerContext === void 0 ? void 0 : renderComposerContext({ chat }) : undefined, notice: composerLayout === 'compact' && longChat && !dismissedComposerNotices.has(`${chat.id}:long-chat`) ? {
613
666
  id: 'long-chat', text: t('Chat.longChatShort'), action: t('Chat.newChat'), onAction: createChat,
614
667
  onDismiss: () => setDismissedComposerNotices((current) => new Set(current).add(`${chat.id}:long-chat`)),
615
668
  } : 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] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.28.0",
3
+ "version": "4.29.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {
@@ -71,13 +71,13 @@
71
71
  "@mui/x-charts": "^8.29.3",
72
72
  "@testing-library/react": "^16.3.3",
73
73
  "@vitejs/plugin-react": "^6.1.2",
74
- "i18next": "^26.4.2",
75
- "jsdom": "^30.1.2",
76
- "react-i18next": "^17.0.16",
74
+ "i18next": "^26.5.11",
75
+ "jsdom": "^30.1.3",
76
+ "react-i18next": "^17.1.9",
77
77
  "react-markdown": "^10.1.0",
78
78
  "remark-gfm": "^4.0.1",
79
79
  "typescript": "^7.0.2",
80
- "vite": "^8.3.4",
81
- "vitest": "^5.0.3"
80
+ "vite": "^8.3.5",
81
+ "vitest": "^5.0.5"
82
82
  }
83
83
  }