@arbidocs/blocks 0.5.183 → 0.5.185
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/dist/{ConnectedCallDock-CF7KF5KM.cjs → ConnectedCallDock-CKJUL7HZ.cjs} +5 -5
- package/dist/{ConnectedCallDock-CF7KF5KM.cjs.map → ConnectedCallDock-CKJUL7HZ.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-NQOE2RYD.cjs → ConnectedCallRoom-CDOGHVES.cjs} +5 -5
- package/dist/{ConnectedCallRoom-NQOE2RYD.cjs.map → ConnectedCallRoom-CDOGHVES.cjs.map} +1 -1
- package/dist/{ConnectedMailInviteCard-DDGB4LLC.cjs → ConnectedMailInviteCard-ZNBHPFKF.cjs} +8 -8
- package/dist/{ConnectedMailInviteCard-DDGB4LLC.cjs.map → ConnectedMailInviteCard-ZNBHPFKF.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-3KTHPCMT.cjs → ConnectedNativeDocxComparison-YP7SASIP.cjs} +8 -8
- package/dist/{ConnectedNativeDocxComparison-3KTHPCMT.cjs.map → ConnectedNativeDocxComparison-YP7SASIP.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-LNDESKYE.cjs → ConnectedPresentation-RFUH3MXL.cjs} +10 -10
- package/dist/{ConnectedPresentation-LNDESKYE.cjs.map → ConnectedPresentation-RFUH3MXL.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-SYDDGJWM.cjs → ConnectedSlidesTab-CCJWFSCX.cjs} +10 -10
- package/dist/{ConnectedSlidesTab-SYDDGJWM.cjs.map → ConnectedSlidesTab-CCJWFSCX.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-LUM6WE7F.cjs → ConnectedStreamedWordArtifact-GVVIWKFH.cjs} +8 -8
- package/dist/{ConnectedStreamedWordArtifact-LUM6WE7F.cjs.map → ConnectedStreamedWordArtifact-GVVIWKFH.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-NKCKBY3P.cjs → DocumentReviewCard-QD6VVDAE.cjs} +3 -3
- package/dist/{DocumentReviewCard-NKCKBY3P.cjs.map → DocumentReviewCard-QD6VVDAE.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-T4SOKUKO.cjs → FilesViewerDialog-S5KRHOFU.cjs} +15 -15
- package/dist/{FilesViewerDialog-T4SOKUKO.cjs.map → FilesViewerDialog-S5KRHOFU.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-QT63XYII.cjs → WorkspaceTableView-TPL6EWXL.cjs} +3 -3
- package/dist/{WorkspaceTableView-QT63XYII.cjs.map → WorkspaceTableView-TPL6EWXL.cjs.map} +1 -1
- package/dist/agents/index.cjs +175 -175
- package/dist/{ai-CTJWECJ5.cjs → ai-6K5DTBLO.cjs} +16 -16
- package/dist/ai-6K5DTBLO.cjs.map +1 -0
- package/dist/{avatar-renderer-OZKS2BSF.cjs → avatar-renderer-FTY24TKC.cjs} +97 -62
- package/dist/avatar-renderer-FTY24TKC.cjs.map +1 -0
- package/dist/calls/connected/CallAvatarMedia.d.ts +1 -1
- package/dist/calls/connected/CallAvatarMedia.js +9 -4
- package/dist/calls/connected/CallAvatarMedia.js.map +2 -2
- package/dist/calls/connected/CallPeoplePicker.js +5 -2
- package/dist/calls/connected/CallPeoplePicker.js.map +2 -2
- package/dist/calls/connected/ConnectedCallRoom.js +24 -0
- package/dist/calls/connected/ConnectedCallRoom.js.map +2 -2
- package/dist/calls/connected/DmCallButton.d.ts +2 -1
- package/dist/calls/connected/DmCallButton.js +10 -3
- package/dist/calls/connected/DmCallButton.js.map +2 -2
- package/dist/calls/connected/OwnedAgentCallButton.d.ts +2 -1
- package/dist/calls/connected/OwnedAgentCallButton.js +5 -2
- package/dist/calls/connected/OwnedAgentCallButton.js.map +2 -2
- package/dist/calls/connected/avatar-framing.d.ts +6 -1
- package/dist/calls/connected/avatar-framing.js +39 -11
- package/dist/calls/connected/avatar-framing.js.map +3 -3
- package/dist/calls/connected/avatar-renderer.js +21 -9
- package/dist/calls/connected/avatar-renderer.js.map +2 -2
- package/dist/calls/connected/call-media-state.js +1 -1
- package/dist/calls/connected/call-media-state.js.map +2 -2
- package/dist/calls/connected/call-people.d.ts +2 -1
- package/dist/calls/connected/call-people.js +11 -1
- package/dist/calls/connected/call-people.js.map +2 -2
- package/dist/calls/index.cjs +22 -22
- package/dist/{chunk-KHZEFLQC.cjs → chunk-26KJYXYH.cjs} +52 -5
- package/dist/chunk-26KJYXYH.cjs.map +1 -0
- package/dist/{chunk-HH5MKRBL.cjs → chunk-2EDVEP2X.cjs} +6 -6
- package/dist/{chunk-HH5MKRBL.cjs.map → chunk-2EDVEP2X.cjs.map} +1 -1
- package/dist/{chunk-W5UGKUV7.cjs → chunk-66IOCKWS.cjs} +124 -31
- package/dist/chunk-66IOCKWS.cjs.map +1 -0
- package/dist/{chunk-ZTLPUUZB.cjs → chunk-6IABKQKX.cjs} +6 -6
- package/dist/{chunk-ZTLPUUZB.cjs.map → chunk-6IABKQKX.cjs.map} +1 -1
- package/dist/{chunk-OHWYQI3B.cjs → chunk-7KUTY4N5.cjs} +9 -9
- package/dist/{chunk-OHWYQI3B.cjs.map → chunk-7KUTY4N5.cjs.map} +1 -1
- package/dist/{chunk-HHZDURXN.cjs → chunk-AS2FZ2T7.cjs} +3 -3
- package/dist/{chunk-HHZDURXN.cjs.map → chunk-AS2FZ2T7.cjs.map} +1 -1
- package/dist/{chunk-3YPVXIFF.cjs → chunk-CF3WPB7T.cjs} +4 -4
- package/dist/{chunk-3YPVXIFF.cjs.map → chunk-CF3WPB7T.cjs.map} +1 -1
- package/dist/{chunk-DWUWPF2A.cjs → chunk-EEB63QUE.cjs} +8 -8
- package/dist/{chunk-DWUWPF2A.cjs.map → chunk-EEB63QUE.cjs.map} +1 -1
- package/dist/{chunk-AZP4ABNL.cjs → chunk-EYOZNVQK.cjs} +4 -4
- package/dist/{chunk-AZP4ABNL.cjs.map → chunk-EYOZNVQK.cjs.map} +1 -1
- package/dist/{chunk-A4HOEGDI.cjs → chunk-FAFA56ZL.cjs} +4 -4
- package/dist/{chunk-A4HOEGDI.cjs.map → chunk-FAFA56ZL.cjs.map} +1 -1
- package/dist/{chunk-XKXKEVHH.cjs → chunk-HPIB5YRV.cjs} +5 -5
- package/dist/{chunk-XKXKEVHH.cjs.map → chunk-HPIB5YRV.cjs.map} +1 -1
- package/dist/{chunk-WIQDXRRB.cjs → chunk-HS626TSS.cjs} +5 -5
- package/dist/{chunk-WIQDXRRB.cjs.map → chunk-HS626TSS.cjs.map} +1 -1
- package/dist/{chunk-YYMCN76N.cjs → chunk-IM6R7DRQ.cjs} +5 -5
- package/dist/{chunk-YYMCN76N.cjs.map → chunk-IM6R7DRQ.cjs.map} +1 -1
- package/dist/{chunk-HYULUR6E.cjs → chunk-L6WEKQTV.cjs} +28 -28
- package/dist/{chunk-HYULUR6E.cjs.map → chunk-L6WEKQTV.cjs.map} +1 -1
- package/dist/{chunk-3EIO4ZH5.cjs → chunk-LUOL7TEY.cjs} +6 -6
- package/dist/{chunk-3EIO4ZH5.cjs.map → chunk-LUOL7TEY.cjs.map} +1 -1
- package/dist/{chunk-LRBX4VIG.cjs → chunk-PDKTW4L2.cjs} +5 -5
- package/dist/{chunk-LRBX4VIG.cjs.map → chunk-PDKTW4L2.cjs.map} +1 -1
- package/dist/{chunk-UFDUDQYT.cjs → chunk-QU3OCUVF.cjs} +1712 -71
- package/dist/chunk-QU3OCUVF.cjs.map +1 -0
- package/dist/{chunk-7GVKG3G4.cjs → chunk-R27P7TYW.cjs} +4 -4
- package/dist/{chunk-7GVKG3G4.cjs.map → chunk-R27P7TYW.cjs.map} +1 -1
- package/dist/{chunk-4H5DPHZ2.cjs → chunk-RDEUBZ3Z.cjs} +8 -8
- package/dist/{chunk-4H5DPHZ2.cjs.map → chunk-RDEUBZ3Z.cjs.map} +1 -1
- package/dist/{chunk-I5LXJLO5.cjs → chunk-TW5AGCHR.cjs} +31 -9
- package/dist/chunk-TW5AGCHR.cjs.map +1 -0
- package/dist/{chunk-5FSULBPE.cjs → chunk-U2T66I7C.cjs} +3 -3
- package/dist/{chunk-5FSULBPE.cjs.map → chunk-U2T66I7C.cjs.map} +1 -1
- package/dist/{chunk-NGT3P5ZG.cjs → chunk-VD3HI5RF.cjs} +6 -7
- package/dist/chunk-VD3HI5RF.cjs.map +1 -0
- package/dist/{chunk-4TCOUQMC.cjs → chunk-WQMIBHSQ.cjs} +6 -6
- package/dist/{chunk-4TCOUQMC.cjs.map → chunk-WQMIBHSQ.cjs.map} +1 -1
- package/dist/{chunk-TX7Y4A6T.cjs → chunk-X5PH6PM7.cjs} +38 -9
- package/dist/chunk-X5PH6PM7.cjs.map +1 -0
- package/dist/{chunk-7QZXHSQX.cjs → chunk-ZKXZKIPE.cjs} +27 -7
- package/dist/chunk-ZKXZKIPE.cjs.map +1 -0
- package/dist/connect/docx.cjs +11 -11
- package/dist/connect/index.cjs +767 -553
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +6 -6
- package/dist/connection/ConnectedAgentChatPanel.js +1 -1
- package/dist/connection/ConnectedAgentChatPanel.js.map +2 -2
- package/dist/connection/ConnectedAgentCreator.js +12 -4
- package/dist/connection/ConnectedAgentCreator.js.map +2 -2
- package/dist/connection/databases/ConnectedSourcesEditor.d.ts +4 -0
- package/dist/connection/databases/ConnectedSourcesEditor.js +126 -0
- package/dist/connection/databases/ConnectedSourcesEditor.js.map +7 -0
- package/dist/connection/databases/sourceCells.d.ts +14 -0
- package/dist/connection/databases/sourceCells.js +40 -0
- package/dist/connection/databases/sourceCells.js.map +7 -0
- package/dist/connection/databases/useApiDatabaseSource.js +35 -11
- package/dist/connection/databases/useApiDatabaseSource.js.map +2 -2
- package/dist/connection/databases/useDatabaseCellSources.d.ts +8 -1
- package/dist/connection/databases/useDatabaseCellSources.js +40 -5
- package/dist/connection/databases/useDatabaseCellSources.js.map +2 -2
- package/dist/connection/databases/wireColumns.d.ts +17 -0
- package/dist/connection/databases/wireColumns.js +22 -0
- package/dist/connection/databases/wireColumns.js.map +7 -0
- package/dist/connection/facts/documentPickerGroups.d.ts +3 -0
- package/dist/connection/facts/documentPickerGroups.js +21 -0
- package/dist/connection/facts/documentPickerGroups.js.map +7 -0
- package/dist/connection/facts/factsSource.js +2 -17
- package/dist/connection/facts/factsSource.js.map +2 -2
- package/dist/connection/facts/useFactComposer.js +6 -60
- package/dist/connection/facts/useFactComposer.js.map +2 -2
- package/dist/connection/facts/usePassageCollection.d.ts +21 -0
- package/dist/connection/facts/usePassageCollection.js +72 -0
- package/dist/connection/facts/usePassageCollection.js.map +7 -0
- package/dist/connection/messenger/ConnectedChatThread.js +1 -1
- package/dist/connection/messenger/ConnectedChatThread.js.map +2 -2
- package/dist/connection/pages/TableViewBlock.js +2 -6
- package/dist/connection/pages/TableViewBlock.js.map +2 -2
- package/dist/connection/settings-page/featuresSection.js +1 -1
- package/dist/connection/settings-page/featuresSection.js.map +1 -1
- package/dist/connection/tags/ConnectedTagsPage.js +4 -1
- package/dist/connection/tags/ConnectedTagsPage.js.map +2 -2
- package/dist/databases/DatabaseFilterMenu.d.ts +1 -1
- package/dist/databases/DatabaseFilterMenu.js +4 -3
- package/dist/databases/DatabaseFilterMenu.js.map +2 -2
- package/dist/databases/DatabaseRowDetail.js +18 -2
- package/dist/databases/DatabaseRowDetail.js.map +2 -2
- package/dist/databases/databaseColumns.js +7 -2
- package/dist/databases/databaseColumns.js.map +2 -2
- package/dist/databases/index.cjs +129 -132
- package/dist/databases/index.d.ts +1 -1
- package/dist/databases/index.js.map +2 -2
- package/dist/databases/linkCells.d.ts +37 -1
- package/dist/databases/linkCells.js +17 -2
- package/dist/databases/linkCells.js.map +2 -2
- package/dist/embed/index.cjs +13 -13
- package/dist/facts/index.cjs +53 -55
- package/dist/facts/index.cjs.map +1 -1
- package/dist/index.cjs +240 -241
- package/dist/index.cjs.map +1 -1
- package/dist/pages/index.cjs +25 -26
- package/dist/pages/index.cjs.map +1 -1
- package/dist/settings/index.cjs +9 -9
- package/dist/site/index.cjs +10 -11
- package/dist/studio/index.cjs +10 -11
- package/dist/studio/index.cjs.map +1 -1
- package/dist/timeline/index.cjs +12 -13
- package/dist/workflow-canvas/index.cjs +19 -19
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/record/render-take.py +5 -0
- package/dist/ai-CTJWECJ5.cjs.map +0 -1
- package/dist/avatar-renderer-OZKS2BSF.cjs.map +0 -1
- package/dist/chunk-7QZXHSQX.cjs.map +0 -1
- package/dist/chunk-GXJW5EK5.cjs +0 -102
- package/dist/chunk-GXJW5EK5.cjs.map +0 -1
- package/dist/chunk-I24N4OSB.cjs +0 -57
- package/dist/chunk-I24N4OSB.cjs.map +0 -1
- package/dist/chunk-I5LXJLO5.cjs.map +0 -1
- package/dist/chunk-KHZEFLQC.cjs.map +0 -1
- package/dist/chunk-NGT3P5ZG.cjs.map +0 -1
- package/dist/chunk-TX7Y4A6T.cjs.map +0 -1
- package/dist/chunk-UFDUDQYT.cjs.map +0 -1
- package/dist/chunk-VBD4RJOL.cjs +0 -1640
- package/dist/chunk-VBD4RJOL.cjs.map +0 -1
- package/dist/chunk-W5UGKUV7.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/facts/useFactComposer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The inline fact composer's state and behaviour: draft buffers, passage collection from the\n * document viewer, create/update/delete, and the \"dirty\" check that gates Save.\n */\nimport type { components } from '@arbidocs/client'\nimport { useCreateFact, useUpdateFact } from '@arbidocs/react'\nimport { refusalReason } from '@arbidocs/sdk/browser'\nimport { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from 'react'\nimport type { GridApi } from 'ag-grid-community'\nimport {\n EMPTY_FACT_DATE_FIELDS,\n factDateFieldsToSpan,\n factDateSpanToFields,\n type FactDateFields,\n} from '../../facts/fact-date'\nimport { decodeWhitespaceEntities } from '../../facts/fact-text'\nimport { toFactCitations, withChunk, withoutChunk } from '../../facts/fact-citations'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { factNouns } from './factNouns'\nimport type { Fact, FactPassageCollector } from './types'\n\ntype CitationSources = components['schemas']['CitationSources']\n\n/** Sentinel target for the composer, which has no fact id yet. */\nconst DRAFT_TARGET = '__draft__'\n\nconst NO_TAG_IDS: readonly string[] = []\n\nexport function useFactComposer(\n notes: Fact[],\n remove: (fact: Fact) => Promise<boolean>,\n gridApiRef: RefObject<GridApi<Fact> | null>,\n collector: FactPassageCollector | undefined,\n /** A request to start a fact (from another surface), and its done. */\n composeRequested: boolean,\n onComposeHandled: () => void,\n /** The page's workspace: a new fact is saved there. */\n workspaceId?: string | null,\n /** The labels a new fact starts with (a page showing one label's facts gives it that label). */\n newFactTagIds: readonly string[] = NO_TAG_IDS\n) {\n const { notify, openDocument } = useBlocksEnvironment()\n const FACT_LABELS = useMemo(factNouns, [])\n const createFact = useCreateFact(workspaceId)\n const updateFact = useUpdateFact()\n\n const [draftCitations, setDraftCitations] = useState<CitationSources | null>(null)\n // The composer's working labels, held locally until save.\n const [draftTagIds, setDraftTagIds] = useState<string[]>([])\n /** Which note is collecting passages from the viewer (DRAFT_TARGET = composer). */\n const [collectingFor, setCollectingFor] = useState<string | null>(null)\n\n const [composing, setComposing] = useState(false)\n const [draft, setDraft] = useState('')\n const draftRef = useRef(draft)\n draftRef.current = draft\n // The fact being deleted from the composer, for a page that watches the list.\n const deletingIdRef = useRef<string | null>(null)\n // The editor's canonicalised text on open (MDXEditor round-trips markdown, so\n // the raw fact text and the editor's form can differ). Used as the \"unchanged\"\n // baseline so an untouched fact leaves Save disabled.\n const [baselineText, setBaselineText] = useState('')\n const [draftDateFields, setDraftDateFields] = useState<FactDateFields>(EMPTY_FACT_DATE_FIELDS)\n const [composerError, setComposerError] = useState<string | null>(null)\n // Non-null while the composer is EDITING that fact (vs. creating a new one).\n const [editingId, setEditingId] = useState<string | null>(null)\n // Shared / Verified are editable in the composer itself, so a fact can be\n // shared-with-workspace or marked verified at the moment it's written or\n // edited \u2014 not only via the grid toggles after the fact. `confirmed` is the\n // backend's name for what the UI calls \"Verified\". New facts default to\n // private + verified (typing a fact is the vouch).\n const [draftShared, setDraftShared] = useState(false)\n const [draftConfirmed, setDraftConfirmed] = useState(true)\n // Bumped every time the composer (re)opens so the WYSIWYG editor remounts and\n // adopts the current draft's markdown (MDXEditor takes its value on mount).\n const [composerSession, setComposerSession] = useState(0)\n // A ref the grid's getRowClass reads (built once), kept in sync so the edited\n // row can be highlighted; changing it redraws the rows to re-apply the class.\n const editingIdRef = useRef<string | null>(null)\n useEffect(() => {\n editingIdRef.current = editingId\n const api = gridApiRef.current\n if (api && !api.isDestroyed()) api.redrawRows()\n }, [editingId, gridApiRef])\n\n // The document currently ON DISPLAY in the viewer (null when the viewer is closed) \u2014 used to\n // highlight the matching Source row in the composer.\n const displayedDocId = collector?.displayedDocId ?? null\n\n /** Arm (or disarm) passage collection for a note. */\n const armCollecting = useCallback(\n (target: string | null) => {\n setCollectingFor(target)\n if (!target) collector?.collect(null)\n },\n [collector]\n )\n\n /**\n * Cite a document: open it in the viewer armed to collect passages for this\n * note. Passages are chosen by reading, so citing means opening \u2014 and the\n * viewer tags the document's first passage on arrival, making a chosen\n * document a usable citation straight away.\n */\n\n const citeDocument = useCallback(\n (docExtId: string, target: string, opts?: { toggle?: boolean }) => {\n // Without the viewer's collection, citing a document just opens it.\n if (!collector) return openDocument(docExtId)\n // Toggle: clicking the source being picked from in the viewer closes it (and\n // disarms passage collection) instead of re-opening the same document \u2014\n // except from the document picker's list, which always opens. A document on\n // display that is not being picked from is opened for picking, as any other.\n if (\n opts?.toggle !== false &&\n displayedDocId === docExtId &&\n collector.collectingDocId === docExtId\n ) {\n collector.close()\n armCollecting(null)\n return\n }\n setCollectingFor(target)\n collector.open(docExtId, target === DRAFT_TARGET ? null : target)\n },\n [collector, openDocument, displayedDocId, armCollecting]\n )\n\n /** Arm (or disarm) passage collection for a source's Citation popover. While it\n * is open, clicking chunks in the viewer toggles them in the composer's draft\n * citations \u2014 the SAME collect flow citing a document uses (pending/unselected\n * passages \u2192 the effects above), so nothing else is needed to wire add/remove.\n * Pass the doc id to arm on open, null to disarm on close. Unlike citeDocument\n * this never toggles the viewer closed \u2014 the popover owns opening the doc. */\n const setSourceCitationSession = useCallback(\n (docExtId: string | null) => {\n if (docExtId) {\n setCollectingFor(DRAFT_TARGET)\n collector?.collect(docExtId)\n } else {\n armCollecting(null)\n }\n },\n [armCollecting, collector]\n )\n\n // Arriving from an \"add a fact\" surface: open the composer, clear the flag.\n useEffect(() => {\n if (!composeRequested) return\n // A request keeps the labels of a fact being edited, and seeds a new one only when the page\n // has labels to give it.\n if (newFactTagIds.length > 0 && !editingIdRef.current) setDraftTagIds([...newFactTagIds])\n setComposing(true)\n setComposerError(null)\n setComposerSession((s) => s + 1)\n onComposeHandled()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [composeRequested, newFactTagIds])\n\n // Passages tagged in the viewer land on whichever note is collecting.\n const picked = collector?.picked\n const docBeingCollected = collector?.collectingDocId\n useEffect(() => {\n if (!collector || !picked?.length || !collectingFor || !docBeingCollected) return\n const docExtId = docBeingCollected\n const apply = (prev: CitationSources | null): CitationSources => {\n let next = toFactCitations(prev)\n for (const pending of picked) {\n next = withChunk(next, docExtId, { chunk_id: pending.chunk_id, page: pending.page ?? null })\n }\n return next ?? []\n }\n setDraftCitations(apply)\n collector.consumePicked()\n }, [picked, collectingFor, docBeingCollected, collector])\n\n // Passages UN-tagged in the viewer drop from the note being collected \u2014 the\n // mirror of the effect above. Removing a document's LAST passage must NOT\n // un-source the document: it stays as a whole-document reference (removing\n // the source itself is the row's \u2715), which is withoutChunk's default.\n const unpicked = collector?.unpicked\n useEffect(() => {\n if (!collector || !unpicked?.length || !collectingFor) return\n setDraftCitations((prev) => {\n let next = toFactCitations(prev)\n for (const chunkId of unpicked) next = withoutChunk(next, chunkId)\n return next\n })\n collector.consumeUnpicked()\n }, [unpicked, collectingFor, collector])\n\n /** Clear the composer back to empty and closed. */\n const resetComposer = useCallback(() => {\n setDraft('')\n setBaselineText('')\n setDraftCitations(null)\n setDraftTagIds([])\n setDraftDateFields(EMPTY_FACT_DATE_FIELDS)\n setDraftShared(false)\n setDraftConfirmed(true)\n setComposerError(null)\n setEditingId(null)\n armCollecting(null)\n setComposing(false)\n }, [armCollecting])\n\n /** Open the composer for a fresh new fact (clearing any in-progress edit). */\n const startNewFact = useCallback(() => {\n setEditingId(null)\n setDraft('')\n setBaselineText('')\n setDraftCitations(null)\n setDraftTagIds([...newFactTagIds])\n setDraftDateFields(EMPTY_FACT_DATE_FIELDS)\n setDraftShared(false)\n setDraftConfirmed(true)\n setComposerError(null)\n setComposerSession((s) => s + 1)\n setComposing(true)\n }, [newFactTagIds])\n\n /** Save the composer \u2014 updates the fact when editing, otherwise creates one.\n * The composer is now the single editing surface (the dialog is gone). */\n const saveComposer = async () => {\n // Decode the editor's whitespace entities (a trailing space serialises to\n // ` `) so the stored text \u2014 and the grid preview of it \u2014 reads as typed.\n const content = decodeWhitespaceEntities(draft).trim()\n if (!content) return\n setComposerError(null)\n const span = factDateFieldsToSpan(draftDateFields)\n try {\n let saved: Fact\n if (editingId) {\n saved = (await updateFact.mutateAsync({\n factId: editingId,\n patch: {\n text: content,\n shared: draftShared,\n confirmed: draftConfirmed,\n citations: draftCitations,\n tag_ext_ids: draftTagIds,\n date: span.date,\n date_end: span.date_end,\n timezone: span.timezone,\n },\n })) as Fact\n notify(`${FACT_LABELS.SINGULAR} updated`, 'success')\n } else {\n saved = (await createFact.mutateAsync({\n text: content,\n shared: draftShared,\n // Verified defaults on (typing a fact is the vouch) but the composer\n // toggle can override it before the first save.\n confirmed: draftConfirmed,\n tag_ext_ids: draftTagIds,\n citations: draftCitations,\n date: span.date,\n date_end: span.date_end,\n timezone: span.timezone,\n })) as Fact\n notify(`${FACT_LABELS.SINGULAR} added`, 'success')\n }\n // Keep the composer OPEN on the fact just saved rather than closing it \u2014 a\n // user working through a run of facts (e.g. clicking events in the timeline)\n // stays on the one they saved and can keep refining it; only the toast\n // confirms the write. Adopt the saved fact's id: an edit soft-deletes the\n // old row and inserts a replacement with a NEW id (and a create had none),\n // so the previous editingId would otherwise dangle. Re-sync the buffers to\n // the saved fact and re-baseline the dirty check so Save disables again\n // until the next change.\n if (saved?.external_id) {\n setEditingId(saved.external_id)\n setBaselineText(draft)\n setDraftCitations(saved.citations ?? null)\n setDraftTagIds(saved.tags.map((t) => t.tag_ext_id))\n setDraftDateFields(factDateSpanToFields(saved.date_start, saved.date_end, saved.timezone))\n setDraftShared(saved.shared ?? false)\n setDraftConfirmed(saved.confirmed ?? true)\n }\n } catch (err) {\n setComposerError(\n refusalReason(\n err,\n editingId\n ? `Could not update ${FACT_LABELS.SINGULAR.toLowerCase()}`\n : `Could not add ${FACT_LABELS.SINGULAR.toLowerCase()}`\n )\n )\n }\n }\n\n /**\n * The open fact was reworded outside the composer's own save (a field saved on its own): follow\n * it to its new id, with the text as it stands as the new baseline.\n */\n const followReworded = useCallback((oldId: string, newId: string) => {\n setEditingId((current) => {\n if (current !== oldId) return current\n setBaselineText(draftRef.current)\n return newId\n })\n }, [])\n\n /** Delete the fact currently open in the composer, then close the composer. True once deleted. */\n const deleteEditingFact = async (): Promise<boolean> => {\n if (!editingId) return false\n const f = notes.find((n) => n.external_id === editingId)\n if (!f) return false\n // Said to the page, which would otherwise take the fact leaving the list for a delete elsewhere.\n deletingIdRef.current = editingId\n try {\n if (!(await remove(f))) return false\n } finally {\n deletingIdRef.current = null\n }\n resetComposer()\n return true\n }\n\n /** Open the full editor for a fact \u2014 the entry the retired actions column\n * used, now reached by double-clicking the row. */\n // Edit a fact in the same inline composer used to create one \u2014 pre-filled\n // with the fact's text, sources, labels and date. (Replaces the old dialog.)\n const openEdit = useCallback((m: Fact) => {\n setEditingId(m.external_id)\n setDraft(m.text)\n setBaselineText(m.text) // refined by the editor's onNormalized on mount\n setDraftCitations(m.citations ?? null)\n setDraftTagIds(m.tags.map((t) => t.tag_ext_id))\n setDraftDateFields(factDateSpanToFields(m.date_start, m.date_end, m.timezone))\n setDraftShared(m.shared ?? false)\n setDraftConfirmed(m.confirmed ?? true)\n setComposerError(null)\n setComposerSession((s) => s + 1)\n setComposing(true)\n }, [])\n\n // Whether the composer has anything worth saving: for a new fact, any text;\n // for an edit, a real change to the text, sources, labels or date. Keeps the\n // Save button disabled when an opened fact is left untouched.\n const composerDirty = useMemo(() => {\n if (!editingId) return draft.trim().length > 0\n const f = notes.find((n) => n.external_id === editingId)\n if (!f) return true\n const textChanged = draft.trim() !== baselineText.trim()\n const citationsChanged =\n JSON.stringify(draftCitations ?? null) !== JSON.stringify(f.citations ?? null)\n const tagsChanged =\n JSON.stringify([...draftTagIds].sort()) !==\n JSON.stringify(f.tags.map((t) => t.tag_ext_id).sort())\n const dateChanged =\n JSON.stringify(draftDateFields) !==\n JSON.stringify(factDateSpanToFields(f.date_start, f.date_end, f.timezone))\n const sharedChanged = draftShared !== (f.shared ?? false)\n const confirmedChanged = draftConfirmed !== (f.confirmed ?? true)\n return (\n textChanged ||\n citationsChanged ||\n tagsChanged ||\n dateChanged ||\n sharedChanged ||\n confirmedChanged\n )\n }, [\n editingId,\n notes,\n draft,\n baselineText,\n draftCitations,\n draftTagIds,\n draftDateFields,\n draftShared,\n draftConfirmed,\n ])\n\n return {\n composing,\n setComposing,\n draft,\n setDraft,\n setBaselineText,\n draftCitations,\n setDraftCitations,\n draftTagIds,\n setDraftTagIds,\n draftDateFields,\n setDraftDateFields,\n draftShared,\n setDraftShared,\n draftConfirmed,\n setDraftConfirmed,\n composerError,\n setComposerError,\n editingId,\n composerSession,\n editingIdRef,\n displayedDocId,\n resetComposer,\n startNewFact,\n saveComposer,\n deleteEditingFact,\n deletingIdRef,\n openEdit,\n composerDirty,\n /** The text differs from what the editor loaded or last saved. */\n textDirty: draft.trim() !== baselineText.trim(),\n followReworded,\n citeDocument,\n setSourceCitationSession,\n isSaving: createFact.isPending || updateFact.isPending,\n DRAFT_TARGET,\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAKA,SAAS,eAAe,qBAAqB;AAC7C,SAAS,qBAAqB;AAC9B,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgC;AAElF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gCAAgC;AACzC,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * The inline fact composer's state and behaviour: draft buffers, passage collection from the\n * document viewer, create/update/delete, and the \"dirty\" check that gates Save.\n */\nimport type { components } from '@arbidocs/client'\nimport { useCreateFact, useUpdateFact } from '@arbidocs/react'\nimport { refusalReason } from '@arbidocs/sdk/browser'\nimport { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from 'react'\nimport type { GridApi } from 'ag-grid-community'\nimport {\n EMPTY_FACT_DATE_FIELDS,\n factDateFieldsToSpan,\n factDateSpanToFields,\n type FactDateFields,\n} from '../../facts/fact-date'\nimport { decodeWhitespaceEntities } from '../../facts/fact-text'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { factNouns } from './factNouns'\nimport type { Fact, FactPassageCollector } from './types'\nimport { DRAFT_TARGET, usePassageCollection } from './usePassageCollection'\n\ntype CitationSources = components['schemas']['CitationSources']\n\nconst NO_TAG_IDS: readonly string[] = []\n\nexport function useFactComposer(\n notes: Fact[],\n remove: (fact: Fact) => Promise<boolean>,\n gridApiRef: RefObject<GridApi<Fact> | null>,\n collector: FactPassageCollector | undefined,\n /** A request to start a fact (from another surface), and its done. */\n composeRequested: boolean,\n onComposeHandled: () => void,\n /** The page's workspace: a new fact is saved there. */\n workspaceId?: string | null,\n /** The labels a new fact starts with (a page showing one label's facts gives it that label). */\n newFactTagIds: readonly string[] = NO_TAG_IDS\n) {\n const { notify } = useBlocksEnvironment()\n const FACT_LABELS = useMemo(factNouns, [])\n const createFact = useCreateFact(workspaceId)\n const updateFact = useUpdateFact()\n\n const [draftCitations, setDraftCitations] = useState<CitationSources | null>(null)\n // The composer's working labels, held locally until save.\n const [draftTagIds, setDraftTagIds] = useState<string[]>([])\n\n const [composing, setComposing] = useState(false)\n const [draft, setDraft] = useState('')\n const draftRef = useRef(draft)\n draftRef.current = draft\n // The fact being deleted from the composer, for a page that watches the list.\n const deletingIdRef = useRef<string | null>(null)\n // The editor's canonicalised text on open (MDXEditor round-trips markdown, so\n // the raw fact text and the editor's form can differ). Used as the \"unchanged\"\n // baseline so an untouched fact leaves Save disabled.\n const [baselineText, setBaselineText] = useState('')\n const [draftDateFields, setDraftDateFields] = useState<FactDateFields>(EMPTY_FACT_DATE_FIELDS)\n const [composerError, setComposerError] = useState<string | null>(null)\n // Non-null while the composer is EDITING that fact (vs. creating a new one).\n const [editingId, setEditingId] = useState<string | null>(null)\n // Shared / Verified are editable in the composer itself, so a fact can be\n // shared-with-workspace or marked verified at the moment it's written or\n // edited \u2014 not only via the grid toggles after the fact. `confirmed` is the\n // backend's name for what the UI calls \"Verified\". New facts default to\n // private + verified (typing a fact is the vouch).\n const [draftShared, setDraftShared] = useState(false)\n const [draftConfirmed, setDraftConfirmed] = useState(true)\n // Bumped every time the composer (re)opens so the WYSIWYG editor remounts and\n // adopts the current draft's markdown (MDXEditor takes its value on mount).\n const [composerSession, setComposerSession] = useState(0)\n // A ref the grid's getRowClass reads (built once), kept in sync so the edited\n // row can be highlighted; changing it redraws the rows to re-apply the class.\n const editingIdRef = useRef<string | null>(null)\n useEffect(() => {\n editingIdRef.current = editingId\n const api = gridApiRef.current\n if (api && !api.isDestroyed()) api.redrawRows()\n }, [editingId, gridApiRef])\n\n const { armCollecting, citeDocument, setSourceCitationSession } = usePassageCollection(\n collector,\n setDraftCitations\n )\n // The document currently ON DISPLAY in the viewer (null when the viewer is closed) \u2014 used to\n // highlight the matching Source row in the composer.\n const displayedDocId = collector?.displayedDocId ?? null\n\n // Arriving from an \"add a fact\" surface: open the composer, clear the flag.\n useEffect(() => {\n if (!composeRequested) return\n // A request keeps the labels of a fact being edited, and seeds a new one only when the page\n // has labels to give it.\n if (newFactTagIds.length > 0 && !editingIdRef.current) setDraftTagIds([...newFactTagIds])\n setComposing(true)\n setComposerError(null)\n setComposerSession((s) => s + 1)\n onComposeHandled()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [composeRequested, newFactTagIds])\n\n /** Clear the composer back to empty and closed. */\n const resetComposer = useCallback(() => {\n setDraft('')\n setBaselineText('')\n setDraftCitations(null)\n setDraftTagIds([])\n setDraftDateFields(EMPTY_FACT_DATE_FIELDS)\n setDraftShared(false)\n setDraftConfirmed(true)\n setComposerError(null)\n setEditingId(null)\n armCollecting(null)\n setComposing(false)\n }, [armCollecting])\n\n /** Open the composer for a fresh new fact (clearing any in-progress edit). */\n const startNewFact = useCallback(() => {\n setEditingId(null)\n setDraft('')\n setBaselineText('')\n setDraftCitations(null)\n setDraftTagIds([...newFactTagIds])\n setDraftDateFields(EMPTY_FACT_DATE_FIELDS)\n setDraftShared(false)\n setDraftConfirmed(true)\n setComposerError(null)\n setComposerSession((s) => s + 1)\n setComposing(true)\n }, [newFactTagIds])\n\n /** Save the composer \u2014 updates the fact when editing, otherwise creates one.\n * The composer is now the single editing surface (the dialog is gone). */\n const saveComposer = async () => {\n // Decode the editor's whitespace entities (a trailing space serialises to\n // ` `) so the stored text \u2014 and the grid preview of it \u2014 reads as typed.\n const content = decodeWhitespaceEntities(draft).trim()\n if (!content) return\n setComposerError(null)\n const span = factDateFieldsToSpan(draftDateFields)\n try {\n let saved: Fact\n if (editingId) {\n saved = (await updateFact.mutateAsync({\n factId: editingId,\n patch: {\n text: content,\n shared: draftShared,\n confirmed: draftConfirmed,\n citations: draftCitations,\n tag_ext_ids: draftTagIds,\n date: span.date,\n date_end: span.date_end,\n timezone: span.timezone,\n },\n })) as Fact\n notify(`${FACT_LABELS.SINGULAR} updated`, 'success')\n } else {\n saved = (await createFact.mutateAsync({\n text: content,\n shared: draftShared,\n // Verified defaults on (typing a fact is the vouch) but the composer\n // toggle can override it before the first save.\n confirmed: draftConfirmed,\n tag_ext_ids: draftTagIds,\n citations: draftCitations,\n date: span.date,\n date_end: span.date_end,\n timezone: span.timezone,\n })) as Fact\n notify(`${FACT_LABELS.SINGULAR} added`, 'success')\n }\n // Keep the composer OPEN on the fact just saved rather than closing it \u2014 a\n // user working through a run of facts (e.g. clicking events in the timeline)\n // stays on the one they saved and can keep refining it; only the toast\n // confirms the write. Adopt the saved fact's id: an edit soft-deletes the\n // old row and inserts a replacement with a NEW id (and a create had none),\n // so the previous editingId would otherwise dangle. Re-sync the buffers to\n // the saved fact and re-baseline the dirty check so Save disables again\n // until the next change.\n if (saved?.external_id) {\n setEditingId(saved.external_id)\n setBaselineText(draft)\n setDraftCitations(saved.citations ?? null)\n setDraftTagIds(saved.tags.map((t) => t.tag_ext_id))\n setDraftDateFields(factDateSpanToFields(saved.date_start, saved.date_end, saved.timezone))\n setDraftShared(saved.shared ?? false)\n setDraftConfirmed(saved.confirmed ?? true)\n }\n } catch (err) {\n setComposerError(\n refusalReason(\n err,\n editingId\n ? `Could not update ${FACT_LABELS.SINGULAR.toLowerCase()}`\n : `Could not add ${FACT_LABELS.SINGULAR.toLowerCase()}`\n )\n )\n }\n }\n\n /**\n * The open fact was reworded outside the composer's own save (a field saved on its own): follow\n * it to its new id, with the text as it stands as the new baseline.\n */\n const followReworded = useCallback((oldId: string, newId: string) => {\n setEditingId((current) => {\n if (current !== oldId) return current\n setBaselineText(draftRef.current)\n return newId\n })\n }, [])\n\n /** Delete the fact currently open in the composer, then close the composer. True once deleted. */\n const deleteEditingFact = async (): Promise<boolean> => {\n if (!editingId) return false\n const f = notes.find((n) => n.external_id === editingId)\n if (!f) return false\n // Said to the page, which would otherwise take the fact leaving the list for a delete elsewhere.\n deletingIdRef.current = editingId\n try {\n if (!(await remove(f))) return false\n } finally {\n deletingIdRef.current = null\n }\n resetComposer()\n return true\n }\n\n /** Open the full editor for a fact \u2014 the entry the retired actions column\n * used, now reached by double-clicking the row. */\n // Edit a fact in the same inline composer used to create one \u2014 pre-filled\n // with the fact's text, sources, labels and date. (Replaces the old dialog.)\n const openEdit = useCallback((m: Fact) => {\n setEditingId(m.external_id)\n setDraft(m.text)\n setBaselineText(m.text) // refined by the editor's onNormalized on mount\n setDraftCitations(m.citations ?? null)\n setDraftTagIds(m.tags.map((t) => t.tag_ext_id))\n setDraftDateFields(factDateSpanToFields(m.date_start, m.date_end, m.timezone))\n setDraftShared(m.shared ?? false)\n setDraftConfirmed(m.confirmed ?? true)\n setComposerError(null)\n setComposerSession((s) => s + 1)\n setComposing(true)\n }, [])\n\n // Whether the composer has anything worth saving: for a new fact, any text;\n // for an edit, a real change to the text, sources, labels or date. Keeps the\n // Save button disabled when an opened fact is left untouched.\n const composerDirty = useMemo(() => {\n if (!editingId) return draft.trim().length > 0\n const f = notes.find((n) => n.external_id === editingId)\n if (!f) return true\n const textChanged = draft.trim() !== baselineText.trim()\n const citationsChanged =\n JSON.stringify(draftCitations ?? null) !== JSON.stringify(f.citations ?? null)\n const tagsChanged =\n JSON.stringify([...draftTagIds].sort()) !==\n JSON.stringify(f.tags.map((t) => t.tag_ext_id).sort())\n const dateChanged =\n JSON.stringify(draftDateFields) !==\n JSON.stringify(factDateSpanToFields(f.date_start, f.date_end, f.timezone))\n const sharedChanged = draftShared !== (f.shared ?? false)\n const confirmedChanged = draftConfirmed !== (f.confirmed ?? true)\n return (\n textChanged ||\n citationsChanged ||\n tagsChanged ||\n dateChanged ||\n sharedChanged ||\n confirmedChanged\n )\n }, [\n editingId,\n notes,\n draft,\n baselineText,\n draftCitations,\n draftTagIds,\n draftDateFields,\n draftShared,\n draftConfirmed,\n ])\n\n return {\n composing,\n setComposing,\n draft,\n setDraft,\n setBaselineText,\n draftCitations,\n setDraftCitations,\n draftTagIds,\n setDraftTagIds,\n draftDateFields,\n setDraftDateFields,\n draftShared,\n setDraftShared,\n draftConfirmed,\n setDraftConfirmed,\n composerError,\n setComposerError,\n editingId,\n composerSession,\n editingIdRef,\n displayedDocId,\n resetComposer,\n startNewFact,\n saveComposer,\n deleteEditingFact,\n deletingIdRef,\n openEdit,\n composerDirty,\n /** The text differs from what the editor loaded or last saved. */\n textDirty: draft.trim() !== baselineText.trim(),\n followReworded,\n citeDocument,\n setSourceCitationSession,\n isSaving: createFact.isPending || updateFact.isPending,\n DRAFT_TARGET,\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAKA,SAAS,eAAe,qBAAqB;AAC7C,SAAS,qBAAqB;AAC9B,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgC;AAElF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAE1B,SAAS,cAAc,4BAA4B;AAInD,MAAM,aAAgC,CAAC;AAEhC,SAAS,gBACd,OACA,QACA,YACA,WAEA,kBACA,kBAEA,aAEA,gBAAmC,YACnC;AACA,QAAM,EAAE,OAAO,IAAI,qBAAqB;AACxC,QAAM,cAAc,QAAQ,WAAW,CAAC,CAAC;AACzC,QAAM,aAAa,cAAc,WAAW;AAC5C,QAAM,aAAa,cAAc;AAEjC,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAiC,IAAI;AAEjF,QAAM,CAAC,aAAa,cAAc,IAAI,SAAmB,CAAC,CAAC;AAE3D,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,QAAM,WAAW,OAAO,KAAK;AAC7B,WAAS,UAAU;AAEnB,QAAM,gBAAgB,OAAsB,IAAI;AAIhD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,EAAE;AACnD,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAyB,sBAAsB;AAC7F,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAEtE,QAAM,CAAC,WAAW,YAAY,IAAI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|
+
* Passage collection from the document viewer, for one list of citations: citing a document opens it
|
|
3
|
+
* in the viewer armed to collect, passages picked (or unpicked) there are added to (removed from) the
|
|
4
|
+
* list, and a source's popover can arm collection on a document already on display. Shared by the
|
|
5
|
+
* fact composer and a database's Sources field.
|
|
6
|
+
*/
|
|
7
|
+
import type { components } from '@arbidocs/client';
|
|
8
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
9
|
+
import type { FactPassageCollector } from './types';
|
|
10
|
+
type CitationSources = components['schemas']['CitationSources'];
|
|
11
|
+
/** Sentinel target for a list with no owner id yet (the composer's draft, a database cell). */
|
|
12
|
+
export declare const DRAFT_TARGET = "__draft__";
|
|
13
|
+
export declare function usePassageCollection(collector: FactPassageCollector | undefined, setCitations: Dispatch<SetStateAction<CitationSources | null>>): {
|
|
14
|
+
collectingFor: string | null;
|
|
15
|
+
armCollecting: (target: string | null) => void;
|
|
16
|
+
citeDocument: (docExtId: string, target: string, opts?: {
|
|
17
|
+
toggle?: boolean;
|
|
18
|
+
}) => void;
|
|
19
|
+
setSourceCitationSession: (docExtId: string | null) => void;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { toFactCitations, withChunk, withoutChunk } from "../../facts/fact-citations.js";
|
|
4
|
+
import { useBlocksEnvironment } from "../../provider/environment.js";
|
|
5
|
+
const DRAFT_TARGET = "__draft__";
|
|
6
|
+
function usePassageCollection(collector, setCitations) {
|
|
7
|
+
const { openDocument } = useBlocksEnvironment();
|
|
8
|
+
const [collectingFor, setCollectingFor] = useState(null);
|
|
9
|
+
const displayedDocId = collector?.displayedDocId ?? null;
|
|
10
|
+
const armCollecting = useCallback(
|
|
11
|
+
(target) => {
|
|
12
|
+
setCollectingFor(target);
|
|
13
|
+
if (!target) collector?.collect(null);
|
|
14
|
+
},
|
|
15
|
+
[collector]
|
|
16
|
+
);
|
|
17
|
+
const citeDocument = useCallback(
|
|
18
|
+
(docExtId, target, opts) => {
|
|
19
|
+
if (!collector) return openDocument(docExtId);
|
|
20
|
+
if (opts?.toggle !== false && displayedDocId === docExtId && collector.collectingDocId === docExtId) {
|
|
21
|
+
collector.close();
|
|
22
|
+
armCollecting(null);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
setCollectingFor(target);
|
|
26
|
+
collector.open(docExtId, target === DRAFT_TARGET ? null : target);
|
|
27
|
+
},
|
|
28
|
+
[collector, openDocument, displayedDocId, armCollecting]
|
|
29
|
+
);
|
|
30
|
+
const setSourceCitationSession = useCallback(
|
|
31
|
+
(docExtId) => {
|
|
32
|
+
if (docExtId) {
|
|
33
|
+
setCollectingFor(DRAFT_TARGET);
|
|
34
|
+
collector?.collect(docExtId);
|
|
35
|
+
} else {
|
|
36
|
+
armCollecting(null);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
[armCollecting, collector]
|
|
40
|
+
);
|
|
41
|
+
const picked = collector?.picked;
|
|
42
|
+
const docBeingCollected = collector?.collectingDocId;
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!collector || !picked?.length || !collectingFor || !docBeingCollected) return;
|
|
45
|
+
const docExtId = docBeingCollected;
|
|
46
|
+
const apply = (prev) => {
|
|
47
|
+
let next = toFactCitations(prev);
|
|
48
|
+
for (const pending of picked) {
|
|
49
|
+
next = withChunk(next, docExtId, { chunk_id: pending.chunk_id, page: pending.page ?? null });
|
|
50
|
+
}
|
|
51
|
+
return next ?? [];
|
|
52
|
+
};
|
|
53
|
+
setCitations(apply);
|
|
54
|
+
collector.consumePicked();
|
|
55
|
+
}, [picked, collectingFor, docBeingCollected, collector]);
|
|
56
|
+
const unpicked = collector?.unpicked;
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!collector || !unpicked?.length || !collectingFor) return;
|
|
59
|
+
setCitations((prev) => {
|
|
60
|
+
let next = toFactCitations(prev);
|
|
61
|
+
for (const chunkId of unpicked) next = withoutChunk(next, chunkId);
|
|
62
|
+
return next;
|
|
63
|
+
});
|
|
64
|
+
collector.consumeUnpicked();
|
|
65
|
+
}, [unpicked, collectingFor, collector]);
|
|
66
|
+
return { collectingFor, armCollecting, citeDocument, setSourceCitationSession };
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
DRAFT_TARGET,
|
|
70
|
+
usePassageCollection
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=usePassageCollection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/connection/facts/usePassageCollection.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Passage collection from the document viewer, for one list of citations: citing a document opens it\n * in the viewer armed to collect, passages picked (or unpicked) there are added to (removed from) the\n * list, and a source's popover can arm collection on a document already on display. Shared by the\n * fact composer and a database's Sources field.\n */\nimport type { components } from '@arbidocs/client'\nimport { useCallback, useEffect, useState, type Dispatch, type SetStateAction } from 'react'\nimport { toFactCitations, withChunk, withoutChunk } from '../../facts/fact-citations'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport type { FactPassageCollector } from './types'\n\ntype CitationSources = components['schemas']['CitationSources']\n\n/** Sentinel target for a list with no owner id yet (the composer's draft, a database cell). */\nexport const DRAFT_TARGET = '__draft__'\n\nexport function usePassageCollection(\n collector: FactPassageCollector | undefined,\n setCitations: Dispatch<SetStateAction<CitationSources | null>>\n) {\n const { openDocument } = useBlocksEnvironment()\n /** Which note is collecting passages from the viewer (DRAFT_TARGET = the draft). */\n const [collectingFor, setCollectingFor] = useState<string | null>(null)\n\n // The document currently ON DISPLAY in the viewer (null when the viewer is closed).\n const displayedDocId = collector?.displayedDocId ?? null\n\n /** Arm (or disarm) passage collection for a note. */\n const armCollecting = useCallback(\n (target: string | null) => {\n setCollectingFor(target)\n if (!target) collector?.collect(null)\n },\n [collector]\n )\n\n /**\n * Cite a document: open it in the viewer armed to collect passages for this\n * note. Passages are chosen by reading, so citing means opening \u2014 and the\n * viewer tags the document's first passage on arrival, making a chosen\n * document a usable citation straight away.\n */\n\n const citeDocument = useCallback(\n (docExtId: string, target: string, opts?: { toggle?: boolean }) => {\n // Without the viewer's collection, citing a document just opens it.\n if (!collector) return openDocument(docExtId)\n // Toggle: clicking the source being picked from in the viewer closes it (and\n // disarms passage collection) instead of re-opening the same document \u2014\n // except from the document picker's list, which always opens. A document on\n // display that is not being picked from is opened for picking, as any other.\n if (\n opts?.toggle !== false &&\n displayedDocId === docExtId &&\n collector.collectingDocId === docExtId\n ) {\n collector.close()\n armCollecting(null)\n return\n }\n setCollectingFor(target)\n collector.open(docExtId, target === DRAFT_TARGET ? null : target)\n },\n [collector, openDocument, displayedDocId, armCollecting]\n )\n\n /** Arm (or disarm) passage collection for a source's Citation popover. While it\n * is open, clicking chunks in the viewer toggles them in the composer's draft\n * citations \u2014 the SAME collect flow citing a document uses (pending/unselected\n * passages \u2192 the effects above), so nothing else is needed to wire add/remove.\n * Pass the doc id to arm on open, null to disarm on close. Unlike citeDocument\n * this never toggles the viewer closed \u2014 the popover owns opening the doc. */\n const setSourceCitationSession = useCallback(\n (docExtId: string | null) => {\n if (docExtId) {\n setCollectingFor(DRAFT_TARGET)\n collector?.collect(docExtId)\n } else {\n armCollecting(null)\n }\n },\n [armCollecting, collector]\n )\n\n // Passages tagged in the viewer land on whichever note is collecting.\n const picked = collector?.picked\n const docBeingCollected = collector?.collectingDocId\n useEffect(() => {\n if (!collector || !picked?.length || !collectingFor || !docBeingCollected) return\n const docExtId = docBeingCollected\n const apply = (prev: CitationSources | null): CitationSources => {\n let next = toFactCitations(prev)\n for (const pending of picked) {\n next = withChunk(next, docExtId, { chunk_id: pending.chunk_id, page: pending.page ?? null })\n }\n return next ?? []\n }\n setCitations(apply)\n collector.consumePicked()\n }, [picked, collectingFor, docBeingCollected, collector])\n\n // Passages UN-tagged in the viewer drop from the note being collected \u2014 the\n // mirror of the effect above. Removing a document's LAST passage must NOT\n // un-source the document: it stays as a whole-document reference (removing\n // the source itself is the row's \u2715), which is withoutChunk's default.\n const unpicked = collector?.unpicked\n useEffect(() => {\n if (!collector || !unpicked?.length || !collectingFor) return\n setCitations((prev) => {\n let next = toFactCitations(prev)\n for (const chunkId of unpicked) next = withoutChunk(next, chunkId)\n return next\n })\n collector.consumeUnpicked()\n }, [unpicked, collectingFor, collector])\n\n return { collectingFor, armCollecting, citeDocument, setSourceCitationSession }\n}\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,aAAa,WAAW,gBAAoD;AACrF,SAAS,iBAAiB,WAAW,oBAAoB;AACzD,SAAS,4BAA4B;AAM9B,MAAM,eAAe;AAErB,SAAS,qBACd,WACA,cACA;AACA,QAAM,EAAE,aAAa,IAAI,qBAAqB;AAE9C,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAGtE,QAAM,iBAAiB,WAAW,kBAAkB;AAGpD,QAAM,gBAAgB;AAAA,IACpB,CAAC,WAA0B;AACzB,uBAAiB,MAAM;AACvB,UAAI,CAAC,OAAQ,YAAW,QAAQ,IAAI;AAAA,IACtC;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AASA,QAAM,eAAe;AAAA,IACnB,CAAC,UAAkB,QAAgB,SAAgC;AAEjE,UAAI,CAAC,UAAW,QAAO,aAAa,QAAQ;AAK5C,UACE,MAAM,WAAW,SACjB,mBAAmB,YACnB,UAAU,oBAAoB,UAC9B;AACA,kBAAU,MAAM;AAChB,sBAAc,IAAI;AAClB;AAAA,MACF;AACA,uBAAiB,MAAM;AACvB,gBAAU,KAAK,UAAU,WAAW,eAAe,OAAO,MAAM;AAAA,IAClE;AAAA,IACA,CAAC,WAAW,cAAc,gBAAgB,aAAa;AAAA,EACzD;AAQA,QAAM,2BAA2B;AAAA,IAC/B,CAAC,aAA4B;AAC3B,UAAI,UAAU;AACZ,yBAAiB,YAAY;AAC7B,mBAAW,QAAQ,QAAQ;AAAA,MAC7B,OAAO;AACL,sBAAc,IAAI;AAAA,MACpB;AAAA,IACF;AAAA,IACA,CAAC,eAAe,SAAS;AAAA,EAC3B;AAGA,QAAM,SAAS,WAAW;AAC1B,QAAM,oBAAoB,WAAW;AACrC,YAAU,MAAM;AACd,QAAI,CAAC,aAAa,CAAC,QAAQ,UAAU,CAAC,iBAAiB,CAAC,kBAAmB;AAC3E,UAAM,WAAW;AACjB,UAAM,QAAQ,CAAC,SAAkD;AAC/D,UAAI,OAAO,gBAAgB,IAAI;AAC/B,iBAAW,WAAW,QAAQ;AAC5B,eAAO,UAAU,MAAM,UAAU,EAAE,UAAU,QAAQ,UAAU,MAAM,QAAQ,QAAQ,KAAK,CAAC;AAAA,MAC7F;AACA,aAAO,QAAQ,CAAC;AAAA,IAClB;AACA,iBAAa,KAAK;AAClB,cAAU,cAAc;AAAA,EAC1B,GAAG,CAAC,QAAQ,eAAe,mBAAmB,SAAS,CAAC;AAMxD,QAAM,WAAW,WAAW;AAC5B,YAAU,MAAM;AACd,QAAI,CAAC,aAAa,CAAC,UAAU,UAAU,CAAC,cAAe;AACvD,iBAAa,CAAC,SAAS;AACrB,UAAI,OAAO,gBAAgB,IAAI;AAC/B,iBAAW,WAAW,SAAU,QAAO,aAAa,MAAM,OAAO;AACjE,aAAO;AAAA,IACT,CAAC;AACD,cAAU,gBAAgB;AAAA,EAC5B,GAAG,CAAC,UAAU,eAAe,SAAS,CAAC;AAEvC,SAAO,EAAE,eAAe,eAAe,cAAc,yBAAyB;AAChF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -449,7 +449,7 @@ function ConnectedChatThread({
|
|
|
449
449
|
draftRef: composerDraft,
|
|
450
450
|
appearance: floating ? "floating" : "standard",
|
|
451
451
|
actions: floating ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
452
|
-
isAgentChat && peerId && /* @__PURE__ */ jsx(OwnedAgentCallButton, { agentId: peerId }),
|
|
452
|
+
isAgentChat && peerId && /* @__PURE__ */ jsx(OwnedAgentCallButton, { agentId: peerId, workspaceExtId: selectedWorkspaceId }),
|
|
453
453
|
floatingControls
|
|
454
454
|
] }) : void 0,
|
|
455
455
|
placeholder: floating ? `Ask ${peer?.given_name || "Assistant"}\u2026` : "Type a message\u2026",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/messenger/ConnectedChatThread.tsx"],
|
|
4
|
-
"sourcesContent": ["import { FloatingAssistantIdentity } from '../../shell/floating-assistant-context'\n/**\n * One open chat thread \u2014 direct (a person, a self-chat, or my personal agent), group or meeting.\n *\n * Container-agnostic: a messenger frames it. Every message is end-to-end encrypted under the chat\n * key (`arbi.chats`); files are encrypted with their own keys and travel in a manifest under the\n * same chat key. A chat has no assistant \u2014 the one exception is the direct chat with my own agent\n * (the PA chat), which runs in the agent\u2019s Home workspace and records browsing changes as\n * context-only notes. A host draws more kinds of message (a call's) with `host.ThreadHistory`.\n */\n\nimport {\n useFloatingConversation,\n FloatingConversationControls,\n ConversationDrafts,\n} from '../panels/ConversationPresentation'\nimport { DmAgentProgress } from './DmAgentProgress'\nimport { OwnedAgentCallButton } from '../../calls/connected/OwnedAgentCallButton'\nimport { Fragment, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n ChatBubble,\n DateSeparator,\n DmComposer,\n annotateThread,\n myChatId,\n setOpenChat,\n useAgentDmStatus,\n useArbi,\n useArbiSessionState,\n useChatPost,\n useChatThread,\n useDeleteChatMessage,\n useMarkChatRead,\n useDmFileShares,\n useNotifications,\n userDisplayName,\n useWorkspaces,\n type ChatResponse,\n type ChatThreadMessage,\n type DmFileShareEntry,\n type DmUser,\n} from '@arbidocs/react'\nimport { formatFriendlyDate } from '@arbidocs/react/ui'\nimport {\n MessageAuthor,\n MessageRoot,\n MessageContent,\n MessageBubble,\n MessageBody,\n} from '../../chat/Message'\nimport { CompactChatContext } from '../../chat/CompactChatContext'\nimport { chats } from '@arbidocs/sdk/browser'\nimport { DmAccessRequestBanner, DmThreadFrame } from '../../collaboration/direct-messages/DmParts'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { ChatAttachmentList } from './ChatAttachments'\nimport { ConnectedChatMessageBody } from './ConnectedChatMessageBody'\nimport { DmFileShareCard } from './DmFileShareCard'\nimport { placeThreadEntries, type PlacedThreadEntry } from './thread-entries'\nimport { renderMessengerUser } from './messengerUser'\nimport type { ChatHistoryProps, ChatThreadItem, MessengerHost } from './types'\n\nexport interface ConnectedChatThreadProps {\n /** The chat to show; null for a peer never messaged (the direct chat is created on send). */\n chat: ChatResponse | null\n /** The other party of a direct chat (myself for a self-chat); unset for a group. */\n peer?: DmUser | null\n host?: MessengerHost\n /** Called after a message is sent. */\n onMessageSent?: () => void\n}\n\nconst THREAD_ACCESSORS = {\n senderId: (m: ChatThreadMessage) => m.sender_ext_id ?? '',\n createdAt: (m: ChatThreadMessage) => m.created_at,\n}\n\n/** Don't hand the user `TypeError: Failed to fetch`; our own messages pass through. */\nfunction sendErrorText(err: unknown): string {\n const raw = err instanceof Error ? err.message : ''\n const isNetworkError =\n !raw || /failed to fetch|networkerror|load failed|network request failed/i.test(raw)\n return isNetworkError ? 'Couldn\u2019t send \u2014 check your connection and try again.' : raw\n}\n\n/** Day separators: \"Today\", \"Yesterday\", \"Mar 3\". */\nfunction defaultFormatDay(iso: string): string {\n const raw = formatFriendlyDate(iso, false)\n return raw.charAt(0).toUpperCase() + raw.slice(1)\n}\n\n/** A thread is pinned to its newest message unless the reader scrolled up. */\nconst NEAR_BOTTOM_PX = 80\n\nexport function ConnectedChatThread({\n chat,\n peer,\n host = {},\n onMessageSent,\n}: ConnectedChatThreadProps) {\n const floating = useFloatingConversation()\n const setAssistantIdentity = useContext(FloatingAssistantIdentity)\n const floatingControls = useContext(FloatingConversationControls)\n const arbi = useArbi()\n const { notify } = useBlocksEnvironment()\n const me = myChatId(arbi)\n const drafts = useContext(ConversationDrafts)\n if (drafts && drafts.owner !== me) {\n drafts.entries.clear()\n drafts.owner = me\n }\n const draftKey = peer?.external_id ?? chat?.external_id ?? 'new'\n if (drafts && !drafts.entries.has(draftKey)) drafts.entries.set(draftKey, { current: null })\n const composerDraft = drafts?.entries.get(draftKey)\n\n const selectedWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const { data: workspaces = [] } = useWorkspaces()\n const workspaceName =\n workspaces.find((workspace) => workspace.external_id === selectedWorkspaceId)?.name ??\n selectedWorkspaceId\n const formatTime = host.formatTime ?? formatFriendlyDate\n const formatDay = host.formatDay ?? defaultFormatDay\n // Personal Assistant chat: the workspace my agent acts in must be usable on this session (its\n // key deposited), without switching to it.\n const prepareAgentWorkspace = useCallback(\n (workspaceId: string) =>\n arbi.workspaces.open(workspaceId).then(\n () => true,\n () => false\n ),\n [arbi]\n )\n\n const isGroup = !!chat && chat.kind !== 'direct'\n const peerId = isGroup ? null : (peer?.external_id ?? null)\n const isAgentChat = !!peerId?.startsWith('agt-')\n\n const { messages, hasMore, isLoading, loadOlder, loadingOlder } = useChatThread(chat)\n const postToChat = useChatPost()\n const deleteChatMessage = useDeleteChatMessage()\n const markRead = useMarkChatRead()\n const [isSending, setIsSending] = useState(false)\n const [sendError, setSendError] = useState<string | null>(null)\n const [awaitingAgentReply, setAwaitingAgentReply] = useState(false)\n const historyRef = useRef<HTMLDivElement>(null)\n\n // A chat created on first send is held here until the caller passes it in.\n const chatRef = useRef<ChatResponse | null>(chat)\n chatRef.current = chat ?? chatRef.current\n\n const membersById = useMemo(() => {\n const map = new Map<string, DmUser>()\n for (const m of chat?.members ?? []) map.set(m.user.external_id, m.user)\n if (peer) map.set(peer.external_id, peer)\n return map\n }, [chat, peer])\n\n // While open: new messages in this chat don't count as unread, and the watermark follows.\n useEffect(() => {\n if (!chat) return\n setOpenChat(chat.external_id)\n return () => setOpenChat(null)\n }, [chat?.external_id]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const newest = messages[messages.length - 1]\n const myReadAt = chat?.members.find((m) => m.user.external_id === me)?.last_read_at\n useEffect(() => {\n if (!chat || !newest || newest.optimistic) return\n const unread =\n chat.unread_count > 0 ||\n (newest.sender_ext_id !== me &&\n (!myReadAt || Date.parse(myReadAt) < Date.parse(newest.created_at)))\n if (!unread) return\n void markRead(chat, newest.external_id)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [chat?.external_id, chat?.unread_count, newest?.external_id])\n\n // Personal agent progress, keyed by the agent.\n const agentDmStatus = useAgentDmStatus(isAgentChat ? peerId : null)\n useEffect(() => {\n if (agentDmStatus?.status === 'done' || agentDmStatus?.status === 'failed') {\n setAwaitingAgentReply(false)\n }\n }, [agentDmStatus])\n useEffect(() => {\n if (awaitingAgentReply && newest && newest.sender_ext_id === peerId) {\n setAwaitingAgentReply(false)\n }\n }, [newest, awaitingAgentReply, peerId])\n const agentWorking =\n awaitingAgentReply || agentDmStatus?.status === 'working' || agentDmStatus?.status === 'queued'\n useEffect(() => {\n setAssistantIdentity?.(peer?.given_name || 'Assistant', agentWorking)\n }, [setAssistantIdentity, peer?.given_name, agentWorking])\n\n // Keep the newest message in view \u2014 also once an image above it has decrypted and grown the\n // thread \u2014 unless the reader has scrolled up.\n const pinnedToBottom = useRef(true)\n const viewport = () =>\n historyRef.current?.querySelector<HTMLElement>('[data-radix-scroll-area-viewport]') ?? null\n const scrollToNewest = useCallback(() => {\n const el = viewport()\n if (el) el.scrollTop = el.scrollHeight\n }, [])\n useEffect(() => {\n pinnedToBottom.current = true\n requestAnimationFrame(scrollToNewest)\n }, [newest?.external_id, scrollToNewest])\n useEffect(() => {\n const el = viewport()\n if (!el) return\n const onScroll = () => {\n pinnedToBottom.current = el.scrollHeight - el.scrollTop - el.clientHeight < NEAR_BOTTOM_PX\n }\n el.addEventListener('scroll', onScroll, { passive: true })\n return () => el.removeEventListener('scroll', onScroll)\n }, [isLoading])\n const onContentLoad = () => {\n if (pinnedToBottom.current) scrollToNewest()\n }\n\n /** Post to the open chat, or to the direct chat with `peer` (created on first send). */\n const post = useCallback(\n async (text: string, files: File[], contextOnly = false, workspace?: string) => {\n const { chat: posted } = await postToChat(\n { chat: chatRef.current, peerExtId: peerId },\n { text, files, contextOnly, ...(workspace ? { workspaceExtId: workspace } : {}) }\n )\n chatRef.current = posted\n },\n [postToChat, peerId]\n )\n\n const contextQueue = useRef<Promise<unknown>>(Promise.resolve())\n\n const handleSend = useCallback(\n async (textToSend: string, files: File[] = []) => {\n if (!textToSend && files.length === 0) return\n setIsSending(true)\n setSendError(null)\n try {\n let workspace: string | undefined\n if (isAgentChat) {\n await contextQueue.current\n if (selectedWorkspaceId) {\n if (!(await prepareAgentWorkspace(selectedWorkspaceId)))\n throw new Error('Could not open the viewed workspace')\n workspace = selectedWorkspaceId\n }\n }\n await post(textToSend, files, false, workspace)\n if (isAgentChat) setAwaitingAgentReply(true)\n onMessageSent?.()\n } catch (err) {\n console.error('[chat] Error sending message:', err)\n setSendError(sendErrorText(err))\n // Rethrow so the composer puts the text back.\n throw err\n } finally {\n setIsSending(false)\n }\n },\n [isAgentChat, selectedWorkspaceId, prepareAgentWorkspace, post, onMessageSent]\n )\n\n // Navigation is context only: the DM master stays in the agent\u2019s Home workspace.\n const lastWorkspace = useRef<{ peer: string; workspace: string } | null>(null)\n useEffect(() => {\n if (!isAgentChat || !peerId || !selectedWorkspaceId || !me) return\n const previous = lastWorkspace.current\n lastWorkspace.current = { peer: peerId, workspace: selectedWorkspaceId }\n if (!previous || previous.peer !== peerId || previous.workspace === selectedWorkspaceId) return\n const workspace = selectedWorkspaceId\n const text = `Now viewing workspace ${workspaceName} (${workspace}).`\n contextQueue.current = contextQueue.current\n .catch(() => undefined)\n .then(async () => {\n if (!(await prepareAgentWorkspace(workspace)))\n throw new Error('Could not open the viewed workspace')\n await post(text, [], true, workspace)\n })\n .catch(() =>\n setSendError(\n 'Could not record the browsing change. Your agent conversation remains in its Home workspace.'\n )\n )\n }, [isAgentChat, peerId, selectedWorkspaceId, workspaceName, me, prepareAgentWorkspace, post])\n\n // The server keeps a deleted message as a tombstone; the cache shows it as one at once.\n const deleteMessage = useCallback(\n async (messageId: string) => {\n const target = chatRef.current\n if (!target || messageId.startsWith('optimistic-')) return\n try {\n await deleteChatMessage(target.external_id, messageId)\n } catch (error) {\n console.error('[chat] Failed to delete message:', error)\n notify('Failed to delete message', 'error')\n }\n },\n [deleteChatMessage, notify]\n )\n\n // An incoming, still-pending workspace access request FROM this peer \u2014 shown as a banner at\n // the top of the thread. Review hands it to the host.\n const { data: allNotifications = [] } = useNotifications()\n const pendingAccessRequest = useMemo(() => {\n if (!peerId || !me || !host.onReviewAccessRequest) return null\n return (\n allNotifications.find(\n (n) =>\n n.type === 'workspace_access_request' &&\n n.sender.external_id === peerId &&\n n.recipient.external_id === me\n ) ?? null\n )\n }, [allNotifications, peerId, me, host.onReviewAccessRequest])\n\n // The files shared between us, each a card in the timeline at its latest event (where its news\n // is), interleaved with the messages. A direct chat with a person only.\n const fileShares = useDmFileShares(isGroup ? null : peer)\n const placement = useMemo(\n () => placeThreadEntries(annotateThread(messages, THREAD_ACCESSORS), fileShares.entries),\n [messages, fileShares.entries]\n )\n const items = placement.items\n // Start at the latest outgoing query: an old reply must not look like a reply to a new query.\n const lastQueryIndex = items.findLastIndex(\n (item) => item.message.sender_ext_id === me && !item.message.context_only\n )\n const lastReplyIndex = items.findLastIndex(\n (item, index) =>\n index > lastQueryIndex &&\n item.message.sender_ext_id !== me &&\n !item.message.context_only &&\n item.message.kind !== 'system'\n )\n const visibleFloatingItems = new Set(\n [lastQueryIndex, lastReplyIndex].filter((index) => index >= 0)\n )\n const memberById = useCallback(\n (id: string | null | undefined) => (id ? membersById.get(id) : undefined),\n [membersById]\n )\n const senderName = useCallback(\n (id: string | null | undefined) => {\n const user = memberById(id)\n return user ? userDisplayName(user) : 'Former member'\n },\n [memberById]\n )\n\n // Someone else's message starts a run (gets their pill) unless the item before it is a typed\n // message from the same person on the same day.\n const startsPeerRun = (i: number) => {\n const previous = items[i - 1]\n return (\n !previous ||\n items[i].isFirstOfDay ||\n previous.message.sender_ext_id !== items[i].message.sender_ext_id\n )\n }\n const renderItem = ({ message: msg, isLastOfRun, isFirstOfDay }: ChatThreadItem, i: number) => {\n const isSent = msg.sender_ext_id === me\n // The server's tombstone of a deleted message (no content to decrypt or show).\n const deleted = !!msg.deleted\n if (msg.context_only) {\n return (\n <DateSeparator key={msg.external_id}>\n {deleted ? 'Workspace note deleted' : msg.content}\n </DateSeparator>\n )\n }\n if (msg.kind === 'system' && !deleted) {\n return <DateSeparator key={msg.external_id}>{msg.content}</DateSeparator>\n }\n // A call, recording or transcript line, for a host that does not draw them itself: one line.\n if (msg.kind !== 'text' && msg.kind !== 'system') {\n // A deleted transcript line is not part of the record (it may be stored again).\n if (deleted && chats.isTranscriptMessage(msg)) return null\n if (!deleted)\n return <DateSeparator key={msg.external_id}>{chats.chatMessagePreview(msg)}</DateSeparator>\n }\n if (isAgentChat && floating && !deleted) {\n const role = isSent ? 'user' : 'assistant'\n return (\n <CompactChatContext.Provider key={msg.external_id} value={floating}>\n <MessageRoot\n role={role}\n messageId={msg.external_id}\n id={msg.external_id}\n data-testid=\"dm-message\"\n className=\"items-start gap-2 px-3 py-2\"\n >\n <span data-testid=\"compact-chat-avatar\" className=\"mt-1.5 shrink-0\">\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')}\n </span>\n <MessageContent\n role={role}\n messageId={msg.external_id}\n align=\"start\"\n className=\"min-w-0 flex-1\"\n >\n <MessageBubble\n role={role}\n messageId={msg.external_id}\n participantTint={isSent ? undefined : 'var(--color-primary)'}\n className=\"max-w-full\"\n >\n <MessageBody messageId={msg.external_id}>\n {floating && isSent && lastReplyIndex > i ? (\n <div className=\"truncate\" title={msg.content ?? ''}>\n {msg.content}\n </div>\n ) : (\n <ConnectedChatMessageBody\n text={msg.content ?? ''}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n </MessageBody>\n </MessageBubble>\n </MessageContent>\n </MessageRoot>\n </CompactChatContext.Provider>\n )\n }\n return (\n <Fragment key={msg.external_id}>\n {!floating && isFirstOfDay && <DateSeparator>{formatDay(msg.created_at)}</DateSeparator>}\n {chat?.kind === 'group' && !isSent && startsPeerRun(i) && (\n <MessageAuthor>\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'author')}\n </MessageAuthor>\n )}\n <ChatBubble\n appearance={floating ? 'floating' : 'standard'}\n compact={floating && isSent && lastReplyIndex > i}\n id={msg.external_id}\n data-testid=\"dm-message\"\n message={msg.content || ''}\n renderMessage={(text) => (\n <ConnectedChatMessageBody\n text={text}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n formatTimestamp={formatTime}\n attachments={\n msg.attachmentFiles?.length || msg.attachmentsError ? (\n <ChatAttachmentList files={msg.attachmentFiles ?? []} error={msg.attachmentsError} />\n ) : undefined\n }\n timestamp={msg.created_at}\n avatar={\n floating\n ? undefined\n : renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')\n }\n senderName={\n memberById(msg.sender_ext_id)\n ? userDisplayName(memberById(msg.sender_ext_id)!)\n : 'Former member'\n }\n isSent={isSent}\n deleted={deleted}\n read={!!chat && !msg.optimistic && chats.readByOthers(chat, me, msg)}\n isLastOfRun={isLastOfRun}\n onDelete={\n floating || deleted || !isSent ? undefined : () => void deleteMessage(msg.external_id)\n }\n />\n </Fragment>\n )\n }\n\n const renderEntries = (placed: readonly PlacedThreadEntry<DmFileShareEntry>[] = []) =>\n placed.map(({ entry, isFirstOfDay }) => (\n <Fragment key={entry.shareId}>\n {isFirstOfDay && entry.at && <DateSeparator>{formatDay(entry.at)}</DateSeparator>}\n <DmFileShareCard\n entry={entry}\n share={fileShares.shareById.get(entry.shareId)}\n loaded={fileShares.loaded}\n failed={fileShares.failed}\n time={entry.at ? formatTime(entry.at) : undefined}\n />\n </Fragment>\n ))\n const renderEntriesBefore = (index: number) => renderEntries(placement.before.get(index))\n const entriesAfter = renderEntries(placement.after)\n\n const loadOlderButton = hasMore ? (\n <button\n type=\"button\"\n onClick={() => void loadOlder()}\n disabled={loadingOlder}\n className=\"mx-auto my-2 block rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-60\"\n >\n {loadingOlder ? 'Loading\u2026' : 'Load earlier messages'}\n </button>\n ) : null\n\n const historyProps: ChatHistoryProps = {\n chat,\n messages,\n items,\n renderItem,\n renderEntriesBefore,\n entriesAfter,\n loadOlder: loadOlderButton,\n memberById,\n senderName,\n myExtId: me,\n formatTime,\n formatDay,\n }\n const History = floating ? undefined : host.ThreadHistory\n\n return (\n <DmThreadFrame\n floating={floating}\n accessBanner={\n pendingAccessRequest ? (\n <DmAccessRequestBanner\n compact={floating}\n name={peer?.given_name ?? 'They'}\n onReview={() => host.onReviewAccessRequest?.(pendingAccessRequest)}\n />\n ) : undefined\n }\n hasRecipient={!!chat || !!peerId}\n historyRef={historyRef}\n isLoading={isLoading}\n // A call's chat is never the generic empty state: its history says what the call is doing.\n isEmpty={\n messages.length === 0 && fileShares.entries.length === 0 && !(History && chat?.call_ext_id)\n }\n history={\n <div onLoadCapture={onContentLoad} className={floating ? 'space-y-0' : undefined}>\n {History ? (\n <History {...historyProps} />\n ) : (\n <>\n {!floating && loadOlderButton}\n {items.map(\n (item, i) =>\n (!floating || visibleFloatingItems.has(i)) && (\n <Fragment key={item.message.external_id}>\n {!floating && renderEntriesBefore(i)}\n {renderItem(item, i)}\n </Fragment>\n )\n )}\n {!floating && entriesAfter}\n </>\n )}\n {agentWorking && (\n <DmAgentProgress\n compact={floating}\n status={agentDmStatus}\n startedAt={Date.parse(\n [...messages].reverse().find((message) => message.sender_ext_id === me)\n ?.created_at ?? ''\n )}\n onOpenThread={host.openAgentThread}\n />\n )}\n {!agentWorking && agentDmStatus?.status === 'failed' && (\n <p role=\"status\" className=\"px-3 text-sm text-muted-foreground\">\n The agent couldn\u2019t finish this message. Please try again.\n </p>\n )}\n </div>\n }\n composer={\n <div className={floating ? 'pointer-events-auto' : undefined}>\n {isAgentChat && !floating && (\n <p className=\"px-3 pb-1 text-xs text-muted-foreground\">\n Conversation: {peer?.given_name || 'Assistant'} Home\n {workspaceName ? ` \u00B7 Viewing: ${workspaceName}` : ''}\n </p>\n )}\n <DmComposer\n draftRef={composerDraft}\n appearance={floating ? 'floating' : 'standard'}\n actions={\n floating ? (\n <>\n {isAgentChat && peerId && <OwnedAgentCallButton agentId={peerId} />}\n {floatingControls}\n </>\n ) : undefined\n }\n placeholder={floating ? `Ask ${peer?.given_name || 'Assistant'}\u2026` : 'Type a message\u2026'}\n /* Agents read the text of a message only, so files are offered to people. */\n allowAttachments={!isAgentChat && !floating}\n disabled={!chat && !peerId}\n busy={isSending}\n onSend={handleSend}\n error={sendError}\n />\n </div>\n }\n />\n )\n}\n"],
|
|
5
|
-
"mappings": ";AA+WQ,SAiLI,UAjLJ,KAmBE,YAnBF;AA/WR,SAAS,iCAAiC;AAW1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,YAAAA,WAAU,aAAa,YAAY,WAAW,SAAS,QAAQ,gBAAgB;AACxF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,uBAAuB,qBAAqB;AACrD,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAChC,SAAS,0BAAkD;AAC3D,SAAS,2BAA2B;AAapC,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AAa,WAAW,OAAO,MAAM,cAAc,WAAW,WAAM;AAAA,YAEpE,kBAAkB,CAAC,eAAe,CAAC;AAAA,YACnC,UAAU,CAAC,QAAQ,CAAC;AAAA,YACpB,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,OAAO;AAAA;AAAA,QACT;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;",
|
|
4
|
+
"sourcesContent": ["import { FloatingAssistantIdentity } from '../../shell/floating-assistant-context'\n/**\n * One open chat thread \u2014 direct (a person, a self-chat, or my personal agent), group or meeting.\n *\n * Container-agnostic: a messenger frames it. Every message is end-to-end encrypted under the chat\n * key (`arbi.chats`); files are encrypted with their own keys and travel in a manifest under the\n * same chat key. A chat has no assistant \u2014 the one exception is the direct chat with my own agent\n * (the PA chat), which runs in the agent\u2019s Home workspace and records browsing changes as\n * context-only notes. A host draws more kinds of message (a call's) with `host.ThreadHistory`.\n */\n\nimport {\n useFloatingConversation,\n FloatingConversationControls,\n ConversationDrafts,\n} from '../panels/ConversationPresentation'\nimport { DmAgentProgress } from './DmAgentProgress'\nimport { OwnedAgentCallButton } from '../../calls/connected/OwnedAgentCallButton'\nimport { Fragment, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n ChatBubble,\n DateSeparator,\n DmComposer,\n annotateThread,\n myChatId,\n setOpenChat,\n useAgentDmStatus,\n useArbi,\n useArbiSessionState,\n useChatPost,\n useChatThread,\n useDeleteChatMessage,\n useMarkChatRead,\n useDmFileShares,\n useNotifications,\n userDisplayName,\n useWorkspaces,\n type ChatResponse,\n type ChatThreadMessage,\n type DmFileShareEntry,\n type DmUser,\n} from '@arbidocs/react'\nimport { formatFriendlyDate } from '@arbidocs/react/ui'\nimport {\n MessageAuthor,\n MessageRoot,\n MessageContent,\n MessageBubble,\n MessageBody,\n} from '../../chat/Message'\nimport { CompactChatContext } from '../../chat/CompactChatContext'\nimport { chats } from '@arbidocs/sdk/browser'\nimport { DmAccessRequestBanner, DmThreadFrame } from '../../collaboration/direct-messages/DmParts'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { ChatAttachmentList } from './ChatAttachments'\nimport { ConnectedChatMessageBody } from './ConnectedChatMessageBody'\nimport { DmFileShareCard } from './DmFileShareCard'\nimport { placeThreadEntries, type PlacedThreadEntry } from './thread-entries'\nimport { renderMessengerUser } from './messengerUser'\nimport type { ChatHistoryProps, ChatThreadItem, MessengerHost } from './types'\n\nexport interface ConnectedChatThreadProps {\n /** The chat to show; null for a peer never messaged (the direct chat is created on send). */\n chat: ChatResponse | null\n /** The other party of a direct chat (myself for a self-chat); unset for a group. */\n peer?: DmUser | null\n host?: MessengerHost\n /** Called after a message is sent. */\n onMessageSent?: () => void\n}\n\nconst THREAD_ACCESSORS = {\n senderId: (m: ChatThreadMessage) => m.sender_ext_id ?? '',\n createdAt: (m: ChatThreadMessage) => m.created_at,\n}\n\n/** Don't hand the user `TypeError: Failed to fetch`; our own messages pass through. */\nfunction sendErrorText(err: unknown): string {\n const raw = err instanceof Error ? err.message : ''\n const isNetworkError =\n !raw || /failed to fetch|networkerror|load failed|network request failed/i.test(raw)\n return isNetworkError ? 'Couldn\u2019t send \u2014 check your connection and try again.' : raw\n}\n\n/** Day separators: \"Today\", \"Yesterday\", \"Mar 3\". */\nfunction defaultFormatDay(iso: string): string {\n const raw = formatFriendlyDate(iso, false)\n return raw.charAt(0).toUpperCase() + raw.slice(1)\n}\n\n/** A thread is pinned to its newest message unless the reader scrolled up. */\nconst NEAR_BOTTOM_PX = 80\n\nexport function ConnectedChatThread({\n chat,\n peer,\n host = {},\n onMessageSent,\n}: ConnectedChatThreadProps) {\n const floating = useFloatingConversation()\n const setAssistantIdentity = useContext(FloatingAssistantIdentity)\n const floatingControls = useContext(FloatingConversationControls)\n const arbi = useArbi()\n const { notify } = useBlocksEnvironment()\n const me = myChatId(arbi)\n const drafts = useContext(ConversationDrafts)\n if (drafts && drafts.owner !== me) {\n drafts.entries.clear()\n drafts.owner = me\n }\n const draftKey = peer?.external_id ?? chat?.external_id ?? 'new'\n if (drafts && !drafts.entries.has(draftKey)) drafts.entries.set(draftKey, { current: null })\n const composerDraft = drafts?.entries.get(draftKey)\n\n const selectedWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const { data: workspaces = [] } = useWorkspaces()\n const workspaceName =\n workspaces.find((workspace) => workspace.external_id === selectedWorkspaceId)?.name ??\n selectedWorkspaceId\n const formatTime = host.formatTime ?? formatFriendlyDate\n const formatDay = host.formatDay ?? defaultFormatDay\n // Personal Assistant chat: the workspace my agent acts in must be usable on this session (its\n // key deposited), without switching to it.\n const prepareAgentWorkspace = useCallback(\n (workspaceId: string) =>\n arbi.workspaces.open(workspaceId).then(\n () => true,\n () => false\n ),\n [arbi]\n )\n\n const isGroup = !!chat && chat.kind !== 'direct'\n const peerId = isGroup ? null : (peer?.external_id ?? null)\n const isAgentChat = !!peerId?.startsWith('agt-')\n\n const { messages, hasMore, isLoading, loadOlder, loadingOlder } = useChatThread(chat)\n const postToChat = useChatPost()\n const deleteChatMessage = useDeleteChatMessage()\n const markRead = useMarkChatRead()\n const [isSending, setIsSending] = useState(false)\n const [sendError, setSendError] = useState<string | null>(null)\n const [awaitingAgentReply, setAwaitingAgentReply] = useState(false)\n const historyRef = useRef<HTMLDivElement>(null)\n\n // A chat created on first send is held here until the caller passes it in.\n const chatRef = useRef<ChatResponse | null>(chat)\n chatRef.current = chat ?? chatRef.current\n\n const membersById = useMemo(() => {\n const map = new Map<string, DmUser>()\n for (const m of chat?.members ?? []) map.set(m.user.external_id, m.user)\n if (peer) map.set(peer.external_id, peer)\n return map\n }, [chat, peer])\n\n // While open: new messages in this chat don't count as unread, and the watermark follows.\n useEffect(() => {\n if (!chat) return\n setOpenChat(chat.external_id)\n return () => setOpenChat(null)\n }, [chat?.external_id]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const newest = messages[messages.length - 1]\n const myReadAt = chat?.members.find((m) => m.user.external_id === me)?.last_read_at\n useEffect(() => {\n if (!chat || !newest || newest.optimistic) return\n const unread =\n chat.unread_count > 0 ||\n (newest.sender_ext_id !== me &&\n (!myReadAt || Date.parse(myReadAt) < Date.parse(newest.created_at)))\n if (!unread) return\n void markRead(chat, newest.external_id)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [chat?.external_id, chat?.unread_count, newest?.external_id])\n\n // Personal agent progress, keyed by the agent.\n const agentDmStatus = useAgentDmStatus(isAgentChat ? peerId : null)\n useEffect(() => {\n if (agentDmStatus?.status === 'done' || agentDmStatus?.status === 'failed') {\n setAwaitingAgentReply(false)\n }\n }, [agentDmStatus])\n useEffect(() => {\n if (awaitingAgentReply && newest && newest.sender_ext_id === peerId) {\n setAwaitingAgentReply(false)\n }\n }, [newest, awaitingAgentReply, peerId])\n const agentWorking =\n awaitingAgentReply || agentDmStatus?.status === 'working' || agentDmStatus?.status === 'queued'\n useEffect(() => {\n setAssistantIdentity?.(peer?.given_name || 'Assistant', agentWorking)\n }, [setAssistantIdentity, peer?.given_name, agentWorking])\n\n // Keep the newest message in view \u2014 also once an image above it has decrypted and grown the\n // thread \u2014 unless the reader has scrolled up.\n const pinnedToBottom = useRef(true)\n const viewport = () =>\n historyRef.current?.querySelector<HTMLElement>('[data-radix-scroll-area-viewport]') ?? null\n const scrollToNewest = useCallback(() => {\n const el = viewport()\n if (el) el.scrollTop = el.scrollHeight\n }, [])\n useEffect(() => {\n pinnedToBottom.current = true\n requestAnimationFrame(scrollToNewest)\n }, [newest?.external_id, scrollToNewest])\n useEffect(() => {\n const el = viewport()\n if (!el) return\n const onScroll = () => {\n pinnedToBottom.current = el.scrollHeight - el.scrollTop - el.clientHeight < NEAR_BOTTOM_PX\n }\n el.addEventListener('scroll', onScroll, { passive: true })\n return () => el.removeEventListener('scroll', onScroll)\n }, [isLoading])\n const onContentLoad = () => {\n if (pinnedToBottom.current) scrollToNewest()\n }\n\n /** Post to the open chat, or to the direct chat with `peer` (created on first send). */\n const post = useCallback(\n async (text: string, files: File[], contextOnly = false, workspace?: string) => {\n const { chat: posted } = await postToChat(\n { chat: chatRef.current, peerExtId: peerId },\n { text, files, contextOnly, ...(workspace ? { workspaceExtId: workspace } : {}) }\n )\n chatRef.current = posted\n },\n [postToChat, peerId]\n )\n\n const contextQueue = useRef<Promise<unknown>>(Promise.resolve())\n\n const handleSend = useCallback(\n async (textToSend: string, files: File[] = []) => {\n if (!textToSend && files.length === 0) return\n setIsSending(true)\n setSendError(null)\n try {\n let workspace: string | undefined\n if (isAgentChat) {\n await contextQueue.current\n if (selectedWorkspaceId) {\n if (!(await prepareAgentWorkspace(selectedWorkspaceId)))\n throw new Error('Could not open the viewed workspace')\n workspace = selectedWorkspaceId\n }\n }\n await post(textToSend, files, false, workspace)\n if (isAgentChat) setAwaitingAgentReply(true)\n onMessageSent?.()\n } catch (err) {\n console.error('[chat] Error sending message:', err)\n setSendError(sendErrorText(err))\n // Rethrow so the composer puts the text back.\n throw err\n } finally {\n setIsSending(false)\n }\n },\n [isAgentChat, selectedWorkspaceId, prepareAgentWorkspace, post, onMessageSent]\n )\n\n // Navigation is context only: the DM master stays in the agent\u2019s Home workspace.\n const lastWorkspace = useRef<{ peer: string; workspace: string } | null>(null)\n useEffect(() => {\n if (!isAgentChat || !peerId || !selectedWorkspaceId || !me) return\n const previous = lastWorkspace.current\n lastWorkspace.current = { peer: peerId, workspace: selectedWorkspaceId }\n if (!previous || previous.peer !== peerId || previous.workspace === selectedWorkspaceId) return\n const workspace = selectedWorkspaceId\n const text = `Now viewing workspace ${workspaceName} (${workspace}).`\n contextQueue.current = contextQueue.current\n .catch(() => undefined)\n .then(async () => {\n if (!(await prepareAgentWorkspace(workspace)))\n throw new Error('Could not open the viewed workspace')\n await post(text, [], true, workspace)\n })\n .catch(() =>\n setSendError(\n 'Could not record the browsing change. Your agent conversation remains in its Home workspace.'\n )\n )\n }, [isAgentChat, peerId, selectedWorkspaceId, workspaceName, me, prepareAgentWorkspace, post])\n\n // The server keeps a deleted message as a tombstone; the cache shows it as one at once.\n const deleteMessage = useCallback(\n async (messageId: string) => {\n const target = chatRef.current\n if (!target || messageId.startsWith('optimistic-')) return\n try {\n await deleteChatMessage(target.external_id, messageId)\n } catch (error) {\n console.error('[chat] Failed to delete message:', error)\n notify('Failed to delete message', 'error')\n }\n },\n [deleteChatMessage, notify]\n )\n\n // An incoming, still-pending workspace access request FROM this peer \u2014 shown as a banner at\n // the top of the thread. Review hands it to the host.\n const { data: allNotifications = [] } = useNotifications()\n const pendingAccessRequest = useMemo(() => {\n if (!peerId || !me || !host.onReviewAccessRequest) return null\n return (\n allNotifications.find(\n (n) =>\n n.type === 'workspace_access_request' &&\n n.sender.external_id === peerId &&\n n.recipient.external_id === me\n ) ?? null\n )\n }, [allNotifications, peerId, me, host.onReviewAccessRequest])\n\n // The files shared between us, each a card in the timeline at its latest event (where its news\n // is), interleaved with the messages. A direct chat with a person only.\n const fileShares = useDmFileShares(isGroup ? null : peer)\n const placement = useMemo(\n () => placeThreadEntries(annotateThread(messages, THREAD_ACCESSORS), fileShares.entries),\n [messages, fileShares.entries]\n )\n const items = placement.items\n // Start at the latest outgoing query: an old reply must not look like a reply to a new query.\n const lastQueryIndex = items.findLastIndex(\n (item) => item.message.sender_ext_id === me && !item.message.context_only\n )\n const lastReplyIndex = items.findLastIndex(\n (item, index) =>\n index > lastQueryIndex &&\n item.message.sender_ext_id !== me &&\n !item.message.context_only &&\n item.message.kind !== 'system'\n )\n const visibleFloatingItems = new Set(\n [lastQueryIndex, lastReplyIndex].filter((index) => index >= 0)\n )\n const memberById = useCallback(\n (id: string | null | undefined) => (id ? membersById.get(id) : undefined),\n [membersById]\n )\n const senderName = useCallback(\n (id: string | null | undefined) => {\n const user = memberById(id)\n return user ? userDisplayName(user) : 'Former member'\n },\n [memberById]\n )\n\n // Someone else's message starts a run (gets their pill) unless the item before it is a typed\n // message from the same person on the same day.\n const startsPeerRun = (i: number) => {\n const previous = items[i - 1]\n return (\n !previous ||\n items[i].isFirstOfDay ||\n previous.message.sender_ext_id !== items[i].message.sender_ext_id\n )\n }\n const renderItem = ({ message: msg, isLastOfRun, isFirstOfDay }: ChatThreadItem, i: number) => {\n const isSent = msg.sender_ext_id === me\n // The server's tombstone of a deleted message (no content to decrypt or show).\n const deleted = !!msg.deleted\n if (msg.context_only) {\n return (\n <DateSeparator key={msg.external_id}>\n {deleted ? 'Workspace note deleted' : msg.content}\n </DateSeparator>\n )\n }\n if (msg.kind === 'system' && !deleted) {\n return <DateSeparator key={msg.external_id}>{msg.content}</DateSeparator>\n }\n // A call, recording or transcript line, for a host that does not draw them itself: one line.\n if (msg.kind !== 'text' && msg.kind !== 'system') {\n // A deleted transcript line is not part of the record (it may be stored again).\n if (deleted && chats.isTranscriptMessage(msg)) return null\n if (!deleted)\n return <DateSeparator key={msg.external_id}>{chats.chatMessagePreview(msg)}</DateSeparator>\n }\n if (isAgentChat && floating && !deleted) {\n const role = isSent ? 'user' : 'assistant'\n return (\n <CompactChatContext.Provider key={msg.external_id} value={floating}>\n <MessageRoot\n role={role}\n messageId={msg.external_id}\n id={msg.external_id}\n data-testid=\"dm-message\"\n className=\"items-start gap-2 px-3 py-2\"\n >\n <span data-testid=\"compact-chat-avatar\" className=\"mt-1.5 shrink-0\">\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')}\n </span>\n <MessageContent\n role={role}\n messageId={msg.external_id}\n align=\"start\"\n className=\"min-w-0 flex-1\"\n >\n <MessageBubble\n role={role}\n messageId={msg.external_id}\n participantTint={isSent ? undefined : 'var(--color-primary)'}\n className=\"max-w-full\"\n >\n <MessageBody messageId={msg.external_id}>\n {floating && isSent && lastReplyIndex > i ? (\n <div className=\"truncate\" title={msg.content ?? ''}>\n {msg.content}\n </div>\n ) : (\n <ConnectedChatMessageBody\n text={msg.content ?? ''}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n </MessageBody>\n </MessageBubble>\n </MessageContent>\n </MessageRoot>\n </CompactChatContext.Provider>\n )\n }\n return (\n <Fragment key={msg.external_id}>\n {!floating && isFirstOfDay && <DateSeparator>{formatDay(msg.created_at)}</DateSeparator>}\n {chat?.kind === 'group' && !isSent && startsPeerRun(i) && (\n <MessageAuthor>\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'author')}\n </MessageAuthor>\n )}\n <ChatBubble\n appearance={floating ? 'floating' : 'standard'}\n compact={floating && isSent && lastReplyIndex > i}\n id={msg.external_id}\n data-testid=\"dm-message\"\n message={msg.content || ''}\n renderMessage={(text) => (\n <ConnectedChatMessageBody\n text={text}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n formatTimestamp={formatTime}\n attachments={\n msg.attachmentFiles?.length || msg.attachmentsError ? (\n <ChatAttachmentList files={msg.attachmentFiles ?? []} error={msg.attachmentsError} />\n ) : undefined\n }\n timestamp={msg.created_at}\n avatar={\n floating\n ? undefined\n : renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')\n }\n senderName={\n memberById(msg.sender_ext_id)\n ? userDisplayName(memberById(msg.sender_ext_id)!)\n : 'Former member'\n }\n isSent={isSent}\n deleted={deleted}\n read={!!chat && !msg.optimistic && chats.readByOthers(chat, me, msg)}\n isLastOfRun={isLastOfRun}\n onDelete={\n floating || deleted || !isSent ? undefined : () => void deleteMessage(msg.external_id)\n }\n />\n </Fragment>\n )\n }\n\n const renderEntries = (placed: readonly PlacedThreadEntry<DmFileShareEntry>[] = []) =>\n placed.map(({ entry, isFirstOfDay }) => (\n <Fragment key={entry.shareId}>\n {isFirstOfDay && entry.at && <DateSeparator>{formatDay(entry.at)}</DateSeparator>}\n <DmFileShareCard\n entry={entry}\n share={fileShares.shareById.get(entry.shareId)}\n loaded={fileShares.loaded}\n failed={fileShares.failed}\n time={entry.at ? formatTime(entry.at) : undefined}\n />\n </Fragment>\n ))\n const renderEntriesBefore = (index: number) => renderEntries(placement.before.get(index))\n const entriesAfter = renderEntries(placement.after)\n\n const loadOlderButton = hasMore ? (\n <button\n type=\"button\"\n onClick={() => void loadOlder()}\n disabled={loadingOlder}\n className=\"mx-auto my-2 block rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-60\"\n >\n {loadingOlder ? 'Loading\u2026' : 'Load earlier messages'}\n </button>\n ) : null\n\n const historyProps: ChatHistoryProps = {\n chat,\n messages,\n items,\n renderItem,\n renderEntriesBefore,\n entriesAfter,\n loadOlder: loadOlderButton,\n memberById,\n senderName,\n myExtId: me,\n formatTime,\n formatDay,\n }\n const History = floating ? undefined : host.ThreadHistory\n\n return (\n <DmThreadFrame\n floating={floating}\n accessBanner={\n pendingAccessRequest ? (\n <DmAccessRequestBanner\n compact={floating}\n name={peer?.given_name ?? 'They'}\n onReview={() => host.onReviewAccessRequest?.(pendingAccessRequest)}\n />\n ) : undefined\n }\n hasRecipient={!!chat || !!peerId}\n historyRef={historyRef}\n isLoading={isLoading}\n // A call's chat is never the generic empty state: its history says what the call is doing.\n isEmpty={\n messages.length === 0 && fileShares.entries.length === 0 && !(History && chat?.call_ext_id)\n }\n history={\n <div onLoadCapture={onContentLoad} className={floating ? 'space-y-0' : undefined}>\n {History ? (\n <History {...historyProps} />\n ) : (\n <>\n {!floating && loadOlderButton}\n {items.map(\n (item, i) =>\n (!floating || visibleFloatingItems.has(i)) && (\n <Fragment key={item.message.external_id}>\n {!floating && renderEntriesBefore(i)}\n {renderItem(item, i)}\n </Fragment>\n )\n )}\n {!floating && entriesAfter}\n </>\n )}\n {agentWorking && (\n <DmAgentProgress\n compact={floating}\n status={agentDmStatus}\n startedAt={Date.parse(\n [...messages].reverse().find((message) => message.sender_ext_id === me)\n ?.created_at ?? ''\n )}\n onOpenThread={host.openAgentThread}\n />\n )}\n {!agentWorking && agentDmStatus?.status === 'failed' && (\n <p role=\"status\" className=\"px-3 text-sm text-muted-foreground\">\n The agent couldn\u2019t finish this message. Please try again.\n </p>\n )}\n </div>\n }\n composer={\n <div className={floating ? 'pointer-events-auto' : undefined}>\n {isAgentChat && !floating && (\n <p className=\"px-3 pb-1 text-xs text-muted-foreground\">\n Conversation: {peer?.given_name || 'Assistant'} Home\n {workspaceName ? ` \u00B7 Viewing: ${workspaceName}` : ''}\n </p>\n )}\n <DmComposer\n draftRef={composerDraft}\n appearance={floating ? 'floating' : 'standard'}\n actions={\n floating ? (\n <>\n {isAgentChat && peerId && (\n <OwnedAgentCallButton agentId={peerId} workspaceExtId={selectedWorkspaceId} />\n )}\n {floatingControls}\n </>\n ) : undefined\n }\n placeholder={floating ? `Ask ${peer?.given_name || 'Assistant'}\u2026` : 'Type a message\u2026'}\n /* Agents read the text of a message only, so files are offered to people. */\n allowAttachments={!isAgentChat && !floating}\n disabled={!chat && !peerId}\n busy={isSending}\n onSend={handleSend}\n error={sendError}\n />\n </div>\n }\n />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA+WQ,SAiLI,UAjLJ,KAmBE,YAnBF;AA/WR,SAAS,iCAAiC;AAW1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,YAAAA,WAAU,aAAa,YAAY,WAAW,SAAS,QAAQ,gBAAgB;AACxF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,uBAAuB,qBAAqB;AACrD,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAChC,SAAS,0BAAkD;AAC3D,SAAS,2BAA2B;AAapC,MAAM,mBAAm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EN,aAAa,WAAW,OAAO,MAAM,cAAc,WAAW,WAAM;AAAA,YAEpE,kBAAkB,CAAC,eAAe,CAAC;AAAA,YACnC,UAAU,CAAC,QAAQ,CAAC;AAAA,YACpB,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,OAAO;AAAA;AAAA,QACT;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;",
|
|
6
6
|
"names": ["Fragment"]
|
|
7
7
|
}
|
|
@@ -5,9 +5,7 @@ import { Table2 } from "lucide-react";
|
|
|
5
5
|
import { useTableViewRows } from "@arbidocs/react";
|
|
6
6
|
import { Card, cn } from "@arbidocs/react/ui";
|
|
7
7
|
import { DatabaseTable } from "../../databases/DatabaseTable.js";
|
|
8
|
-
import {
|
|
9
|
-
DATABASE_COLUMN_TYPES
|
|
10
|
-
} from "../../databases/column-types.js";
|
|
8
|
+
import { kitTypeOf } from "../databases/wireColumns.js";
|
|
11
9
|
const DEFAULT_TABLE_VIEW_BLOCK_LABELS = {
|
|
12
10
|
loading: "Loading\u2026",
|
|
13
11
|
unavailable: "This table view is not available to you.",
|
|
@@ -19,11 +17,9 @@ const toRowView = (r) => ({
|
|
|
19
17
|
titles: { ...r.titles ?? {} },
|
|
20
18
|
shared: r.shared ?? true
|
|
21
19
|
});
|
|
22
|
-
const GRID_TYPES = new Set(DATABASE_COLUMN_TYPES);
|
|
23
|
-
const isGridType = (type) => GRID_TYPES.has(type);
|
|
24
20
|
const toColumnView = (c) => ({
|
|
25
21
|
...c,
|
|
26
|
-
type:
|
|
22
|
+
type: kitTypeOf(c.type) ?? "text"
|
|
27
23
|
});
|
|
28
24
|
function TableViewBlock({
|
|
29
25
|
viewId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/pages/TableViewBlock.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * `TableViewBlock`: a page's table block. It shows one saved table view of a database: the view,\n * its database's columns and its rows read in one request with the view applied on the server\n * (`useTableViewRows`: its filters, sort and columns), through the database grid (`DatabaseTable`)\n * in read mode. Only what the viewer can read: a view they cannot see (someone else's private one,\n * or deleted), or whose database they cannot, says so instead.\n */\nimport { useMemo, type ReactNode } from 'react'\nimport { Table2 } from 'lucide-react'\nimport { useTableViewRows, type DatabaseColumn, type DatabaseRow } from '@arbidocs/react'\nimport { Card, cn } from '@arbidocs/react/ui'\nimport { DatabaseTable } from '../../databases/DatabaseTable'\nimport
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * `TableViewBlock`: a page's table block. It shows one saved table view of a database: the view,\n * its database's columns and its rows read in one request with the view applied on the server\n * (`useTableViewRows`: its filters, sort and columns), through the database grid (`DatabaseTable`)\n * in read mode. Only what the viewer can read: a view they cannot see (someone else's private one,\n * or deleted), or whose database they cannot, says so instead.\n */\nimport { useMemo, type ReactNode } from 'react'\nimport { Table2 } from 'lucide-react'\nimport { useTableViewRows, type DatabaseColumn, type DatabaseRow } from '@arbidocs/react'\nimport { Card, cn } from '@arbidocs/react/ui'\nimport { DatabaseTable } from '../../databases/DatabaseTable'\nimport type { DatabaseColumnView, DatabaseRowView } from '../../databases/column-types'\nimport { kitTypeOf } from '../databases/wireColumns'\n\nexport interface TableViewBlockLabels {\n loading: string\n /** The view is not one the viewer can see (private to someone else, or deleted). */\n unavailable: string\n /** A view of the document table (pages show database views). */\n notADatabase: string\n}\n\nexport const DEFAULT_TABLE_VIEW_BLOCK_LABELS: TableViewBlockLabels = {\n loading: 'Loading\u2026',\n unavailable: 'This table view is not available to you.',\n notADatabase: 'This view is of the documents table, which a page does not show.',\n}\n\nexport interface TableViewBlockProps {\n viewId: string\n /** Buttons in the block's corner (a page being edited). */\n actions?: ReactNode\n labels?: Partial<TableViewBlockLabels>\n className?: string\n testId?: string\n}\n\nconst toRowView = (r: DatabaseRow): DatabaseRowView => ({\n id: r.id,\n values: { ...r.values },\n titles: { ...(r.titles ?? {}) },\n shared: r.shared ?? true,\n})\n\n/** A column as the grid reads it: a tag column is a label column; a type the grid does not draw reads as text. */\nconst toColumnView = (c: DatabaseColumn): DatabaseColumnView => ({\n ...c,\n type: kitTypeOf(c.type) ?? 'text',\n})\n\nexport function TableViewBlock({\n viewId,\n actions,\n labels,\n className,\n testId,\n}: TableViewBlockProps) {\n const l = { ...DEFAULT_TABLE_VIEW_BLOCK_LABELS, ...labels }\n const read = useTableViewRows(viewId || null)\n const data = read.data\n const columns = useMemo(() => (data?.columns ?? []).map(toColumnView), [data])\n const rows = useMemo(() => (data?.rows ?? []).map(toRowView), [data])\n\n let body: ReactNode\n if (read.isError) {\n body = <p className=\"p-4 text-sm text-muted-foreground\">{l.unavailable}</p>\n } else if (data && !data.database) {\n body = <p className=\"p-4 text-sm text-muted-foreground\">{l.notADatabase}</p>\n } else if (!data) {\n body = <p className=\"p-4 text-sm text-muted-foreground\">{l.loading}</p>\n } else {\n body = (\n <DatabaseTable\n columns={columns}\n rows={rows}\n readOnly\n isFiltered\n gridId={`page-view-${viewId}`}\n height=\"100%\"\n testId={testId && `${testId}-table`}\n />\n )\n }\n\n return (\n <Card\n variant=\"elevated\"\n className={cn('flex h-full min-h-[12rem] flex-col overflow-hidden rounded-xl p-0', className)}\n data-testid={testId}\n >\n <div className=\"flex items-center gap-2 border-b border-border px-4 py-2\">\n <Table2 className=\"size-4 text-muted-foreground\" />\n <span className=\"truncate text-sm font-medium\" data-testid={testId && `${testId}-name`}>\n {data?.view.spec.name ?? ''}\n </span>\n {actions && <div className=\"ml-auto flex gap-1\">{actions}</div>}\n </div>\n <div className=\"min-h-0 flex-1\">{body}</div>\n </Card>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAkEW,cAyBL,YAzBK;AA3DX,SAAS,eAA+B;AACxC,SAAS,cAAc;AACvB,SAAS,wBAA+D;AACxE,SAAS,MAAM,UAAU;AACzB,SAAS,qBAAqB;AAE9B,SAAS,iBAAiB;AAUnB,MAAM,kCAAwD;AAAA,EACnE,SAAS;AA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AAAA,MACC,SAAQ;AAAA,MACR,WAAW,GAAG,qEAAqE,SAAS;AAAA,MAC5F,eAAa;AAAA,MAEb;AAAA,6BAAC,SAAI,WAAU,4DACb;AAAA,8BAAC,UAAO,WAAU,gCAA+B;AAAA,UACjD,oBAAC,UAAK,WAAU,gCAA+B,eAAa,UAAU,GAAG,MAAM,SAC5E,gBAAM,KAAK,KAAK,QAAQ,IAC3B;AAAA,UACC,WAAW,oBAAC,SAAI,WAAU,sBAAsB,mBAAQ;AAAA,WAC3D;AAAA,QACA,oBAAC,SAAI,WAAU,kBAAkB,gBAAK;AAAA;AAAA;AAAA,EACxC;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -129,7 +129,7 @@ const DEFAULT_FEATURE_ROWS = [
|
|
|
129
129
|
testId: "toggle-call-avatars",
|
|
130
130
|
title: "Assistant avatars (experimental)",
|
|
131
131
|
icon: /* @__PURE__ */ jsx(Phone, { size: ICON }),
|
|
132
|
-
description: "
|
|
132
|
+
description: "Enable before joining a call to see your assistant\u2019s 3D projection. Turning animation off keeps speech playing; enabling it during an audio-only call applies to your next call."
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
feature: "connectors",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/settings-page/featuresSection.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * Features, as a settings section a site adds as data (`ConnectedSettingsPage sections`): a switch\n * per feature the site lists, each read and written through the host's `features` (`useFeature`),\n * so a switch kept in the user's settings and one kept on this device look the same here.\n *\n * The rows are, by default, every feature the host lists (`features`) with its words; a site may\n * give its own. A row's\n * sub-switches show while it is on, and the `more` rows sit behind a disclosure. The `calls` row follows the server's calls config:\n * it is off and locked where the server has no calls, on and locked where calls are not\n * experimental there.\n */\nimport { useState, type ReactNode } from 'react'\nimport {\n Bot,\n CalendarDays,\n ChevronDown,\n ChartColumn,\n ChevronRight,\n Code2,\n Mail,\n Network,\n Phone,\n PlugZap,\n Search,\n Sparkles,\n Table2,\n Upload,\n Workflow,\n} from 'lucide-react'\nimport {\n useArbiHost,\n useCallsConfig,\n useFeatureSwitch,\n type ArbiFeature,\n type ArbiFeatures,\n} from '@arbidocs/react'\nimport { ArbiBotHeadIcon } from '@arbidocs/react/ui'\nimport type { SettingsPageSection } from '../../settings/SettingsPage'\nimport { SettingsCard, SettingsPanel, SettingsSection } from '../../settings/SettingsPanel'\nimport { SettingsSwitchGroup, SettingsSwitchRow } from '../../settings/SettingsSwitchRow'\nimport { callsSwitchState } from '../../settings/calls-switch'\n\n/** One feature's switch. */\nexport interface FeatureSettingRow {\n feature: ArbiFeature\n title: ReactNode\n /** The help text (the `calls` row says what the server allows instead). */\n description?: ReactNode\n icon?: ReactNode\n /** The switch's id. Default: the feature. */\n id?: string\n /** Default: `toggle-<feature>`. */\n testId?: string\n /** Switches that belong to this one, shown indented while it is on. */\n rows?: readonly FeatureSettingRow[]\n}\n\nexport interface FeaturesSettingsSectionOptions {\n /** The rows, in order. Default: every feature ({@link DEFAULT_FEATURE_ROWS}). */\n rows?: readonly FeatureSettingRow[]\n /**\n * Rows behind a disclosure, closed at first (switches a regular user need not meet). Default,\n * with the default rows: {@link DEFAULT_FEATURE_MORE}; `null`: none.\n */\n more?: { label: ReactNode; rows: readonly FeatureSettingRow[] } | null\n /** The section's id. Default: `experimental`. */\n id?: string\n /** The tab's and the heading's name. Default: \"Experimental\". */\n label?: string\n /** The tab's icon. Default: a code glyph. */\n icon?: ReactNode\n}\n\nconst ICON = 16\n\n/** Every feature's switch, in order: the default rows. */\nconst DEFAULT_FEATURE_ROWS: readonly FeatureSettingRow[] = [\n {\n feature: 'calendar',\n testId: 'toggle-calendar',\n title: 'Calendar (experimental)',\n icon: <CalendarDays size={ICON} />,\n description: 'Show the calendar when this experimental feature is switched on.',\n },\n {\n feature: 'directUpload',\n id: 'useS3DirectUpload',\n testId: 'toggle-use-s3-direct-upload',\n title: 'Direct-to-storage upload',\n icon: <Upload size={ICON} />,\n description:\n 'Send encrypted files straight to storage instead of through the server. Looks the same while uploading; try it if uploads are slow.',\n },\n {\n feature: 'threadVisualization',\n id: 'threadsVisualization',\n testId: 'toggle-thread-visualization',\n title: 'Thread Visualization',\n icon: <Network size={ICON} />,\n description: 'Add a preview button to your chat list that shows how a conversation branched.',\n },\n {\n feature: 'skills',\n testId: 'toggle-skills',\n title: 'Skills',\n icon: <Sparkles size={ICON} />,\n description:\n 'Offer a list of things to start (research, summaries, your own skills) in a new chat, in the / menu and in the sidebar.',\n },\n {\n feature: 'paMode',\n testId: 'toggle-pa-mode',\n title: 'PA Mode',\n icon: <Bot size={ICON} />,\n description: 'Add a personal assistant mode to the chat box.',\n },\n {\n feature: 'conversationSearch',\n testId: 'toggle-conversation-search',\n title: 'Conversation Search',\n icon: <Search size={ICON} />,\n description: 'Search the text of your past conversations from the thread list.',\n },\n {\n feature: 'agentBuilder',\n id: 'agent-builder',\n testId: 'toggle-agent-builder',\n title: 'Agent Builder',\n icon: <Bot size={ICON} />,\n description:\n 'Design your own agents (persona, tools and skills) and give them tasks. Adds an Agents page to the sidebar.',\n },\n {\n feature: 'agentSessions',\n testId: 'toggle-agent-sessions',\n title: 'Assistant Sessions',\n icon: <ArbiBotHeadIcon className=\"size-4\" />,\n description: 'Manage long-running assistants and hand them workspace sessions.',\n },\n {\n feature: 'workflows',\n id: 'automations',\n testId: 'toggle-automations',\n title: 'Workflows',\n icon: <Workflow size={ICON} />,\n description:\n 'Saved workflows that start by hand, on a schedule, on an event or after a task, with steps for people and agents, and a Run later option when you start a skill. Adds Workflows to the sidebar.',\n },\n {\n feature: 'mail',\n testId: 'toggle-mail',\n title: 'Mail',\n icon: <Mail size={ICON} />,\n description:\n 'Your ARBI inbox: read, write and share documents by email. Adds Mail to the sidebar and a Mail tab to Settings.',\n },\n {\n feature: 'databases',\n id: 'custom_databases',\n testId: 'toggle-custom-databases',\n title: 'Databases',\n icon: <Table2 size={ICON} />,\n description:\n 'Tables your team keeps and searches, such as a client database or billing records, with typed columns and spreadsheet import and export. Adds Databases to the sidebar.',\n },\n {\n feature: 'dashboards',\n testId: 'toggle-dashboards',\n title: 'Pages',\n icon: <ChartColumn size={ICON} />,\n description:\n 'Pages of charts, figures, text and table views in each workspace: private until you share them. AI usage and database charts work anywhere; documents, tags, facts, workflows and activity read the open workspace. Adds Pages to the account menu.',\n },\n {\n feature: 'calls',\n testId: 'toggle-calls',\n title: 'Audio/video calls (experimental)',\n icon: <Phone size={ICON} />,\n },\n {\n feature: 'callAvatars',\n testId: 'toggle-call-avatars',\n title: 'Assistant avatars (experimental)',\n icon: <Phone size={ICON} />,\n description:\n 'Choose a voice and a 3D projection for your assistant. Requires an avatar-enabled call service.',\n },\n {\n feature: 'connectors',\n id: 'mcpConnectors',\n testId: 'toggle-mcp-connectors',\n title: 'Connectors',\n icon: <PlugZap size={ICON} />,\n description:\n 'Add a Connected Apps tab to settings for linking tools such as Slack, Google Drive, DocuSign and iManage.',\n rows: [\n {\n feature: 'connectorMicrosoft',\n testId: 'toggle-connector-microsoft',\n title: 'Microsoft',\n description: 'Outlook and Microsoft 365',\n },\n {\n feature: 'connectorSharepoint',\n testId: 'toggle-connector-sharepoint',\n title: 'SharePoint',\n description: 'SharePoint document libraries',\n },\n {\n feature: 'connectorGoogle',\n testId: 'toggle-connector-google',\n title: 'Google',\n description: 'Gmail and Google Drive',\n },\n {\n feature: 'connectorImanage',\n testId: 'toggle-connector-imanage',\n title: 'iManage',\n description: 'iManage Work',\n },\n ],\n },\n]\n\n/** The engineering switches, behind the \"Performance and diagnostics\" disclosure by default. */\nconst DEFAULT_FEATURE_MORE: { label: ReactNode; rows: readonly FeatureSettingRow[] } = {\n label: 'Performance and diagnostics',\n rows: [\n {\n feature: 'welcomeJourney',\n id: 'welcomeJourney',\n testId: 'toggle-welcome-journey',\n title: 'Welcome journey',\n icon: <Sparkles size={ICON} />,\n description: 'Show the getting-started checklist for new users.',\n },\n ],\n}\n\n/** Features: the switches of the features a site lets the user turn on or off. */\nexport function featuresSettingsSection({\n rows: siteRows,\n more: siteMore,\n id = 'experimental',\n label = 'Experimental',\n icon = <Code2 className=\"w-6 h-6\" />,\n}: FeaturesSettingsSectionOptions = {}): SettingsPageSection {\n const rows = siteRows ?? DEFAULT_FEATURE_ROWS\n const more =\n siteMore === null ? undefined : siteRows ? siteMore : (siteMore ?? DEFAULT_FEATURE_MORE)\n return {\n id,\n label,\n icon,\n render: () =>\n siteRows ? (\n <FeaturesSettings title={label} rows={rows} more={more} />\n ) : (\n <ListedFeaturesSettings title={label} rows={rows} more={more} />\n ),\n }\n}\n\n/** The rows of features the host lists (`features`), sub-rows too: an unlisted one has no switch. */\nfunction listedRows(\n rows: readonly FeatureSettingRow[],\n listed: ArbiFeatures | undefined\n): FeatureSettingRow[] {\n return rows\n .filter((row) => !!listed?.[row.feature])\n .map((row) => (row.rows ? { ...row, rows: listedRows(row.rows, listed) } : row))\n}\n\n/** The default rows, narrowed to the features the host lists. */\nfunction ListedFeaturesSettings({\n title,\n rows,\n more,\n}: {\n title: string\n rows: readonly FeatureSettingRow[]\n more?: { label: ReactNode; rows: readonly FeatureSettingRow[] }\n}) {\n const listed = useArbiHost().features\n const moreRows = more ? listedRows(more.rows, listed) : []\n return (\n <FeaturesSettings\n title={title}\n rows={listedRows(rows, listed)}\n more={more && moreRows.length > 0 ? { ...more, rows: moreRows } : undefined}\n />\n )\n}\n\nfunction FeaturesSettings({\n title,\n rows,\n more,\n}: {\n title: string\n rows: readonly FeatureSettingRow[]\n more?: { label: ReactNode; rows: readonly FeatureSettingRow[] }\n}) {\n const [showMore, setShowMore] = useState(false)\n return (\n <SettingsPanel className=\"max-w-2xl space-y-4\">\n <SettingsSection title={title}>\n <SettingsCard>\n {rows.map((row) => (\n <FeatureRow key={row.feature} row={row} />\n ))}\n </SettingsCard>\n {more && (\n <div className=\"mt-6\" data-testid=\"experimental-diagnostics\">\n <button\n type=\"button\"\n onClick={() => setShowMore((open) => !open)}\n aria-expanded={showMore}\n data-testid=\"experimental-diagnostics-toggle\"\n className=\"flex items-center gap-1.5 text-sm font-medium text-muted-foreground pointer-coarse:min-h-11\"\n >\n {showMore ? <ChevronDown size={14} /> : <ChevronRight size={14} />}\n {more.label}\n </button>\n {showMore && (\n <SettingsCard className=\"mt-3\">\n {more.rows.map((row) => (\n <FeatureRow key={row.feature} row={row} />\n ))}\n </SettingsCard>\n )}\n </div>\n )}\n </SettingsSection>\n </SettingsPanel>\n )\n}\n\nfunction FeatureRow({ row }: { row: FeatureSettingRow }) {\n return row.feature === 'calls' ? <CallsRow row={row} /> : <SwitchRow row={row} />\n}\n\nfunction SwitchRow({ row }: { row: FeatureSettingRow }) {\n const { on, set } = useFeatureSwitch(row.feature)\n return (\n <>\n <SettingsSwitchRow\n id={row.id ?? row.feature}\n testId={row.testId ?? `toggle-${row.feature}`}\n title={row.title}\n icon={row.icon}\n description={row.description}\n checked={on}\n onCheckedChange={set}\n />\n {on && row.rows && row.rows.length > 0 && (\n <SettingsSwitchGroup>\n {row.rows.map((sub) => (\n <FeatureRow key={sub.feature} row={sub} />\n ))}\n </SettingsSwitchGroup>\n )}\n </>\n )\n}\n\nfunction CallsRow({ row }: { row: FeatureSettingRow }) {\n const { on, set } = useFeatureSwitch(row.feature)\n const state = callsSwitchState(useCallsConfig(), on)\n return (\n <SettingsSwitchRow\n id={row.id ?? row.feature}\n testId={row.testId ?? `toggle-${row.feature}`}\n title={row.title}\n icon={row.icon}\n description={state.description}\n checked={state.checked}\n disabled={state.disabled}\n onCheckedChange={set}\n />\n )\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Features, as a settings section a site adds as data (`ConnectedSettingsPage sections`): a switch\n * per feature the site lists, each read and written through the host's `features` (`useFeature`),\n * so a switch kept in the user's settings and one kept on this device look the same here.\n *\n * The rows are, by default, every feature the host lists (`features`) with its words; a site may\n * give its own. A row's\n * sub-switches show while it is on, and the `more` rows sit behind a disclosure. The `calls` row follows the server's calls config:\n * it is off and locked where the server has no calls, on and locked where calls are not\n * experimental there.\n */\nimport { useState, type ReactNode } from 'react'\nimport {\n Bot,\n CalendarDays,\n ChevronDown,\n ChartColumn,\n ChevronRight,\n Code2,\n Mail,\n Network,\n Phone,\n PlugZap,\n Search,\n Sparkles,\n Table2,\n Upload,\n Workflow,\n} from 'lucide-react'\nimport {\n useArbiHost,\n useCallsConfig,\n useFeatureSwitch,\n type ArbiFeature,\n type ArbiFeatures,\n} from '@arbidocs/react'\nimport { ArbiBotHeadIcon } from '@arbidocs/react/ui'\nimport type { SettingsPageSection } from '../../settings/SettingsPage'\nimport { SettingsCard, SettingsPanel, SettingsSection } from '../../settings/SettingsPanel'\nimport { SettingsSwitchGroup, SettingsSwitchRow } from '../../settings/SettingsSwitchRow'\nimport { callsSwitchState } from '../../settings/calls-switch'\n\n/** One feature's switch. */\nexport interface FeatureSettingRow {\n feature: ArbiFeature\n title: ReactNode\n /** The help text (the `calls` row says what the server allows instead). */\n description?: ReactNode\n icon?: ReactNode\n /** The switch's id. Default: the feature. */\n id?: string\n /** Default: `toggle-<feature>`. */\n testId?: string\n /** Switches that belong to this one, shown indented while it is on. */\n rows?: readonly FeatureSettingRow[]\n}\n\nexport interface FeaturesSettingsSectionOptions {\n /** The rows, in order. Default: every feature ({@link DEFAULT_FEATURE_ROWS}). */\n rows?: readonly FeatureSettingRow[]\n /**\n * Rows behind a disclosure, closed at first (switches a regular user need not meet). Default,\n * with the default rows: {@link DEFAULT_FEATURE_MORE}; `null`: none.\n */\n more?: { label: ReactNode; rows: readonly FeatureSettingRow[] } | null\n /** The section's id. Default: `experimental`. */\n id?: string\n /** The tab's and the heading's name. Default: \"Experimental\". */\n label?: string\n /** The tab's icon. Default: a code glyph. */\n icon?: ReactNode\n}\n\nconst ICON = 16\n\n/** Every feature's switch, in order: the default rows. */\nconst DEFAULT_FEATURE_ROWS: readonly FeatureSettingRow[] = [\n {\n feature: 'calendar',\n testId: 'toggle-calendar',\n title: 'Calendar (experimental)',\n icon: <CalendarDays size={ICON} />,\n description: 'Show the calendar when this experimental feature is switched on.',\n },\n {\n feature: 'directUpload',\n id: 'useS3DirectUpload',\n testId: 'toggle-use-s3-direct-upload',\n title: 'Direct-to-storage upload',\n icon: <Upload size={ICON} />,\n description:\n 'Send encrypted files straight to storage instead of through the server. Looks the same while uploading; try it if uploads are slow.',\n },\n {\n feature: 'threadVisualization',\n id: 'threadsVisualization',\n testId: 'toggle-thread-visualization',\n title: 'Thread Visualization',\n icon: <Network size={ICON} />,\n description: 'Add a preview button to your chat list that shows how a conversation branched.',\n },\n {\n feature: 'skills',\n testId: 'toggle-skills',\n title: 'Skills',\n icon: <Sparkles size={ICON} />,\n description:\n 'Offer a list of things to start (research, summaries, your own skills) in a new chat, in the / menu and in the sidebar.',\n },\n {\n feature: 'paMode',\n testId: 'toggle-pa-mode',\n title: 'PA Mode',\n icon: <Bot size={ICON} />,\n description: 'Add a personal assistant mode to the chat box.',\n },\n {\n feature: 'conversationSearch',\n testId: 'toggle-conversation-search',\n title: 'Conversation Search',\n icon: <Search size={ICON} />,\n description: 'Search the text of your past conversations from the thread list.',\n },\n {\n feature: 'agentBuilder',\n id: 'agent-builder',\n testId: 'toggle-agent-builder',\n title: 'Agent Builder',\n icon: <Bot size={ICON} />,\n description:\n 'Design your own agents (persona, tools and skills) and give them tasks. Adds an Agents page to the sidebar.',\n },\n {\n feature: 'agentSessions',\n testId: 'toggle-agent-sessions',\n title: 'Assistant Sessions',\n icon: <ArbiBotHeadIcon className=\"size-4\" />,\n description: 'Manage long-running assistants and hand them workspace sessions.',\n },\n {\n feature: 'workflows',\n id: 'automations',\n testId: 'toggle-automations',\n title: 'Workflows',\n icon: <Workflow size={ICON} />,\n description:\n 'Saved workflows that start by hand, on a schedule, on an event or after a task, with steps for people and agents, and a Run later option when you start a skill. Adds Workflows to the sidebar.',\n },\n {\n feature: 'mail',\n testId: 'toggle-mail',\n title: 'Mail',\n icon: <Mail size={ICON} />,\n description:\n 'Your ARBI inbox: read, write and share documents by email. Adds Mail to the sidebar and a Mail tab to Settings.',\n },\n {\n feature: 'databases',\n id: 'custom_databases',\n testId: 'toggle-custom-databases',\n title: 'Databases',\n icon: <Table2 size={ICON} />,\n description:\n 'Tables your team keeps and searches, such as a client database or billing records, with typed columns and spreadsheet import and export. Adds Databases to the sidebar.',\n },\n {\n feature: 'dashboards',\n testId: 'toggle-dashboards',\n title: 'Pages',\n icon: <ChartColumn size={ICON} />,\n description:\n 'Pages of charts, figures, text and table views in each workspace: private until you share them. AI usage and database charts work anywhere; documents, tags, facts, workflows and activity read the open workspace. Adds Pages to the account menu.',\n },\n {\n feature: 'calls',\n testId: 'toggle-calls',\n title: 'Audio/video calls (experimental)',\n icon: <Phone size={ICON} />,\n },\n {\n feature: 'callAvatars',\n testId: 'toggle-call-avatars',\n title: 'Assistant avatars (experimental)',\n icon: <Phone size={ICON} />,\n description:\n 'Enable before joining a call to see your assistant\u2019s 3D projection. Turning animation off keeps speech playing; enabling it during an audio-only call applies to your next call.',\n },\n {\n feature: 'connectors',\n id: 'mcpConnectors',\n testId: 'toggle-mcp-connectors',\n title: 'Connectors',\n icon: <PlugZap size={ICON} />,\n description:\n 'Add a Connected Apps tab to settings for linking tools such as Slack, Google Drive, DocuSign and iManage.',\n rows: [\n {\n feature: 'connectorMicrosoft',\n testId: 'toggle-connector-microsoft',\n title: 'Microsoft',\n description: 'Outlook and Microsoft 365',\n },\n {\n feature: 'connectorSharepoint',\n testId: 'toggle-connector-sharepoint',\n title: 'SharePoint',\n description: 'SharePoint document libraries',\n },\n {\n feature: 'connectorGoogle',\n testId: 'toggle-connector-google',\n title: 'Google',\n description: 'Gmail and Google Drive',\n },\n {\n feature: 'connectorImanage',\n testId: 'toggle-connector-imanage',\n title: 'iManage',\n description: 'iManage Work',\n },\n ],\n },\n]\n\n/** The engineering switches, behind the \"Performance and diagnostics\" disclosure by default. */\nconst DEFAULT_FEATURE_MORE: { label: ReactNode; rows: readonly FeatureSettingRow[] } = {\n label: 'Performance and diagnostics',\n rows: [\n {\n feature: 'welcomeJourney',\n id: 'welcomeJourney',\n testId: 'toggle-welcome-journey',\n title: 'Welcome journey',\n icon: <Sparkles size={ICON} />,\n description: 'Show the getting-started checklist for new users.',\n },\n ],\n}\n\n/** Features: the switches of the features a site lets the user turn on or off. */\nexport function featuresSettingsSection({\n rows: siteRows,\n more: siteMore,\n id = 'experimental',\n label = 'Experimental',\n icon = <Code2 className=\"w-6 h-6\" />,\n}: FeaturesSettingsSectionOptions = {}): SettingsPageSection {\n const rows = siteRows ?? DEFAULT_FEATURE_ROWS\n const more =\n siteMore === null ? undefined : siteRows ? siteMore : (siteMore ?? DEFAULT_FEATURE_MORE)\n return {\n id,\n label,\n icon,\n render: () =>\n siteRows ? (\n <FeaturesSettings title={label} rows={rows} more={more} />\n ) : (\n <ListedFeaturesSettings title={label} rows={rows} more={more} />\n ),\n }\n}\n\n/** The rows of features the host lists (`features`), sub-rows too: an unlisted one has no switch. */\nfunction listedRows(\n rows: readonly FeatureSettingRow[],\n listed: ArbiFeatures | undefined\n): FeatureSettingRow[] {\n return rows\n .filter((row) => !!listed?.[row.feature])\n .map((row) => (row.rows ? { ...row, rows: listedRows(row.rows, listed) } : row))\n}\n\n/** The default rows, narrowed to the features the host lists. */\nfunction ListedFeaturesSettings({\n title,\n rows,\n more,\n}: {\n title: string\n rows: readonly FeatureSettingRow[]\n more?: { label: ReactNode; rows: readonly FeatureSettingRow[] }\n}) {\n const listed = useArbiHost().features\n const moreRows = more ? listedRows(more.rows, listed) : []\n return (\n <FeaturesSettings\n title={title}\n rows={listedRows(rows, listed)}\n more={more && moreRows.length > 0 ? { ...more, rows: moreRows } : undefined}\n />\n )\n}\n\nfunction FeaturesSettings({\n title,\n rows,\n more,\n}: {\n title: string\n rows: readonly FeatureSettingRow[]\n more?: { label: ReactNode; rows: readonly FeatureSettingRow[] }\n}) {\n const [showMore, setShowMore] = useState(false)\n return (\n <SettingsPanel className=\"max-w-2xl space-y-4\">\n <SettingsSection title={title}>\n <SettingsCard>\n {rows.map((row) => (\n <FeatureRow key={row.feature} row={row} />\n ))}\n </SettingsCard>\n {more && (\n <div className=\"mt-6\" data-testid=\"experimental-diagnostics\">\n <button\n type=\"button\"\n onClick={() => setShowMore((open) => !open)}\n aria-expanded={showMore}\n data-testid=\"experimental-diagnostics-toggle\"\n className=\"flex items-center gap-1.5 text-sm font-medium text-muted-foreground pointer-coarse:min-h-11\"\n >\n {showMore ? <ChevronDown size={14} /> : <ChevronRight size={14} />}\n {more.label}\n </button>\n {showMore && (\n <SettingsCard className=\"mt-3\">\n {more.rows.map((row) => (\n <FeatureRow key={row.feature} row={row} />\n ))}\n </SettingsCard>\n )}\n </div>\n )}\n </SettingsSection>\n </SettingsPanel>\n )\n}\n\nfunction FeatureRow({ row }: { row: FeatureSettingRow }) {\n return row.feature === 'calls' ? <CallsRow row={row} /> : <SwitchRow row={row} />\n}\n\nfunction SwitchRow({ row }: { row: FeatureSettingRow }) {\n const { on, set } = useFeatureSwitch(row.feature)\n return (\n <>\n <SettingsSwitchRow\n id={row.id ?? row.feature}\n testId={row.testId ?? `toggle-${row.feature}`}\n title={row.title}\n icon={row.icon}\n description={row.description}\n checked={on}\n onCheckedChange={set}\n />\n {on && row.rows && row.rows.length > 0 && (\n <SettingsSwitchGroup>\n {row.rows.map((sub) => (\n <FeatureRow key={sub.feature} row={sub} />\n ))}\n </SettingsSwitchGroup>\n )}\n </>\n )\n}\n\nfunction CallsRow({ row }: { row: FeatureSettingRow }) {\n const { on, set } = useFeatureSwitch(row.feature)\n const state = callsSwitchState(useCallsConfig(), on)\n return (\n <SettingsSwitchRow\n id={row.id ?? row.feature}\n testId={row.testId ?? `toggle-${row.feature}`}\n title={row.title}\n icon={row.icon}\n description={state.description}\n checked={state.checked}\n disabled={state.disabled}\n onCheckedChange={set}\n />\n )\n}\n"],
|
|
5
5
|
"mappings": ";AAiFU,SAwQN,UAxQM,KAyOE,YAzOF;AAtEV,SAAS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ACjF;AAEA,SAAS,UAAU,EAAE,IAAI,GAA+B;AACtD,QAAM,EAAE,IAAI,IAAI,IAAI,iBAAiB,IAAI,OAAO;AAChD,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,IAAI,IAAI,MAAM,IAAI;AAAA,QAClB,QAAQ,IAAI,UAAU,UAAU,IAAI,OAAO;AAAA,QAC3C,OAAO,IAAI;AAAA,QACX,MAAM,IAAI;AAAA,QACV,aAAa,IAAI;AAAA,QACjB,SAAS;AAAA,QACT,iBAAiB;AAAA;AAAA,IACnB;AAAA,IACC,MAAM,IAAI,QAAQ,IAAI,KAAK,SAAS,KACnC,oBAAC,uBACE,cAAI,KAAK,IAAI,CAAC,QACb,oBAAC,cAA6B,KAAK,OAAlB,IAAI,OAAmB,CACzC,GACH;AAAA,KAEJ;AAEJ;AAEA,SAAS,SAAS,EAAE,IAAI,GAA+B;AACrD,QAAM,EAAE,IAAI,IAAI,IAAI,iBAAiB,IAAI,OAAO;AAChD,QAAM,QAAQ,iBAAiB,eAAe,GAAG,EAAE;AACnD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI,IAAI,MAAM,IAAI;AAAA,MAClB,QAAQ,IAAI,UAAU,UAAU,IAAI,OAAO;AAAA,MAC3C,OAAO,IAAI;AAAA,MACX,MAAM,IAAI;AAAA,MACV,aAAa,MAAM;AAAA,MACnB,SAAS,MAAM;AAAA,MACf,UAAU,MAAM;AAAA,MAChB,iBAAiB;AAAA;AAAA,EACnB;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -112,12 +112,15 @@ function ConnectedTagsPage() {
|
|
|
112
112
|
const onDelete = async (t) => {
|
|
113
113
|
const nested = getChildTags([...tags], t.external_id);
|
|
114
114
|
const uses = tagUseCount(t);
|
|
115
|
+
const dbRows = t.dbrow_count ?? 0;
|
|
115
116
|
const n2 = tagsPageNouns();
|
|
116
117
|
const tagNoun = (count) => (count === 1 ? n2.tag : n2.tags).toLowerCase();
|
|
117
118
|
const carriers = uses === 1 ? `${n2.document}, ${n2.fact} or ${n2.thread}` : `${n2.documents}, ${n2.facts} and ${n2.threads}`;
|
|
118
119
|
const message = `Delete ${tagKindNouns(t.kind).singular} "${t.name}"?` + (uses > 0 ? `
|
|
119
120
|
|
|
120
|
-
It is on ${uses} ${carriers.toLowerCase()}; those links are removed.` : "") + (
|
|
121
|
+
It is on ${uses} ${carriers.toLowerCase()}; those links are removed.` : "") + (dbRows > 0 ? `
|
|
122
|
+
|
|
123
|
+
It labels ${dbRows} database ${dbRows === 1 ? "row" : "rows"}; those labels are removed.` : "") + (nested.length > 0 ? `
|
|
121
124
|
|
|
122
125
|
${nested.length} nested ${tagNoun(nested.length)} ${nested.length === 1 ? "moves" : "move"} to the top level \u2014 not deleted.` : "");
|
|
123
126
|
if (!await confirm({ message, title: `Delete ${tagKindNouns(t.kind).singular}` })) return;
|