@arbidocs/react 0.5.62 → 0.5.64
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/README.md +9 -0
- package/dist/artifacts/index.cjs +2 -2
- package/dist/artifacts/index.js +1 -1
- package/dist/calls/livekit/index.cjs +41 -41
- package/dist/calls/livekit/index.js +2 -2
- package/dist/{chunk-BLBXADTN.cjs → chunk-24Q3WUQK.cjs} +5 -5
- package/dist/{chunk-BLBXADTN.cjs.map → chunk-24Q3WUQK.cjs.map} +1 -1
- package/dist/{chunk-ER4LFZG3.js → chunk-QGOYIYLI.js} +245 -63
- package/dist/chunk-QGOYIYLI.js.map +1 -0
- package/dist/{chunk-DVL7EFZZ.cjs → chunk-RS6UUPD2.cjs} +245 -63
- package/dist/chunk-RS6UUPD2.cjs.map +1 -0
- package/dist/{chunk-NCMSQACC.js → chunk-YIIML7Y5.js} +3 -3
- package/dist/{chunk-NCMSQACC.js.map → chunk-YIIML7Y5.js.map} +1 -1
- package/dist/index.cjs +417 -417
- package/dist/index.d.cts +104 -24
- package/dist/index.d.ts +104 -24
- package/dist/index.js +4 -4
- package/package.json +3 -3
- package/dist/chunk-DVL7EFZZ.cjs.map +0 -1
- package/dist/chunk-ER4LFZG3.js.map +0 -1
|
@@ -6,6 +6,130 @@ import { getUserEncryptionKeypair, sealedBoxDecrypt, sealedBoxEncrypt } from '@a
|
|
|
6
6
|
import { useSyncExternalStore, useCallback, useMemo, useRef, useEffect } from 'react';
|
|
7
7
|
import { useQuery, useMutation, useQueryClient, useInfiniteQuery, useQueries } from '@tanstack/react-query';
|
|
8
8
|
|
|
9
|
+
// src/session/thread-tabs.ts
|
|
10
|
+
var threadTabId = (tab) => tab.conversationId ?? "new";
|
|
11
|
+
var MAX_THREAD_TABS = 12;
|
|
12
|
+
var withView = (threads, tabId, view) => threads.map((tab) => tabId !== null && threadTabId(tab) === tabId ? { ...tab, view } : tab);
|
|
13
|
+
function selectThreadTabIn(tabs, tabId, leaving) {
|
|
14
|
+
const target = tabs.threads.find((tab) => threadTabId(tab) === tabId);
|
|
15
|
+
if (!target) return { tabs, show: null };
|
|
16
|
+
const isActive = tabs.activeThread === tabId;
|
|
17
|
+
if (isActive && leaving.conversationId === target.conversationId) return { tabs, show: null };
|
|
18
|
+
return {
|
|
19
|
+
tabs: {
|
|
20
|
+
...tabs,
|
|
21
|
+
// Re-opening the active tab saves nothing: its live composer is the cleared one.
|
|
22
|
+
threads: isActive ? tabs.threads : withView(tabs.threads, tabs.activeThread, leaving.view),
|
|
23
|
+
activeThread: tabId,
|
|
24
|
+
threadScrollRestore: target.view?.scrollTop ?? null
|
|
25
|
+
},
|
|
26
|
+
show: { conversationId: target.conversationId, view: target.view }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function openThreadTabIn(tabs, conversationId, leaving) {
|
|
30
|
+
const tabId = conversationId ?? "new";
|
|
31
|
+
const existing = tabs.threads.find((tab) => threadTabId(tab) === tabId);
|
|
32
|
+
if (existing) {
|
|
33
|
+
const threads2 = tabs.threads.map(
|
|
34
|
+
(tab) => threadTabId(tab) === tabId && tab.view ? { ...tab, view: { ...tab.view, scrollTop: null, cursor: null } } : tab
|
|
35
|
+
);
|
|
36
|
+
return { tabId, ...selectThreadTabIn({ ...tabs, threads: threads2 }, tabId, leaving) };
|
|
37
|
+
}
|
|
38
|
+
const fresh = { conversationId, view: void 0 };
|
|
39
|
+
const onlyNewChat = tabs.threads.length === 1 && tabs.threads[0].conversationId === null;
|
|
40
|
+
if (conversationId && onlyNewChat)
|
|
41
|
+
return {
|
|
42
|
+
tabId,
|
|
43
|
+
tabs: { ...tabs, threads: [{ conversationId }], activeThread: tabId },
|
|
44
|
+
show: fresh
|
|
45
|
+
};
|
|
46
|
+
let threads = [...withView(tabs.threads, tabs.activeThread, leaving.view), { conversationId }];
|
|
47
|
+
if (threads.length > MAX_THREAD_TABS) {
|
|
48
|
+
const evict = threads.findIndex(
|
|
49
|
+
(tab, i) => i < threads.length - 1 && threadTabId(tab) !== tabs.activeThread
|
|
50
|
+
);
|
|
51
|
+
if (evict !== -1) threads = threads.filter((_, i) => i !== evict);
|
|
52
|
+
}
|
|
53
|
+
return { tabId, tabs: { ...tabs, threads, activeThread: tabId }, show: fresh };
|
|
54
|
+
}
|
|
55
|
+
function closeThreadTabIn(tabs, tabId) {
|
|
56
|
+
const threads = tabs.threads.filter((tab) => threadTabId(tab) !== tabId);
|
|
57
|
+
if (threads.length === 0)
|
|
58
|
+
return { tabs: { ...tabs, threads: [], activeThread: null }, show: "list" };
|
|
59
|
+
if (tabs.activeThread !== tabId) return { tabs: { ...tabs, threads }, show: null };
|
|
60
|
+
const index = tabs.threads.findIndex((tab) => threadTabId(tab) === tabId);
|
|
61
|
+
const next = threads[Math.min(index, threads.length - 1)];
|
|
62
|
+
return {
|
|
63
|
+
tabs: { ...tabs, threads, activeThread: threadTabId(next) },
|
|
64
|
+
show: { conversationId: next.conversationId, view: next.view }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function showThreadListIn(tabs, leaving) {
|
|
68
|
+
return {
|
|
69
|
+
...tabs,
|
|
70
|
+
activeThread: null,
|
|
71
|
+
threads: tabs.threads.map(
|
|
72
|
+
(tab) => threadTabId(tab) === tabs.activeThread ? { ...tab, view: { ...leaving.view, scrollTop: null } } : tab.view ? { ...tab, view: { ...tab.view, scrollTop: null } } : tab
|
|
73
|
+
)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function renameThreadTabIn(tabs, fromId, toId) {
|
|
77
|
+
if (fromId === toId || !tabs.threads.some((tab) => threadTabId(tab) === fromId)) return tabs;
|
|
78
|
+
const taken = tabs.threads.some((tab) => threadTabId(tab) === toId);
|
|
79
|
+
return {
|
|
80
|
+
...tabs,
|
|
81
|
+
activeThread: tabs.activeThread === fromId ? toId : tabs.activeThread,
|
|
82
|
+
threads: taken ? tabs.threads.filter((tab) => threadTabId(tab) !== fromId) : tabs.threads.map(
|
|
83
|
+
(tab) => threadTabId(tab) === fromId ? { ...tab, conversationId: toId } : tab
|
|
84
|
+
)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function withThreadDrafts(threads, drafts) {
|
|
88
|
+
let changed = false;
|
|
89
|
+
const next = threads.map((tab) => {
|
|
90
|
+
const draft = drafts[threadTabId(tab)];
|
|
91
|
+
if (!draft || !tab.view || tab.view.draft) return tab;
|
|
92
|
+
changed = true;
|
|
93
|
+
return { ...tab, view: { ...tab.view, draft } };
|
|
94
|
+
});
|
|
95
|
+
return changed ? next : threads;
|
|
96
|
+
}
|
|
97
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
98
|
+
var stringOrNull = (v) => typeof v === "string" ? v : null;
|
|
99
|
+
var stringOrUndefined = (v) => typeof v === "string" ? v : void 0;
|
|
100
|
+
function parseView(value) {
|
|
101
|
+
if (!isRecord(value)) return void 0;
|
|
102
|
+
return {
|
|
103
|
+
cursor: stringOrNull(value.cursor),
|
|
104
|
+
draft: "",
|
|
105
|
+
editingMessageId: stringOrNull(value.editingMessageId),
|
|
106
|
+
preEditDraft: null,
|
|
107
|
+
preEditCursor: stringOrNull(value.preEditCursor),
|
|
108
|
+
chatModel: stringOrUndefined(value.chatModel),
|
|
109
|
+
chatModelName: stringOrUndefined(value.chatModelName),
|
|
110
|
+
scrollTop: typeof value.scrollTop === "number" && Number.isFinite(value.scrollTop) ? value.scrollTop : null
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function parseSavedThreadTabs(threads, activeThread) {
|
|
114
|
+
const tabs = [];
|
|
115
|
+
for (const entry of Array.isArray(threads) ? threads : []) {
|
|
116
|
+
if (!isRecord(entry)) continue;
|
|
117
|
+
const { conversationId } = entry;
|
|
118
|
+
if (conversationId !== null && typeof conversationId !== "string") continue;
|
|
119
|
+
const view = parseView(entry.view);
|
|
120
|
+
const tab = view ? { conversationId, view } : { conversationId };
|
|
121
|
+
if (!tabs.some((t) => threadTabId(t) === threadTabId(tab))) tabs.push(tab);
|
|
122
|
+
}
|
|
123
|
+
const active = typeof activeThread === "string" ? activeThread : null;
|
|
124
|
+
return {
|
|
125
|
+
threads: tabs,
|
|
126
|
+
activeThread: active && tabs.some((tab) => threadTabId(tab) === active) ? active : null
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
var savedThreadTabs = (threads) => threads.map(
|
|
130
|
+
(tab) => tab.view ? { ...tab, view: { ...tab.view, draft: "", preEditDraft: null } } : tab
|
|
131
|
+
);
|
|
132
|
+
|
|
9
133
|
// src/session/layout.ts
|
|
10
134
|
var PANEL_MODES = ["main", "docked", "overlay", "popout"];
|
|
11
135
|
var defaultPinned = () => typeof window === "undefined" || window.innerWidth >= 640;
|
|
@@ -17,26 +141,36 @@ function defaultLayoutState() {
|
|
|
17
141
|
panels: { main: null, docked: null, overlay: null, popout: null, modes: {}, sizes: {} },
|
|
18
142
|
focusedArea: "main"
|
|
19
143
|
},
|
|
20
|
-
tabs: {
|
|
144
|
+
tabs: {
|
|
145
|
+
threads: [],
|
|
146
|
+
activeThread: null,
|
|
147
|
+
threadScrollRestore: null,
|
|
148
|
+
dm: [],
|
|
149
|
+
activeDm: null,
|
|
150
|
+
dmMessageId: null,
|
|
151
|
+
projects: [],
|
|
152
|
+
activeProject: null
|
|
153
|
+
},
|
|
21
154
|
views: { tabs: {}, filters: {}, values: {}, transient: {} },
|
|
22
155
|
grid: { states: {}, rowHeights: {}, labelWidths: {}, savedViews: {} }
|
|
23
156
|
};
|
|
24
157
|
}
|
|
25
|
-
var
|
|
26
|
-
var recordOf = (value, keep) =>
|
|
158
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
159
|
+
var recordOf = (value, keep) => isRecord2(value) ? Object.fromEntries(Object.entries(value).filter(([, v]) => keep(v))) : {};
|
|
27
160
|
var isString = (v) => typeof v === "string";
|
|
28
161
|
var isNumber = (v) => typeof v === "number" && Number.isFinite(v);
|
|
29
162
|
var isAny = (v) => v !== void 0;
|
|
30
163
|
var isMode = (v) => PANEL_MODES.includes(v);
|
|
31
|
-
var isSize = (v) =>
|
|
164
|
+
var isSize = (v) => isRecord2(v) && isNumber(v.width) && isNumber(v.height);
|
|
32
165
|
var isList = (v) => Array.isArray(v);
|
|
33
|
-
var
|
|
166
|
+
var stringOrNull2 = (v) => isString(v) ? v : null;
|
|
34
167
|
function parseSavedLayout(saved) {
|
|
35
|
-
if (!
|
|
36
|
-
const shell =
|
|
37
|
-
const panels =
|
|
38
|
-
const
|
|
39
|
-
const
|
|
168
|
+
if (!isRecord2(saved) || saved.version !== 1) return null;
|
|
169
|
+
const shell = isRecord2(saved.shell) ? saved.shell : {};
|
|
170
|
+
const panels = isRecord2(shell.panels) ? shell.panels : {};
|
|
171
|
+
const tabs = isRecord2(saved.tabs) ? saved.tabs : {};
|
|
172
|
+
const views = isRecord2(saved.views) ? saved.views : {};
|
|
173
|
+
const grid = isRecord2(saved.grid) ? saved.grid : {};
|
|
40
174
|
const defaults = defaultLayoutState();
|
|
41
175
|
return {
|
|
42
176
|
version: 1,
|
|
@@ -45,19 +179,20 @@ function parseSavedLayout(saved) {
|
|
|
45
179
|
page: isString(shell.page) ? shell.page : defaults.shell.page,
|
|
46
180
|
sidebarPinned: typeof shell.sidebarPinned === "boolean" ? shell.sidebarPinned : defaults.shell.sidebar.pinned,
|
|
47
181
|
panels: {
|
|
48
|
-
main:
|
|
49
|
-
docked:
|
|
182
|
+
main: stringOrNull2(panels.main),
|
|
183
|
+
docked: stringOrNull2(panels.docked),
|
|
50
184
|
modes: recordOf(panels.modes, isMode),
|
|
51
185
|
sizes: recordOf(panels.sizes, isSize)
|
|
52
186
|
}
|
|
53
187
|
},
|
|
188
|
+
tabs: parseSavedThreadTabs(tabs.threads, tabs.activeThread),
|
|
54
189
|
views: {
|
|
55
190
|
tabs: recordOf(views.tabs, isString),
|
|
56
191
|
filters: recordOf(views.filters, isAny),
|
|
57
192
|
values: recordOf(views.values, isAny)
|
|
58
193
|
},
|
|
59
194
|
grid: {
|
|
60
|
-
states: recordOf(grid.states,
|
|
195
|
+
states: recordOf(grid.states, isRecord2),
|
|
61
196
|
rowHeights: recordOf(grid.rowHeights, isNumber),
|
|
62
197
|
labelWidths: recordOf(grid.labelWidths, isNumber),
|
|
63
198
|
savedViews: recordOf(grid.savedViews, isList)
|
|
@@ -65,7 +200,7 @@ function parseSavedLayout(saved) {
|
|
|
65
200
|
};
|
|
66
201
|
}
|
|
67
202
|
function savedLayoutOf(layout, migrated) {
|
|
68
|
-
const { shell, views, grid } = layout;
|
|
203
|
+
const { shell, tabs, views, grid } = layout;
|
|
69
204
|
return {
|
|
70
205
|
version: 1,
|
|
71
206
|
migrated,
|
|
@@ -80,6 +215,7 @@ function savedLayoutOf(layout, migrated) {
|
|
|
80
215
|
sizes: shell.panels.sizes
|
|
81
216
|
}
|
|
82
217
|
},
|
|
218
|
+
tabs: { threads: savedThreadTabs(tabs.threads), activeThread: tabs.activeThread },
|
|
83
219
|
views: { tabs: views.tabs, filters: views.filters, values: views.values },
|
|
84
220
|
grid
|
|
85
221
|
};
|
|
@@ -93,6 +229,7 @@ function restoreLayout(current, saved) {
|
|
|
93
229
|
sidebar: { ...current.shell.sidebar, pinned: saved.shell.sidebarPinned },
|
|
94
230
|
panels: { ...current.shell.panels, ...saved.shell.panels }
|
|
95
231
|
},
|
|
232
|
+
tabs: { ...current.tabs, ...saved.tabs },
|
|
96
233
|
views: { ...saved.views, transient: current.views.transient },
|
|
97
234
|
grid: saved.grid
|
|
98
235
|
};
|
|
@@ -126,8 +263,11 @@ function panelPlace(panels, panelId) {
|
|
|
126
263
|
}
|
|
127
264
|
var isPanelOpen = (state, panelId) => panelPlace(state.shell.panels, panelId) !== null;
|
|
128
265
|
var dmTabId = (tab) => tab.recipientId ?? "new";
|
|
129
|
-
function createArbiLayoutStore({
|
|
130
|
-
|
|
266
|
+
function createArbiLayoutStore({
|
|
267
|
+
persist,
|
|
268
|
+
initial
|
|
269
|
+
} = {}) {
|
|
270
|
+
let layout = { ...defaultLayoutState(), ...initial };
|
|
131
271
|
let migrated = [];
|
|
132
272
|
let isHydrated = !persist;
|
|
133
273
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -136,7 +276,7 @@ function createArbiLayoutStore({ persist } = {}) {
|
|
|
136
276
|
};
|
|
137
277
|
const update = (next) => {
|
|
138
278
|
if (next === layout) return;
|
|
139
|
-
const persisted = next.views.tabs !== layout.views.tabs || next.views.filters !== layout.views.filters || next.views.values !== layout.views.values || next.grid !== layout.grid || next.shell.page !== layout.shell.page || next.shell.sidebar.pinned !== layout.shell.sidebar.pinned || next.shell.panels !== layout.shell.panels;
|
|
279
|
+
const persisted = next.tabs.threads !== layout.tabs.threads || next.tabs.activeThread !== layout.tabs.activeThread || next.views.tabs !== layout.views.tabs || next.views.filters !== layout.views.filters || next.views.values !== layout.views.values || next.grid !== layout.grid || next.shell.page !== layout.shell.page || next.shell.sidebar.pinned !== layout.shell.sidebar.pinned || next.shell.panels !== layout.shell.panels;
|
|
140
280
|
layout = next;
|
|
141
281
|
listeners.forEach((listener) => listener());
|
|
142
282
|
if (persisted) save();
|
|
@@ -169,6 +309,41 @@ function createArbiLayoutStore({ persist } = {}) {
|
|
|
169
309
|
},
|
|
170
310
|
hydrated: () => hydration,
|
|
171
311
|
isHydrated: () => isHydrated,
|
|
312
|
+
threads: {
|
|
313
|
+
open: (conversationId, leaving) => {
|
|
314
|
+
const change = openThreadTabIn(layout.tabs, conversationId, leaving);
|
|
315
|
+
tabs(change.tabs);
|
|
316
|
+
return { tabId: change.tabId, show: change.show };
|
|
317
|
+
},
|
|
318
|
+
close: (tabId) => {
|
|
319
|
+
const change = closeThreadTabIn(layout.tabs, tabId);
|
|
320
|
+
tabs(change.tabs);
|
|
321
|
+
return change.show;
|
|
322
|
+
},
|
|
323
|
+
select: (tabId, leaving) => {
|
|
324
|
+
const change = selectThreadTabIn(layout.tabs, tabId, leaving);
|
|
325
|
+
if (change.tabs !== layout.tabs) tabs(change.tabs);
|
|
326
|
+
return change.show;
|
|
327
|
+
},
|
|
328
|
+
showList: (leaving) => tabs(showThreadListIn(layout.tabs, leaving)),
|
|
329
|
+
rename: (fromId, toId) => {
|
|
330
|
+
const next = renameThreadTabIn(layout.tabs, fromId, toId);
|
|
331
|
+
if (next !== layout.tabs) tabs(next);
|
|
332
|
+
},
|
|
333
|
+
clear: () => {
|
|
334
|
+
if (layout.tabs.threads.length > 0 || layout.tabs.activeThread !== null)
|
|
335
|
+
tabs({ threads: [], activeThread: null });
|
|
336
|
+
},
|
|
337
|
+
restoreDrafts: (drafts) => {
|
|
338
|
+
const threads = withThreadDrafts(layout.tabs.threads, drafts);
|
|
339
|
+
if (threads !== layout.tabs.threads) tabs({ threads });
|
|
340
|
+
},
|
|
341
|
+
consumeScrollRestore: () => {
|
|
342
|
+
const value = layout.tabs.threadScrollRestore;
|
|
343
|
+
if (value !== null) tabs({ threadScrollRestore: null });
|
|
344
|
+
return value;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
172
347
|
setPage: (page) => {
|
|
173
348
|
if (layout.shell.page !== page || layout.shell.focusedArea !== "main")
|
|
174
349
|
shell({ page, focusedArea: "main" });
|
|
@@ -435,8 +610,6 @@ var agentControl = {
|
|
|
435
610
|
};
|
|
436
611
|
|
|
437
612
|
// src/session/store.ts
|
|
438
|
-
var threadTabId = (tab) => tab.conversationId ?? "new";
|
|
439
|
-
var MAX_THREAD_TABS = 12;
|
|
440
613
|
var DEFAULT_DOCUMENT_VIEWER_STATE = {
|
|
441
614
|
tab: "pdf",
|
|
442
615
|
compareId: null,
|
|
@@ -469,8 +642,6 @@ var EMPTY_SESSION_STATE = {
|
|
|
469
642
|
activeCitationKey: null,
|
|
470
643
|
chatModel: void 0,
|
|
471
644
|
chatModelName: void 0,
|
|
472
|
-
threadTabs: [],
|
|
473
|
-
activeThreadTabId: null,
|
|
474
645
|
newConversationAssistantMode: "always",
|
|
475
646
|
pendingTools: null,
|
|
476
647
|
autoSendDraft: false,
|
|
@@ -500,6 +671,7 @@ function layoutActionsOf(layout) {
|
|
|
500
671
|
delete actions.hydrated;
|
|
501
672
|
delete actions.isHydrated;
|
|
502
673
|
delete actions.reset;
|
|
674
|
+
delete actions.threads;
|
|
503
675
|
return actions;
|
|
504
676
|
}
|
|
505
677
|
function withoutNew(record) {
|
|
@@ -511,12 +683,18 @@ function createArbiSessionStore(initial = {}, {
|
|
|
511
683
|
persist,
|
|
512
684
|
workspace = createArbiWorkspaceStore({ workspaceId: initial.workspaceId ?? null })
|
|
513
685
|
} = {}) {
|
|
514
|
-
const
|
|
686
|
+
const { shell, tabs, views, grid, ...rest } = initial;
|
|
687
|
+
const layout = createArbiLayoutStore({
|
|
688
|
+
persist,
|
|
689
|
+
initial: Object.fromEntries(
|
|
690
|
+
Object.entries({ shell, tabs, views, grid }).filter(([, part]) => part !== void 0)
|
|
691
|
+
)
|
|
692
|
+
});
|
|
515
693
|
if (initial.workspaceStatus) workspace.setWorkspaceStatus(initial.workspaceStatus);
|
|
516
694
|
let state = {
|
|
517
695
|
...EMPTY_SESSION_STATE,
|
|
696
|
+
...rest,
|
|
518
697
|
...layout.getLayout(),
|
|
519
|
-
...initial,
|
|
520
698
|
...workspace.getState()
|
|
521
699
|
};
|
|
522
700
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -568,6 +746,35 @@ function createArbiSessionStore(initial = {}, {
|
|
|
568
746
|
else delete drafts[key];
|
|
569
747
|
setDrafts(drafts);
|
|
570
748
|
};
|
|
749
|
+
const composer = () => ({
|
|
750
|
+
conversationId: state.conversationId,
|
|
751
|
+
view: {
|
|
752
|
+
cursor: state.cursor,
|
|
753
|
+
draft: selectDraft(state),
|
|
754
|
+
editingMessageId: state.editingMessageId,
|
|
755
|
+
preEditDraft: state.editingMessageId ? preEdit.draft : null,
|
|
756
|
+
preEditCursor: state.editingMessageId ? preEdit.cursor : null,
|
|
757
|
+
chatModel: state.chatModel,
|
|
758
|
+
chatModelName: state.chatModelName,
|
|
759
|
+
scrollTop: null
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
const show = (next) => {
|
|
763
|
+
if (next === null) return;
|
|
764
|
+
if (next === "list") {
|
|
765
|
+
preEdit = { draft: "", cursor: null };
|
|
766
|
+
return update({ conversationId: null, cursor: null, editingMessageId: null });
|
|
767
|
+
}
|
|
768
|
+
const view = next.view;
|
|
769
|
+
preEdit = { draft: view?.preEditDraft ?? "", cursor: view?.preEditCursor ?? null };
|
|
770
|
+
update({
|
|
771
|
+
conversationId: next.conversationId,
|
|
772
|
+
cursor: view?.cursor ?? null,
|
|
773
|
+
editingMessageId: view?.editingMessageId ?? null,
|
|
774
|
+
chatModel: view?.chatModel,
|
|
775
|
+
chatModelName: view?.chatModelName
|
|
776
|
+
});
|
|
777
|
+
};
|
|
571
778
|
return {
|
|
572
779
|
...layoutActionsOf(layout),
|
|
573
780
|
layoutHydrated: () => layout.hydrated(),
|
|
@@ -598,10 +805,9 @@ function createArbiSessionStore(initial = {}, {
|
|
|
598
805
|
pinnedDocumentId: null,
|
|
599
806
|
newAgentChat: null,
|
|
600
807
|
newChatDocumentId: null,
|
|
601
|
-
messageTimers: {}
|
|
602
|
-
threadTabs: [],
|
|
603
|
-
activeThreadTabId: null
|
|
808
|
+
messageTimers: {}
|
|
604
809
|
});
|
|
810
|
+
layout.threads.clear();
|
|
605
811
|
},
|
|
606
812
|
setConversationId: (conversationId) => {
|
|
607
813
|
if (state.conversationId !== conversationId)
|
|
@@ -669,13 +875,9 @@ function createArbiSessionStore(initial = {}, {
|
|
|
669
875
|
conversationDocuments: move(state.conversationDocuments),
|
|
670
876
|
conversationDocumentAutoAdd: move(state.conversationDocumentAutoAdd),
|
|
671
877
|
conversationFacts: move(state.conversationFacts),
|
|
672
|
-
conversationId: state.conversationId ?? toId
|
|
673
|
-
// The new chat's tab is now the conversation's.
|
|
674
|
-
threadTabs: state.threadTabs.map(
|
|
675
|
-
(tab) => threadTabId(tab) === fromId ? { conversationId: toId } : tab
|
|
676
|
-
),
|
|
677
|
-
activeThreadTabId: state.activeThreadTabId === fromId ? toId : state.activeThreadTabId
|
|
878
|
+
conversationId: state.conversationId ?? toId
|
|
678
879
|
});
|
|
880
|
+
layout.threads.rename(fromId, toId);
|
|
679
881
|
if (fromId in state.drafts) setDrafts(move(state.drafts));
|
|
680
882
|
},
|
|
681
883
|
setConversationFacts: (conversationId, factIds) => update({ conversationFacts: { ...state.conversationFacts, [conversationId]: factIds } }),
|
|
@@ -702,37 +904,17 @@ function createArbiSessionStore(initial = {}, {
|
|
|
702
904
|
if (state.chatModel !== chatModel) update({ chatModel });
|
|
703
905
|
},
|
|
704
906
|
openThreadTab: (conversationId) => {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
activeThreadTabId: id,
|
|
711
|
-
...conversationId === null ? { newChatDocumentId: null } : {}
|
|
712
|
-
});
|
|
713
|
-
if (state.conversationId !== conversationId)
|
|
714
|
-
update({ conversationId, cursor: null, editingMessageId: null });
|
|
715
|
-
return id;
|
|
716
|
-
},
|
|
717
|
-
closeThreadTab: (tabId) => {
|
|
718
|
-
const threadTabs = state.threadTabs.filter((tab) => threadTabId(tab) !== tabId);
|
|
719
|
-
if (threadTabs.length === state.threadTabs.length) return;
|
|
720
|
-
if (state.activeThreadTabId !== tabId) return update({ threadTabs });
|
|
721
|
-
const next = threadTabs.at(-1);
|
|
722
|
-
update({ threadTabs, activeThreadTabId: next ? threadTabId(next) : null });
|
|
723
|
-
if (next && state.conversationId !== next.conversationId)
|
|
724
|
-
update({ conversationId: next.conversationId, cursor: null, editingMessageId: null });
|
|
907
|
+
if (conversationId === null) update({ newAgentChat: null, newChatDocumentId: null });
|
|
908
|
+
else if (state.newAgentChat) update({ newAgentChat: null });
|
|
909
|
+
const { tabId, show: next } = layout.threads.open(conversationId, composer());
|
|
910
|
+
show(next);
|
|
911
|
+
return tabId;
|
|
725
912
|
},
|
|
913
|
+
closeThreadTab: (tabId) => show(layout.threads.close(tabId)),
|
|
726
914
|
selectThreadTab: (tabId) => {
|
|
727
|
-
if (tabId
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
const tab = state.threadTabs.find((t) => threadTabId(t) === tabId);
|
|
732
|
-
if (!tab) return;
|
|
733
|
-
update({ activeThreadTabId: tabId });
|
|
734
|
-
if (state.conversationId !== tab.conversationId)
|
|
735
|
-
update({ conversationId: tab.conversationId, cursor: null, editingMessageId: null });
|
|
915
|
+
if (tabId !== null) return show(layout.threads.select(tabId, composer()));
|
|
916
|
+
layout.threads.showList(composer());
|
|
917
|
+
show("list");
|
|
736
918
|
},
|
|
737
919
|
setChatModelName: (chatModelName) => {
|
|
738
920
|
if (state.chatModelName !== chatModelName) update({ chatModelName });
|
|
@@ -1482,5 +1664,5 @@ function useUserUsageToday(options) {
|
|
|
1482
1664
|
}
|
|
1483
1665
|
|
|
1484
1666
|
export { DEFAULT_DOCUMENT_VIEWER_STATE, EMPTY_SESSION_STATE, MAX_THREAD_TABS, MIN_QUEUED_MESSAGE_VISIBILITY_MS, PROJECT_CREATION_DENIED_REASON, WORKSPACE_LAST_OPENED_KEY, WORKSPACE_STORAGE_KEY, agentControl, browserWorkspaceStorage, clearSealedDrafts, closePanelIn, conversationKey, createArbiLayoutStore, createArbiSessionStore, createArbiWorkspaceStore, createDebouncedWriter, createSealedDraftStorage, createStoragePersist, defaultLayoutState, dmTabId, flushOnPageExit, isPanelOpen, isUsageMetered, layoutActionsOf, nextViewingDocument, openPanelIn, panelPlace, parseSavedLayout, queuedMessages, readWorkspaceLastOpened, restoreLayout, savedLayoutOf, selectDraft, selectIsGenerating, selectViewingDocumentId, threadTabId, useActivity, useAgents, useArbiSession, useArbiSessionState, useArbiSessionStore, useAssistantQuery, useAvailableModels, useBoxRole, useBuiltinCommands, useCanCreateProjects, useConfig, useConfigs, useConversationThreads, useConversations, useCurrentUser, useDeleteAgents, useDocumentVersionList, useFirmPool, useHealth, useMessageDetails, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessionPageTab, useSessionView, useSignedInSession, useTags, useThumbnails, useTopUpFirmPool, useTransientView, useUserUsageToday, useWorkspaceActivity, useWorkspaces };
|
|
1485
|
-
//# sourceMappingURL=chunk-
|
|
1486
|
-
//# sourceMappingURL=chunk-
|
|
1667
|
+
//# sourceMappingURL=chunk-QGOYIYLI.js.map
|
|
1668
|
+
//# sourceMappingURL=chunk-QGOYIYLI.js.map
|