@micha.bigler/ui-core-micha 4.29.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 +8 -0
- package/README.md +6 -0
- package/dist/chat/ChatWorkspace.js +14 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 4.29.0 - UCM-CHAT-16
|
|
4
12
|
|
|
5
13
|
Chat opens at its end, no empty chat entries, usable thread on phones. Found in the Maana staging acceptance of 2026-11-03.
|
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;
|
|
@@ -62,12 +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
|
*/
|
|
67
70
|
// On a phone the thread keeps at least half the screen: composer, notice and header take what is left (UCM-CHAT-16).
|
|
68
71
|
const CHAT_WORKSPACE_NARROW_THREAD_SX = { minHeight: '50vh' };
|
|
69
72
|
export const CHAT_WORKSPACE_SIDE_PANEL_SX = { borderLeft: 1, borderColor: 'divider', minHeight: 0, overflow: 'auto', contain: 'strict' };
|
|
70
|
-
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 }) {
|
|
71
74
|
var _a;
|
|
72
75
|
const { t } = useTranslation();
|
|
73
76
|
const theme = useTheme();
|
|
@@ -104,6 +107,9 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
104
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
|
|
105
108
|
// first message on. emptyIds are the chats known to be empty; emptyChecks remembers what was found per chat so each is read once.
|
|
106
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))); };
|
|
107
113
|
const emptyChecks = useRef(new Map()); // id -> 'pending' | 'empty' | 'used'
|
|
108
114
|
const markUsed = (id) => {
|
|
109
115
|
emptyChecks.current.set(id, 'used');
|
|
@@ -376,8 +382,8 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
376
382
|
useEffect(() => {
|
|
377
383
|
const untitled = (item) => !item.title || (item.title === 'New chat' && item.title_source !== 'user');
|
|
378
384
|
[...chats, ...archived].filter(untitled).forEach((item) => {
|
|
379
|
-
if (emptyChecks.current.has(item.id))
|
|
380
|
-
return;
|
|
385
|
+
if (emptyChecks.current.has(item.id) || inUse(item))
|
|
386
|
+
return; // a chat the app marked in use is never read as empty
|
|
381
387
|
emptyChecks.current.set(item.id, 'pending');
|
|
382
388
|
api.listTurns(item.id)
|
|
383
389
|
.then((page) => {
|
|
@@ -527,8 +533,10 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
527
533
|
const selectChat = (next) => { setChat(next); setListOpen(false); };
|
|
528
534
|
// "New chat" while an empty chat is open (or exists) shows that one instead of creating another.
|
|
529
535
|
const createChat = guarded(async () => {
|
|
536
|
+
var _a;
|
|
530
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.
|
|
531
|
-
const
|
|
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);
|
|
532
540
|
if (reusable) {
|
|
533
541
|
selectChat(reusable);
|
|
534
542
|
focusPending.current = true;
|
|
@@ -640,7 +648,7 @@ export function ChatWorkspace({ apiBase, wsUrl, api: apiOverrides, scope, preloa
|
|
|
640
648
|
return { text: t(texts[problem]), severity: 'warning' };
|
|
641
649
|
return null;
|
|
642
650
|
};
|
|
643
|
-
const list = (_jsx(ChatList, { chats: chats.filter((item) => !emptyIds.has(item.id)), archivedChats: archived.filter((item) => !emptyIds.has(item.id)), 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 }));
|
|
644
652
|
const notConfigured = status === 'not_configured' || problem === 'not_configured';
|
|
645
653
|
const unavailable = status === 'unavailable' || problem === 'unavailable';
|
|
646
654
|
const unavailableText = typeof unavailableReasonText === 'function' ? unavailableReasonText(unavailableReason) : unavailableReasonText === null || unavailableReasonText === void 0 ? void 0 : unavailableReasonText[unavailableReason];
|