@arbidocs/react 0.5.76 → 0.5.77
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 +6 -1
- package/dist/index.cjs +70 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -7
- package/dist/index.d.ts +25 -7
- package/dist/index.js +70 -24
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -180,6 +180,11 @@ host with state of its own composes its session from parts instead (`composeArbi
|
|
|
180
180
|
layout, workspace, chat, documents })`, with `createArbiDocumentSessionStore` or its own documents
|
|
181
181
|
part).
|
|
182
182
|
|
|
183
|
+
**Conversation settings.** `useConversationSettings()` is the open conversation's title and sharing
|
|
184
|
+
(`saveTitle`, `share`, `unshare`: one `PATCH` of the conversation, which the server resolves from the
|
|
185
|
+
conversation's workspace) and the model of the config its next turn runs on (`resetToDefaults` drops
|
|
186
|
+
the picked one).
|
|
187
|
+
|
|
183
188
|
## Artifact editing (`@arbidocs/react/artifacts`)
|
|
184
189
|
|
|
185
190
|
`useArtifactSession({ workspaceId, docId })` loads an artifact, holds the edit buffer, saves it as a
|
|
@@ -254,7 +259,7 @@ Form-to-request mappings (`taskComposerToCreateRequest`, `composePersona`, ...)
|
|
|
254
259
|
`@arbidocs/blocks/agents`. AI usage is reported in **£** (ex VAT), not dollars: use
|
|
255
260
|
`formatGbp(n)` (`£0.47`, `£12.40`, whole pounds as `£10`) and the `metered` flag on `useProjectUsage` /
|
|
256
261
|
`useProjectsUsage` (`false` = this deployment does not record usage). The messenger (a
|
|
257
|
-
side panel, or a messages page
|
|
262
|
+
side panel, or its list and thread parts on a messages page) is `ConnectedMessenger` in
|
|
258
263
|
`@arbidocs/blocks/connect`. See `docs/design/blocks-package.md`
|
|
259
264
|
("Hooks and mappings a host should not rewrite").
|
|
260
265
|
|
package/dist/index.cjs
CHANGED
|
@@ -6371,6 +6371,71 @@ function useAnswerAgentQuestion() {
|
|
|
6371
6371
|
[arbi, queryClient]
|
|
6372
6372
|
);
|
|
6373
6373
|
}
|
|
6374
|
+
var TITLE_MAX = 50;
|
|
6375
|
+
function useConversationSettings() {
|
|
6376
|
+
const session = chunk6RSVGLQY_cjs.useArbiSessionStore();
|
|
6377
|
+
const conversationId = chunk6RSVGLQY_cjs.useArbiSessionState((s) => s.conversationId);
|
|
6378
|
+
const chatModel = chunk6RSVGLQY_cjs.useArbiSessionState((s) => s.chatModel);
|
|
6379
|
+
const parentMessageId = chunk6RSVGLQY_cjs.useArbiSessionState((s) => s.cursor);
|
|
6380
|
+
const currentUser = chunk6RSVGLQY_cjs.useArbiSession().user;
|
|
6381
|
+
const { messageHistory } = useConversationData();
|
|
6382
|
+
const { conversations } = useConversationItems();
|
|
6383
|
+
const { data: userSettings } = chunkPMHFLOXY_cjs.useUserSettings();
|
|
6384
|
+
const parentMessage = messageHistory?.find((m) => m.external_id === parentMessageId);
|
|
6385
|
+
const configToLoad = chatModel || parentMessage?.config_ext_id || userSettings?.last_config || "default";
|
|
6386
|
+
const { data: activeConfig } = chunk6RSVGLQY_cjs.useConfig(configToLoad);
|
|
6387
|
+
const { refetch: refetchSystemDefaults } = chunk6RSVGLQY_cjs.useConfig("default");
|
|
6388
|
+
const conversation = conversations.find((c) => c.external_id === conversationId);
|
|
6389
|
+
const isOwner = !!conversation && conversation.created_by_ext_id === currentUser?.external_id;
|
|
6390
|
+
const isShared = conversation?.is_shared ?? false;
|
|
6391
|
+
const [title, setTitle] = React.useState("");
|
|
6392
|
+
React.useEffect(() => {
|
|
6393
|
+
setTitle(conversation?.title || "");
|
|
6394
|
+
}, [conversation?.title]);
|
|
6395
|
+
React.useEffect(() => {
|
|
6396
|
+
if (isFullConfig(activeConfig)) session.setChatModelName(resolveConfigModel(activeConfig));
|
|
6397
|
+
}, [activeConfig, configToLoad]);
|
|
6398
|
+
const update = useUpdateConversation();
|
|
6399
|
+
const pending = update.isPending ? update.variables?.patch : void 0;
|
|
6400
|
+
const saveTitle = React.useCallback(() => {
|
|
6401
|
+
const trimmed = title.trim();
|
|
6402
|
+
if (!conversationId || !isOwner || !trimmed || trimmed.length > TITLE_MAX) return;
|
|
6403
|
+
if (trimmed === conversation?.title) return;
|
|
6404
|
+
update.mutate({ conversationId, patch: { title: trimmed } });
|
|
6405
|
+
}, [conversationId, isOwner, title, conversation?.title, update]);
|
|
6406
|
+
const setShared = React.useCallback(
|
|
6407
|
+
(shared) => {
|
|
6408
|
+
if (!conversationId || !isOwner || isShared === shared) return;
|
|
6409
|
+
update.mutate({ conversationId, patch: { shared } });
|
|
6410
|
+
},
|
|
6411
|
+
[conversationId, isOwner, isShared, update]
|
|
6412
|
+
);
|
|
6413
|
+
const share = React.useCallback(() => setShared(true), [setShared]);
|
|
6414
|
+
const unshare = React.useCallback(() => setShared(false), [setShared]);
|
|
6415
|
+
const resetToDefaults = React.useCallback(async () => {
|
|
6416
|
+
try {
|
|
6417
|
+
const { data } = await refetchSystemDefaults();
|
|
6418
|
+
session.setChatModel(void 0);
|
|
6419
|
+
if (isFullConfig(data)) session.setChatModelName(resolveConfigModel(data));
|
|
6420
|
+
} catch (error) {
|
|
6421
|
+
console.error("Failed to reset to system defaults:", error);
|
|
6422
|
+
}
|
|
6423
|
+
}, [refetchSystemDefaults, session]);
|
|
6424
|
+
return {
|
|
6425
|
+
/** No message yet: nothing to title or share. */
|
|
6426
|
+
isNewConversation: !parentMessageId,
|
|
6427
|
+
title,
|
|
6428
|
+
setTitle,
|
|
6429
|
+
isOwner,
|
|
6430
|
+
isShared,
|
|
6431
|
+
isSavingTitle: pending !== void 0 && "title" in pending,
|
|
6432
|
+
isSharing: pending !== void 0 && "shared" in pending,
|
|
6433
|
+
saveTitle,
|
|
6434
|
+
share,
|
|
6435
|
+
unshare,
|
|
6436
|
+
resetToDefaults
|
|
6437
|
+
};
|
|
6438
|
+
}
|
|
6374
6439
|
function useAskAgain(options) {
|
|
6375
6440
|
const session = chunk6RSVGLQY_cjs.useArbiSessionStore();
|
|
6376
6441
|
const optionsRef = React.useRef(options);
|
|
@@ -6787,22 +6852,8 @@ function createMailClient(fetch2, overrides = {}) {
|
|
|
6787
6852
|
};
|
|
6788
6853
|
}
|
|
6789
6854
|
function arbiMailClient(arbi) {
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
unlocking ??= arbi.mail.unlockNative().finally(() => {
|
|
6793
|
-
unlocking = null;
|
|
6794
|
-
});
|
|
6795
|
-
return unlocking;
|
|
6796
|
-
};
|
|
6797
|
-
const fetch2 = async (path, init = {}) => {
|
|
6798
|
-
if (path.startsWith("/accounts/native/") && (init.method ?? "GET") !== "POST")
|
|
6799
|
-
await unlockNative();
|
|
6800
|
-
return arbi.mail.fetch(path, init);
|
|
6801
|
-
};
|
|
6802
|
-
return createMailClient(fetch2, {
|
|
6803
|
-
unlock: async (account) => {
|
|
6804
|
-
if (account.provider === "native") await unlockNative();
|
|
6805
|
-
}
|
|
6855
|
+
return createMailClient((path, init) => arbi.mail.fetch(path, init), {
|
|
6856
|
+
unlock: (account) => arbi.mail.unlockAccount(account)
|
|
6806
6857
|
});
|
|
6807
6858
|
}
|
|
6808
6859
|
async function fileAttachment(file) {
|
|
@@ -14762,17 +14813,12 @@ function useCommandPalette() {
|
|
|
14762
14813
|
if (!v) throw new Error("useCommandPalette must be used within a CommandPaletteProvider");
|
|
14763
14814
|
return v;
|
|
14764
14815
|
}
|
|
14765
|
-
function CommandPaletteProvider({
|
|
14766
|
-
children,
|
|
14767
|
-
hotkey = true,
|
|
14768
|
-
...paletteProps
|
|
14769
|
-
}) {
|
|
14816
|
+
function CommandPaletteProvider({ children, ...paletteProps }) {
|
|
14770
14817
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
14771
14818
|
const open = React.useCallback(() => setIsOpen(true), []);
|
|
14772
14819
|
const close = React.useCallback(() => setIsOpen(false), []);
|
|
14773
14820
|
const toggle = React.useCallback(() => setIsOpen((o) => !o), []);
|
|
14774
14821
|
React.useEffect(() => {
|
|
14775
|
-
if (!hotkey) return;
|
|
14776
14822
|
const onKey = (e) => {
|
|
14777
14823
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
|
|
14778
14824
|
e.preventDefault();
|
|
@@ -14781,7 +14827,7 @@ function CommandPaletteProvider({
|
|
|
14781
14827
|
};
|
|
14782
14828
|
window.addEventListener("keydown", onKey);
|
|
14783
14829
|
return () => window.removeEventListener("keydown", onKey);
|
|
14784
|
-
}, [
|
|
14830
|
+
}, [toggle]);
|
|
14785
14831
|
const value = React.useMemo(() => ({ open, close, toggle, isOpen }), [open, close, toggle, isOpen]);
|
|
14786
14832
|
return /* @__PURE__ */ jsxRuntime.jsxs(CommandPaletteCtx.Provider, { value, children: [
|
|
14787
14833
|
children,
|
|
@@ -17663,6 +17709,7 @@ exports.useConversationIsShared = useConversationIsShared;
|
|
|
17663
17709
|
exports.useConversationItems = useConversationItems;
|
|
17664
17710
|
exports.useConversationPendingAuth = useConversationPendingAuth;
|
|
17665
17711
|
exports.useConversationSearch = useConversationSearch;
|
|
17712
|
+
exports.useConversationSettings = useConversationSettings;
|
|
17666
17713
|
exports.useConversationTurn = useConversationTurn;
|
|
17667
17714
|
exports.useConversationUsage = useConversationUsage;
|
|
17668
17715
|
exports.useCreateAgent = useCreateAgent;
|