@arbidocs/blocks 0.5.127 → 0.5.128
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/{FilesViewerDialog-V6FSRQTP.cjs → FilesViewerDialog-C7XHGK36.cjs} +5 -5
- package/dist/{FilesViewerDialog-V6FSRQTP.cjs.map → FilesViewerDialog-C7XHGK36.cjs.map} +1 -1
- package/dist/{chunk-KXIRVKCJ.cjs → chunk-ERRXU2HL.cjs} +38 -6
- package/dist/chunk-ERRXU2HL.cjs.map +1 -0
- package/dist/{chunk-2SU37RZA.cjs → chunk-IWMHQTVL.cjs} +28 -12
- package/dist/chunk-IWMHQTVL.cjs.map +1 -0
- package/dist/{chunk-M6WVIGYP.cjs → chunk-IZJ5L246.cjs} +2 -2
- package/dist/{chunk-M6WVIGYP.cjs.map → chunk-IZJ5L246.cjs.map} +1 -1
- package/dist/{chunk-JVLOIIA7.cjs → chunk-ZQNTYINE.cjs} +4 -4
- package/dist/{chunk-JVLOIIA7.cjs.map → chunk-ZQNTYINE.cjs.map} +1 -1
- package/dist/connect/index.cjs +140 -140
- package/dist/connect/viewer.cjs +3 -3
- package/dist/connection/conversation/MermaidDiagram.js +11 -2
- package/dist/connection/conversation/MermaidDiagram.js.map +2 -2
- package/dist/connection/conversation/download-mermaid.d.ts +2 -0
- package/dist/connection/conversation/download-mermaid.js +29 -0
- package/dist/connection/conversation/download-mermaid.js.map +7 -0
- package/dist/connection/remote-control/remoteControl.js +19 -3
- package/dist/connection/remote-control/remoteControl.js.map +2 -2
- package/dist/embed/index.cjs +8 -8
- package/dist/index.cjs +53 -53
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/chunk-2SU37RZA.cjs.map +0 -1
- package/dist/chunk-KXIRVKCJ.cjs.map +0 -1
|
@@ -5,7 +5,7 @@ var chunkVWBYE3XY_cjs = require('./chunk-VWBYE3XY.cjs');
|
|
|
5
5
|
require('./chunk-XF355M7O.cjs');
|
|
6
6
|
require('./chunk-2F57IO7S.cjs');
|
|
7
7
|
require('./chunk-UFT22LAB.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkZQNTYINE_cjs = require('./chunk-ZQNTYINE.cjs');
|
|
9
9
|
require('./chunk-JITYC4OS.cjs');
|
|
10
10
|
require('./chunk-WVZLAAIZ.cjs');
|
|
11
11
|
require('./chunk-X7ALF4MP.cjs');
|
|
@@ -14,7 +14,7 @@ require('./chunk-PL7HUTM3.cjs');
|
|
|
14
14
|
require('./chunk-QWVUBTW3.cjs');
|
|
15
15
|
require('./chunk-JVEDKKNO.cjs');
|
|
16
16
|
require('./chunk-ADDQKZ5I.cjs');
|
|
17
|
-
require('./chunk-
|
|
17
|
+
require('./chunk-ERRXU2HL.cjs');
|
|
18
18
|
require('./chunk-5QERK4PK.cjs');
|
|
19
19
|
var chunkT73BHNQX_cjs = require('./chunk-T73BHNQX.cjs');
|
|
20
20
|
require('./chunk-HYUKPHCT.cjs');
|
|
@@ -233,11 +233,11 @@ function FilesViewerDialog({ artifactRuntimeUrl, ...props }) {
|
|
|
233
233
|
DocumentViewerDialog,
|
|
234
234
|
{
|
|
235
235
|
...props,
|
|
236
|
-
renderDocument: (id) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
236
|
+
renderDocument: (id) => /* @__PURE__ */ jsxRuntime.jsx(chunkZQNTYINE_cjs.ConnectedDocumentViewer, { documentId: id, artifactRuntimeUrl })
|
|
237
237
|
}
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
exports.FilesViewerDialog = FilesViewerDialog;
|
|
242
|
-
//# sourceMappingURL=FilesViewerDialog-
|
|
243
|
-
//# sourceMappingURL=FilesViewerDialog-
|
|
242
|
+
//# sourceMappingURL=FilesViewerDialog-C7XHGK36.cjs.map
|
|
243
|
+
//# sourceMappingURL=FilesViewerDialog-C7XHGK36.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/viewer/DocumentViewerDialog.tsx","../src/connection/files/page/FilesViewerDialog.tsx"],"names":["jsx","Eye","PenLine","MessageSquareText","DEFAULT_DOCUMENT_VIEWER_TABS","DEFAULT_ASK_SUGGESTIONS","DEFAULT_DOCUMENT_VIEWER_LABELS","useConnectedWorkspace","useArbiSessionStore","useBlocksEnvironment","useArbiSessionState","useDocuments","parseVersionRef","tab","useState","question","useRef","useSlashField","Dialog","jsxs","DialogContent","DialogHeader","DialogTitle","FileText","DialogDescription","SegmentedControl","ErrorBoundary","DocumentReview","AskBar","ConnectedDocumentViewer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAM,UAAU,CAAC,GAAA,KACf,KAAK,YAAA,EAAc,KAAA,IAAS,KAAK,SAAA,IAAa,UAAA;AAEhD,IAAM,SAAA,GAAkD;AAAA,EACtD,MAAA,kBAAQA,cAAA,CAACC,eAAA,EAAA,EAAI,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,EAChC,QAAA,kBAAUD,cAAA,CAACE,mBAAA,EAAA,EAAQ,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,EACtC,GAAA,kBAAKF,cAAA,CAACG,6BAAA,EAAA,EAAkB,SAAA,EAAU,QAAA,EAAS;AAC7C,CAAA;AAEA,IAAM,YAAA,GAAkD;AAAA,EACtD,MAAA,EAAQ,mBAAA;AAAA,EACR,QAAA,EAAU,gBAAA;AAAA,EACV,GAAA,EAAK;AACP,CAAA;AAEO,SAAS,oBAAA,CAAqB;AAAA,EACnC,UAAA;AAAA,EACA,IAAA,GAAOC,8CAAA;AAAA,EACP,UAAA;AAAA,EACA,MAAA,EAAQ,cAAA;AAAA,EACR,cAAA,GAAiBC,yCAAA;AAAA,EACjB,OAAA;AAAA,EACA;AACF,CAAA,EAA8B;AAC5B,EAAA,MAAM,MAAA,G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EAAU,kCAAA,EAAmC,eAAY,cAAA,EAC5D,QAAA,EAAA;AAAA,gCAAAnB,cAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,+BAAA,EAAiC,QAAA,EAAA,MAAA,CAAO,QAAA,EAAS,CAAA;AAAA,gBAC7D,KAAA,CAAM,QAAA;AAAA,gCACPA,cAAA;AAAA,kBAAC4B,wBAAA;AAAA,kBAAA;AAAA,oBACC,MAAA,EAAO,SAAA;AAAA,oBACP,WAAA,EAAa,MAAA,CAAO,cAAA,CAAe,OAAA,CAAQ,WAAW,KAAK,CAAA;AAAA,oBAC3D,WAAA,EAAa,CAAC,GAAG,cAAc,CAAA;AAAA,oBAC/B,KAAA,EAAO,CAAC,IAAA,KAAS;AACf,sBAAA,IAAI,CAAC,KAAA,CAAM,WAAA,CAAY,IAAI,CAAA,MAAO,IAAI,CAAA;AAAA,oBACxC,CAAA;AAAA,oBACA,KAAA,EAAO,QAAA;AAAA,oBACP,aAAA,EAAe,WAAA;AAAA,oBACf,gBAAgB,KAAA,CAAM,SAAA;AAAA,oBACtB,YAAY,KAAA,CAAM,aAAA;AAAA,oBAClB,QAAA,EAAU,WAAA;AAAA,oBACV,MAAM,KAAA,CAAM;AAAA;AAAA;AACd,eAAA,EACF;AAAA;AAAA;AAAA,SAEJ,EACF;AAAA;AAAA;AAAA,GACF,EACF,CAAA;AAEJ;ACnLO,SAAS,iBAAA,CAAkB,EAAE,kBAAA,EAAoB,GAAG,OAAM,EAA2B;AAC1F,EAAA,uBACE5B,cAAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,cAAA,EAAgB,CAAC,EAAA,qBACfA,eAAC6B,yCAAA,EAAA,EAAwB,UAAA,EAAY,IAAI,kBAAA,EAAwC;AAAA;AAAA,GAErF;AAEJ","file":"FilesViewerDialog-V6FSRQTP.cjs","sourcesContent":["/**\n * The document viewer as a dialog (the files page's own viewer): a title, the tabs\n * the host offers, and under them the review (`DocumentReview`), the whole viewer, or a question\n * (`AskBar`) that starts a thread about the document. Views of existing parts, not a new viewer.\n *\n * A draft started with Create New (the session's `draftDocuments`) has no server record yet: it\n * shows the whole viewer only (its kind, name and recorder), titled from the draft.\n */\n\nimport { useRef, useState, type ReactNode } from 'react'\nimport { Eye, FileText, MessageSquareText, PenLine } from 'lucide-react'\nimport {\n DocumentReview,\n useArbiSessionState,\n useArbiSessionStore,\n useDocuments,\n type WorkspaceDocument,\n} from '@arbidocs/react'\nimport { parseVersionRef } from '@arbidocs/react/artifacts'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '@arbidocs/react/ui'\nimport { AskBar } from '../../components/AskBar'\nimport { ErrorBoundary } from '../../components/ErrorBoundary'\nimport { SegmentedControl, type SegmentedOption } from '../../settings/SegmentedControl'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useConnectedWorkspace } from '../ConnectionProvider'\nimport { useSlashField } from '../ask/useSlashField'\nimport {\n DEFAULT_ASK_SUGGESTIONS,\n DEFAULT_DOCUMENT_VIEWER_LABELS,\n DEFAULT_DOCUMENT_VIEWER_TABS,\n type DocumentViewerDialogLabels,\n type DocumentViewerTab,\n} from './documentViewerTabs'\n\ntype ReviewDocument = Parameters<typeof DocumentReview>[0]['doc']\n\nexport interface DocumentViewerDialogProps {\n /** The document, or a version reference `doc-…@v{n}`. */\n documentId: string\n /** The views offered, in order. Default: review, document, ask. */\n tabs?: readonly DocumentViewerTab[]\n /** The view it opens on. Default: the first offered. */\n initialTab?: DocumentViewerTab\n labels?: DocumentViewerDialogLabels\n /** The ask view's suggested questions. */\n askSuggestions?: readonly string[]\n onClose: () => void\n /** The whole viewer, for the document view. */\n renderDocument: (documentId: string) => ReactNode\n}\n\nconst titleOf = (doc: WorkspaceDocument | undefined) =>\n doc?.doc_metadata?.title || doc?.file_name || 'Document'\n\nconst TAB_ICONS: Record<DocumentViewerTab, ReactNode> = {\n review: <Eye className=\"size-4\" />,\n document: <PenLine className=\"size-4\" />,\n ask: <MessageSquareText className=\"size-4\" />,\n}\n\nconst TAB_TEST_IDS: Record<DocumentViewerTab, string> = {\n review: 'review-tab-review',\n document: 'review-tab-pdf',\n ask: 'review-tab-qa',\n}\n\nexport function DocumentViewerDialog({\n documentId,\n tabs = DEFAULT_DOCUMENT_VIEWER_TABS,\n initialTab,\n labels: labelOverrides,\n askSuggestions = DEFAULT_ASK_SUGGESTIONS,\n onClose,\n renderDocument,\n}: DocumentViewerDialogProps) {\n const labels = { ...DEFAULT_DOCUMENT_VIEWER_LABELS, ...labelOverrides }\n const { workspaceId, live } = useConnectedWorkspace()\n const session = useArbiSessionStore()\n const { openNewConversation } = useBlocksEnvironment()\n const passageId = useArbiSessionState((s) => s.viewingDocument?.passageId ?? null)\n const draft = useArbiSessionState((s) => s.draftDocuments[documentId])\n const { data: documents } = useDocuments()\n const baseId = parseVersionRef(documentId).docId\n const doc = documents?.find((d) => d.external_id === baseId)\n const title = draft?.title || titleOf(doc)\n\n // The whole viewer needs a signed-in session (marking up, signing, versions). A draft is only\n // on the client: there is nothing to review or ask about until it is saved.\n const offered: readonly DocumentViewerTab[] = draft\n ? ['document']\n : tabs.filter((tab) => tab !== 'document' || live)\n const [chosen, setChosen] = useState<DocumentViewerTab | undefined>(initialTab)\n const tab = chosen && offered.includes(chosen) ? chosen : offered[0]\n\n const options: SegmentedOption<DocumentViewerTab>[] = offered.map((value) => ({\n value,\n label: labels[value],\n icon: TAB_ICONS[value],\n testId: TAB_TEST_IDS[value],\n }))\n\n // A question opens a new thread about the document, as the viewer's \"Chat\" does.\n const ask = (question: string) => {\n openNewConversation({ prompt: question })\n session.setNewChatDocumentId(baseId)\n }\n // The `/` menu: a skill's run is asked the same way, so its thread is about this document too.\n const [question, setQuestion] = useState('')\n const askInputRef = useRef<HTMLInputElement>(null)\n const slash = useSlashField({\n text: question,\n setText: setQuestion,\n inputRef: askInputRef,\n landing: 'chat',\n send: ask,\n })\n\n return (\n <Dialog open onOpenChange={(open) => !open && onClose()}>\n <DialogContent\n className=\"flex h-[90vh] max-w-[95vw] flex-col gap-0 p-0 sm:max-w-[95vw]\"\n data-testid=\"documents-dialog\"\n >\n <DialogHeader className=\"border-b px-4 py-3\">\n <DialogTitle className=\"flex min-w-0 items-center gap-2 pr-8 text-base\">\n <FileText className=\"size-4 shrink-0\" />\n <span className=\"truncate\" data-testid=\"documents-dialog-title\">\n {title}\n </span>\n </DialogTitle>\n <DialogDescription className=\"sr-only\">\n {offered.map((value) => labels[value]).join(', ')}: {title}\n </DialogDescription>\n {options.length > 1 && tab && (\n <SegmentedControl\n ariaLabel=\"Document view\"\n // A phone fits the three on one row: no label breaks over two lines.\n className=\"mt-2 w-fit max-w-full overflow-x-auto [&_button]:whitespace-nowrap max-sm:[&_button]:px-2.5\"\n value={tab}\n onChange={setChosen}\n options={options}\n />\n )}\n </DialogHeader>\n <div className=\"min-h-0 flex-1 overflow-hidden p-3\">\n {/* A view that fails to render says so here: the dialog and the page under it stay. */}\n <ErrorBoundary\n resetKey={`${documentId}|${tab}`}\n labels={{ title: \"This document couldn't be displayed\" }}\n testId=\"documents-dialog-error\"\n >\n {tab === 'review' && (\n <DocumentReview\n docId={baseId}\n doc={doc as ReviewDocument}\n workspaceId={workspaceId ?? undefined}\n activeChunkId={passageId}\n />\n )}\n {tab === 'document' && (\n <div className=\"h-full overflow-hidden\" data-testid=\"documents-dialog-viewer\">\n {renderDocument(documentId)}\n </div>\n )}\n {tab === 'ask' && (\n <div className=\"mx-auto max-w-2xl space-y-3 pt-6\" data-testid=\"doc-qa-panel\">\n <p className=\"text-sm text-muted-foreground\">{labels.askIntro}</p>\n {slash.launcher}\n <AskBar\n testId=\"doc-ask\"\n placeholder={labels.askPlaceholder.replace('{title}', title)}\n suggestions={[...askSuggestions]}\n onAsk={(text) => {\n if (!slash.startsSkill(text)) ask(text)\n }}\n value={question}\n onValueChange={setQuestion}\n onInputKeyDown={slash.onKeyDown}\n inputProps={slash.comboboxProps}\n inputRef={askInputRef}\n menu={slash.menu}\n />\n </div>\n )}\n </ErrorBoundary>\n </div>\n </DialogContent>\n </Dialog>\n )\n}\n","/**\n * The files page's own viewer (a page without a host viewer): `DocumentViewerDialog`, with the\n * whole `ConnectedDocumentViewer` as its document view. The page lazy-loads this module, so the\n * viewer stays out of the page's chunk.\n */\nimport { ConnectedDocumentViewer } from '../../viewer/ConnectedDocumentViewer'\nimport {\n DocumentViewerDialog,\n type DocumentViewerDialogProps,\n} from '../../viewer/DocumentViewerDialog'\n\nexport interface FilesViewerDialogProps extends Omit<DocumentViewerDialogProps, 'renderDocument'> {\n /** Where html/react artifacts load their sandbox runtime from. */\n artifactRuntimeUrl?: string\n}\n\nexport function FilesViewerDialog({ artifactRuntimeUrl, ...props }: FilesViewerDialogProps) {\n return (\n <DocumentViewerDialog\n {...props}\n renderDocument={(id) => (\n <ConnectedDocumentViewer documentId={id} artifactRuntimeUrl={artifactRuntimeUrl} />\n )}\n />\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/connection/viewer/DocumentViewerDialog.tsx","../src/connection/files/page/FilesViewerDialog.tsx"],"names":["jsx","Eye","PenLine","MessageSquareText","DEFAULT_DOCUMENT_VIEWER_TABS","DEFAULT_ASK_SUGGESTIONS","DEFAULT_DOCUMENT_VIEWER_LABELS","useConnectedWorkspace","useArbiSessionStore","useBlocksEnvironment","useArbiSessionState","useDocuments","parseVersionRef","tab","useState","question","useRef","useSlashField","Dialog","jsxs","DialogContent","DialogHeader","DialogTitle","FileText","DialogDescription","SegmentedControl","ErrorBoundary","DocumentReview","AskBar","ConnectedDocumentViewer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAM,UAAU,CAAC,GAAA,KACf,KAAK,YAAA,EAAc,KAAA,IAAS,KAAK,SAAA,IAAa,UAAA;AAEh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AA,oBACP,aAAA,EAAe,WAAA;AAAA,oBACf,gBAAgB,KAAA,CAAM,SAAA;AAAA,oBACtB,YAAY,KAAA,CAAM,aAAA;AAAA,oBAClB,QAAA,EAAU,WAAA;AAAA,oBACV,MAAM,KAAA,CAAM;AAAA;AAAA;AACd,eAAA,EACF;AAAA;AAAA;AAAA,SAEJ,EACF;AAAA;AAAA;AAAA,GACF,EACF,CAAA;AAEJ;ACnLO,SAAS,iBAAA,CAAkB,EAAE,kBAAA,EAAoB,GAAG,OAAM,EAA2B;AAC1F,EAAA,uBACE5B,cAAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,cAAA,EAAgB,CAAC,EAAA,qBACfA,eAAC6B,yCAAA,EAAA,EAAwB,UAAA,EAAY,IAAI,kBAAA,EAAwC;AAAA;AAAA,GAErF;AAEJ","file":"FilesViewerDialog-C7XHGK36.cjs","sourcesContent":["/**\n * The document viewer as a dialog (the files page's own viewer): a title, the tabs\n * the host offers, and under them the review (`DocumentReview`), the whole viewer, or a question\n * (`AskBar`) that starts a thread about the document. Views of existing parts, not a new viewer.\n *\n * A draft started with Create New (the session's `draftDocuments`) has no server record yet: it\n * shows the whole viewer only (its kind, name and recorder), titled from the draft.\n */\n\nimport { useRef, useState, type ReactNode } from 'react'\nimport { Eye, FileText, MessageSquareText, PenLine } from 'lucide-react'\nimport {\n DocumentReview,\n useArbiSessionState,\n useArbiSessionStore,\n useDocuments,\n type WorkspaceDocument,\n} from '@arbidocs/react'\nimport { parseVersionRef } from '@arbidocs/react/artifacts'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '@arbidocs/react/ui'\nimport { AskBar } from '../../components/AskBar'\nimport { ErrorBoundary } from '../../components/ErrorBoundary'\nimport { SegmentedControl, type SegmentedOption } from '../../settings/SegmentedControl'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useConnectedWorkspace } from '../ConnectionProvider'\nimport { useSlashField } from '../ask/useSlashField'\nimport {\n DEFAULT_ASK_SUGGESTIONS,\n DEFAULT_DOCUMENT_VIEWER_LABELS,\n DEFAULT_DOCUMENT_VIEWER_TABS,\n type DocumentViewerDialogLabels,\n type DocumentViewerTab,\n} from './documentViewerTabs'\n\ntype ReviewDocument = Parameters<typeof DocumentReview>[0]['doc']\n\nexport interface DocumentViewerDialogProps {\n /** The document, or a version reference `doc-…@v{n}`. */\n documentId: string\n /** The views offered, in order. Default: review, document, ask. */\n tabs?: readonly DocumentViewerTab[]\n /** The view it opens on. Default: the first offered. */\n initialTab?: DocumentViewerTab\n labels?: DocumentViewerDialogLabels\n /** The ask view's suggested questions. */\n askSuggestions?: readonly string[]\n onClose: () => void\n /** The whole viewer, for the document view. */\n renderDocument: (documentId: string) => ReactNode\n}\n\nconst titleOf = (doc: WorkspaceDocument | undefined) =>\n doc?.doc_metadata?.title || doc?.file_name || 'Document'\n\nconst TAB_ICONS: Record<DocumentViewerTab, ReactNode> = {\n review: <Eye className=\"size-4\" />,\n document: <PenLine className=\"size-4\" />,\n ask: <MessageSquareText className=\"size-4\" />,\n}\n\nconst TAB_TEST_IDS: Record<DocumentViewerTab, string> = {\n review: 'review-tab-review',\n document: 'review-tab-pdf',\n ask: 'review-tab-qa',\n}\n\nexport function DocumentViewerDialog({\n documentId,\n tabs = DEFAULT_DOCUMENT_VIEWER_TABS,\n initialTab,\n labels: labelOverrides,\n askSuggestions = DEFAULT_ASK_SUGGESTIONS,\n onClose,\n renderDocument,\n}: DocumentViewerDialogProps) {\n const labels = { ...DEFAULT_DOCUMENT_VIEWER_LABELS, ...labelOverrides }\n const { workspaceId, live } = useConnectedWorkspace()\n const session = useArbiSessionStore()\n const { openNewConversation } = useBlocksEnvironment()\n const passageId = useArbiSessionState((s) => s.viewingDocument?.passageId ?? null)\n const draft = useArbiSessionState((s) => s.draftDocuments[documentId])\n const { data: documents } = useDocuments()\n const baseId = parseVersionRef(documentId).docId\n const doc = documents?.find((d) => d.external_id === baseId)\n const title = draft?.title || titleOf(doc)\n\n // The whole viewer needs a signed-in session (marking up, signing, versions). A draft is only\n // on the client: there is nothing to review or ask about until it is saved.\n const offered: readonly DocumentViewerTab[] = draft\n ? ['document']\n : tabs.filter((tab) => tab !== 'document' || live)\n const [chosen, setChosen] = useState<DocumentViewerTab | undefined>(initialTab)\n const tab = chosen && offered.includes(chosen) ? chosen : offered[0]\n\n const options: SegmentedOption<DocumentViewerTab>[] = offered.map((value) => ({\n value,\n label: labels[value],\n icon: TAB_ICONS[value],\n testId: TAB_TEST_IDS[value],\n }))\n\n // A question opens a new thread about the document, as the viewer's \"Chat\" does.\n const ask = (question: string) => {\n openNewConversation({ prompt: question })\n session.setNewChatDocumentId(baseId)\n }\n // The `/` menu: a skill's run is asked the same way, so its thread is about this document too.\n const [question, setQuestion] = useState('')\n const askInputRef = useRef<HTMLInputElement>(null)\n const slash = useSlashField({\n text: question,\n setText: setQuestion,\n inputRef: askInputRef,\n landing: 'chat',\n send: ask,\n })\n\n return (\n <Dialog open onOpenChange={(open) => !open && onClose()}>\n <DialogContent\n className=\"flex h-[90vh] max-w-[95vw] flex-col gap-0 p-0 sm:max-w-[95vw]\"\n data-testid=\"documents-dialog\"\n >\n <DialogHeader className=\"border-b px-4 py-3\">\n <DialogTitle className=\"flex min-w-0 items-center gap-2 pr-8 text-base\">\n <FileText className=\"size-4 shrink-0\" />\n <span className=\"truncate\" data-testid=\"documents-dialog-title\">\n {title}\n </span>\n </DialogTitle>\n <DialogDescription className=\"sr-only\">\n {offered.map((value) => labels[value]).join(', ')}: {title}\n </DialogDescription>\n {options.length > 1 && tab && (\n <SegmentedControl\n ariaLabel=\"Document view\"\n // A phone fits the three on one row: no label breaks over two lines.\n className=\"mt-2 w-fit max-w-full overflow-x-auto [&_button]:whitespace-nowrap max-sm:[&_button]:px-2.5\"\n value={tab}\n onChange={setChosen}\n options={options}\n />\n )}\n </DialogHeader>\n <div className=\"min-h-0 flex-1 overflow-hidden p-3\">\n {/* A view that fails to render says so here: the dialog and the page under it stay. */}\n <ErrorBoundary\n resetKey={`${documentId}|${tab}`}\n labels={{ title: \"This document couldn't be displayed\" }}\n testId=\"documents-dialog-error\"\n >\n {tab === 'review' && (\n <DocumentReview\n docId={baseId}\n doc={doc as ReviewDocument}\n workspaceId={workspaceId ?? undefined}\n activeChunkId={passageId}\n />\n )}\n {tab === 'document' && (\n <div className=\"h-full overflow-hidden\" data-testid=\"documents-dialog-viewer\">\n {renderDocument(documentId)}\n </div>\n )}\n {tab === 'ask' && (\n <div className=\"mx-auto max-w-2xl space-y-3 pt-6\" data-testid=\"doc-qa-panel\">\n <p className=\"text-sm text-muted-foreground\">{labels.askIntro}</p>\n {slash.launcher}\n <AskBar\n testId=\"doc-ask\"\n placeholder={labels.askPlaceholder.replace('{title}', title)}\n suggestions={[...askSuggestions]}\n onAsk={(text) => {\n if (!slash.startsSkill(text)) ask(text)\n }}\n value={question}\n onValueChange={setQuestion}\n onInputKeyDown={slash.onKeyDown}\n inputProps={slash.comboboxProps}\n inputRef={askInputRef}\n menu={slash.menu}\n />\n </div>\n )}\n </ErrorBoundary>\n </div>\n </DialogContent>\n </Dialog>\n )\n}\n","/**\n * The files page's own viewer (a page without a host viewer): `DocumentViewerDialog`, with the\n * whole `ConnectedDocumentViewer` as its document view. The page lazy-loads this module, so the\n * viewer stays out of the page's chunk.\n */\nimport { ConnectedDocumentViewer } from '../../viewer/ConnectedDocumentViewer'\nimport {\n DocumentViewerDialog,\n type DocumentViewerDialogProps,\n} from '../../viewer/DocumentViewerDialog'\n\nexport interface FilesViewerDialogProps extends Omit<DocumentViewerDialogProps, 'renderDocument'> {\n /** Where html/react artifacts load their sandbox runtime from. */\n artifactRuntimeUrl?: string\n}\n\nexport function FilesViewerDialog({ artifactRuntimeUrl, ...props }: FilesViewerDialogProps) {\n return (\n <DocumentViewerDialog\n {...props}\n renderDocument={(id) => (\n <ConnectedDocumentViewer documentId={id} artifactRuntimeUrl={artifactRuntimeUrl} />\n )}\n />\n )\n}\n"]}
|
|
@@ -7,11 +7,11 @@ var chunkMCXS6X37_cjs = require('./chunk-MCXS6X37.cjs');
|
|
|
7
7
|
var chunk75BNMCUX_cjs = require('./chunk-75BNMCUX.cjs');
|
|
8
8
|
var chunkTKHCIHE2_cjs = require('./chunk-TKHCIHE2.cjs');
|
|
9
9
|
var React = require('react');
|
|
10
|
+
var lucideReact = require('lucide-react');
|
|
11
|
+
var ui = require('@arbidocs/react/ui');
|
|
10
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
13
|
var react = require('@arbidocs/react');
|
|
12
14
|
var shell = require('@arbidocs/react/shell');
|
|
13
|
-
var ui = require('@arbidocs/react/ui');
|
|
14
|
-
var lucideReact = require('lucide-react');
|
|
15
15
|
|
|
16
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
|
|
@@ -31,6 +31,32 @@ function normalizeMermaidGraph(source) {
|
|
|
31
31
|
return `${header}
|
|
32
32
|
${body.trimStart()}`;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
// src/connection/conversation/download-mermaid.ts
|
|
36
|
+
function downloadMermaidSvg(rendered) {
|
|
37
|
+
const doc = new DOMParser().parseFromString(rendered, "image/svg+xml");
|
|
38
|
+
const svg = doc.documentElement;
|
|
39
|
+
if (svg.localName !== "svg" || doc.querySelector("parsererror"))
|
|
40
|
+
throw new Error("The diagram did not produce a valid SVG image");
|
|
41
|
+
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
42
|
+
const box = svg.getAttribute("viewBox")?.trim().split(/[\s,]+/).map(Number);
|
|
43
|
+
if (box?.length === 4 && box.every(Number.isFinite) && box[2] > 0 && box[3] > 0) {
|
|
44
|
+
svg.setAttribute("width", String(Math.ceil(box[2])));
|
|
45
|
+
svg.setAttribute("height", String(Math.ceil(box[3])));
|
|
46
|
+
}
|
|
47
|
+
const blob = new Blob([new XMLSerializer().serializeToString(svg)], { type: "image/svg+xml" });
|
|
48
|
+
const url = URL.createObjectURL(blob);
|
|
49
|
+
const link = document.createElement("a");
|
|
50
|
+
link.href = url;
|
|
51
|
+
link.download = "diagram.svg";
|
|
52
|
+
document.body.append(link);
|
|
53
|
+
try {
|
|
54
|
+
link.click();
|
|
55
|
+
} finally {
|
|
56
|
+
link.remove();
|
|
57
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
34
60
|
var mermaidInstance = null;
|
|
35
61
|
var mermaidLoadPromise = null;
|
|
36
62
|
async function getMermaid() {
|
|
@@ -118,12 +144,18 @@ function MermaidDiagram({ chart }) {
|
|
|
118
144
|
}
|
|
119
145
|
);
|
|
120
146
|
}
|
|
121
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
122
148
|
"div",
|
|
123
149
|
{
|
|
124
150
|
className: "mermaid-diagram my-4 overflow-x-auto rounded-md border border-border bg-background p-4",
|
|
125
151
|
"data-testid": "mermaid-diagram",
|
|
126
|
-
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { variant: "ghost", size: "sm", onClick: () => downloadMermaidSvg(svg), children: [
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "mr-2 size-4", "aria-hidden": "true" }),
|
|
155
|
+
"Download SVG"
|
|
156
|
+
] }) }),
|
|
157
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { dangerouslySetInnerHTML: { __html: svg } })
|
|
158
|
+
]
|
|
127
159
|
}
|
|
128
160
|
);
|
|
129
161
|
}
|
|
@@ -284,5 +316,5 @@ exports.InternalDocLink = InternalDocLink;
|
|
|
284
316
|
exports.MermaidDiagram = MermaidDiagram;
|
|
285
317
|
exports.WorkspaceDocumentReference = WorkspaceDocumentReference;
|
|
286
318
|
exports.useDocumentWorkspace = useDocumentWorkspace;
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
288
|
-
//# sourceMappingURL=chunk-
|
|
319
|
+
//# sourceMappingURL=chunk-ERRXU2HL.cjs.map
|
|
320
|
+
//# sourceMappingURL=chunk-ERRXU2HL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chat/mermaid-normalize.ts","../src/connection/conversation/download-mermaid.ts","../src/connection/conversation/MermaidDiagram.tsx","../src/connection/conversation/DocumentWorkspaceContext.tsx","../src/connection/conversation/ConnectedMarkdown.tsx"],"names":["useState","useId","useEffect","jsxs","jsx","Button","Download","createContext","useContext","useBlocksEnvironment","React","useArbiSession","MentionChip","QuietLink","useArbiHost","Fragment","useCompactChat","useDocument","EntityPill","FileText","DocumentEntity","Mail","mentionFromHref","MarkdownLink","workspaceDocIdFromHref","MarkdownStreamingContext","MarkdownCode","rehypeDocEntityPills","useMemo","KitMarkdownRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBO,SAAS,sBAAsB,MAAA,EAAwB;AAE5D,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA,EAAG,OAAO,MAAA;AAE9B,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,KAAA,CAAM,gCAAgC,CAAA;AACjE,EAAA,IAAI,CAAC,aAAa,OAAO,MAAA;AAEzB,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,CAAC,CAAA,CAAE,OAAA,EAAQ;AACtC,EAAA,IAAI,OAAO,MAAA,CAAO,KAAA,CAAM,WAAA,CAAY,CAAC,EAAE,MAAM,CAAA;AAG7C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,uDAAA,EAAyD,OAAO,CAAA;AAIpF,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,cAAA,EAAgB,SAAS,CAAA;AAI7C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,wCAAA,EAA0C,KA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IACrE;AACA,IAAA,uBAAOA,cAAAA,CAACsB,eAAA,EAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AAAA,EAClC,CAAA;AAAA,EACA,MAAM,CAAC,EAAE,UAAU,SAAA,EAAW,GAAG,OAAM,KAA8C;AACnF,IAAA,MAAM,KAAA,GAAS,MAAkC,aAAa,CAAA;AAC9D,IAAA,IAAI,KAAA,EAAO,uBAAOtB,cAAAA,CAAC,gBAAa,KAAA,EAAc,CAAA;AAC9C,IAAA,MAAM,MAAA,GAAU,MAAkC,cAAc,CAAA;AAChE,IAAA,IAAI,MAAA,EAAQ,uBAAOA,cAAAA,CAAC,YAAS,MAAA,EAAgB,CAAA;AAC7C,IAAA,uBACEA,cAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAuB,GAAG,OAC7B,QAAA,EACH,CAAA;AAAA,EAEJ;AACF,CAAA;AAGA,IAAM,yBAAA,GAA4B,CAACuB,sCAAoB,CAAA;AAWvD,SAAS,0BAAA,CAA2B,EAAE,UAAA,EAAY,GAAG,OAAM,EAA2B;AACpF,EAAA,MAAM,MAAA,GAASC,aAAA;AAAA,IACb,MACE,UAAA,GACI,EAAE,GAAG,8BAAA,EAAgC,GAAG,YAAW,GACnD,8BAAA;AAAA,IACN,CAAC,UAAU;AAAA,GACb;AACA,EAAA,uBACExB,eAACyB,mBAAA,EAAA,EAAqB,GAAG,OAAO,UAAA,EAAY,MAAA,EAAQ,eAAe,yBAAA,EAA2B,CAAA;AAElG;AAEO,IAAM,iBAAA,GAAoBnB,sBAAA,CAAM,IAAA,CAAK,0BAA0B","file":"chunk-ERRXU2HL.cjs","sourcesContent":["/**\n * Defensive normalizer for single-line `graph` / `flowchart` Mermaid source.\n *\n * Some LLMs emit the entire diagram on one line. Mermaid's parser splits\n * statements on newlines, so a single-line graph fails outright. This helper\n * inserts newlines on safe statement boundaries so the diagram has a chance\n * of parsing. Only attempts normalization when:\n * 1. The source has no embedded newlines (i.e. is genuinely single-line), and\n * 2. The first directive is `graph` or `flowchart`.\n *\n * Other diagram types (sequenceDiagram, classDiagram, gantt, …) have very\n * different syntaxes — applying these heuristics to them would corrupt valid\n * input, so they're left untouched.\n *\n * Boundaries we split on:\n * - After the diagram-type header (`graph TD`, `flowchart LR`, …).\n * - Before each `style` / `classDef` / `class` / `linkStyle` / `click`\n * / `subgraph` keyword.\n * - Before/after `end` (closes a subgraph block).\n * - After a `]` (label close) that's followed by another node identifier\n * starting a new edge or node declaration.\n */\nexport function normalizeMermaidGraph(source: string): string {\n // Already multi-line — assume it's well-formed; don't touch it.\n if (/\\n/.test(source)) return source\n\n const headerMatch = source.match(/^\\s*(graph|flowchart)\\s+\\w+\\s+/)\n if (!headerMatch) return source\n\n const header = headerMatch[0].trimEnd()\n let body = source.slice(headerMatch[0].length)\n\n // Insert newline before keywords that always start a new statement.\n body = body.replace(/\\s+(style|classDef|class|linkStyle|click|subgraph)\\s/g, '\\n$1 ')\n\n // `end` closes a subgraph: put it on its own line, with a break after it\n // too so any trailing statements don't stay attached.\n body = body.replace(/\\s+end\\b\\s*/g, '\\nend\\n')\n\n // After a label close (`]`), if the next token looks like a Mermaid node id\n // followed by another `[` or `-->`, that's a new statement starting.\n body = body.replace(/\\]\\s+(?=[A-Za-z_][\\w-]*\\s*(?:\\[|-->))/g, ']\\n')\n\n // Collapse any accidental runs of blank lines we may have produced.\n body = body.replace(/\\n{2,}/g, '\\n')\n\n return `${header}\\n${body.trimStart()}`\n}\n","/** Save the rendered graphic, including Mermaid's styles, as a standalone image. */\nexport function downloadMermaidSvg(rendered: string): void {\n const doc = new DOMParser().parseFromString(rendered, 'image/svg+xml')\n const svg = doc.documentElement\n if (svg.localName !== 'svg' || doc.querySelector('parsererror'))\n throw new Error('The diagram did not produce a valid SVG image')\n svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg')\n const box = svg\n .getAttribute('viewBox')\n ?.trim()\n .split(/[\\s,]+/)\n .map(Number)\n if (box?.length === 4 && box.every(Number.isFinite) && box[2] > 0 && box[3] > 0) {\n svg.setAttribute('width', String(Math.ceil(box[2])))\n svg.setAttribute('height', String(Math.ceil(box[3])))\n }\n const blob = new Blob([new XMLSerializer().serializeToString(svg)], { type: 'image/svg+xml' })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = 'diagram.svg'\n document.body.append(link)\n try {\n link.click()\n } finally {\n link.remove()\n // Let the browser consume the download before releasing the image URL.\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n }\n}\n","/**\n * MermaidDiagram Component\n *\n * Renders a Mermaid diagram from source code.\n * Used inside MarkdownRenderer to handle ```mermaid code blocks.\n * Lazy-loads the mermaid library to avoid bloating the initial bundle.\n */\n\nimport { useState, useEffect, useId } from 'react'\nimport { Download } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { normalizeMermaidGraph } from '../../chat/mermaid-normalize'\nimport { downloadMermaidSvg } from './download-mermaid'\n\ninterface MermaidDiagramProps {\n /** Mermaid diagram source code */\n chart: string\n}\n\n// Lazy-load and initialize mermaid once\nlet mermaidInstance: typeof import('mermaid').default | null = null\nlet mermaidLoadPromise: Promise<typeof import('mermaid').default> | null = null\n\nasync function getMermaid() {\n if (mermaidInstance) return mermaidInstance\n if (!mermaidLoadPromise) {\n mermaidLoadPromise = import('mermaid').then((mod) => {\n const m = mod.default\n m.initialize({\n startOnLoad: false,\n theme: 'default',\n securityLevel: 'strict',\n flowchart: { useMaxWidth: true, curve: 'basis' },\n })\n mermaidInstance = m\n return m\n })\n }\n return mermaidLoadPromise\n}\n\nexport function MermaidDiagram({ chart }: MermaidDiagramProps) {\n const [svg, setSvg] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const uniqueId = useId().replace(/:/g, '-')\n\n useEffect(() => {\n let cancelled = false\n\n async function render() {\n const mermaid = await getMermaid()\n const diagramId = `mermaid${uniqueId}`\n\n // Validate with parse() before render(). In Mermaid v11 a render() with\n // bad source can return a \"Syntax error in text\" bomb SVG instead of\n // throwing — and it appends DOM side-effects of its own — so a try/catch\n // around render() doesn't reliably catch failures and the bomb leaks\n // into the page (especially under React StrictMode where effects run\n // twice). parse() throws cleanly with no DOM side-effects.\n //\n // Defensive rescue: some LLMs emit single-line `graph`/`flowchart`\n // source. If the original parse fails, try a normalized variant. The\n // normalizer is a no-op on already-multi-line source and on non-graph\n // diagram types, so this only helps the bad-source case and never\n // corrupts valid input.\n let validSource: string | null = null\n let firstErr: unknown\n try {\n await mermaid.parse(chart)\n validSource = chart\n } catch (err) {\n firstErr = err\n const normalized = normalizeMermaidGraph(chart)\n if (normalized !== chart) {\n try {\n await mermaid.parse(normalized)\n validSource = normalized\n } catch (retryErr) {\n console.warn('Mermaid normalized parse also failed', retryErr)\n }\n }\n }\n\n if (cancelled) return\n\n if (!validSource) {\n console.warn('Mermaid parse failed, showing source', firstErr)\n setError('Failed to render diagram')\n setSvg(null)\n return\n }\n\n try {\n const { svg: renderedSvg } = await mermaid.render(diagramId, validSource)\n if (!cancelled) {\n setSvg(renderedSvg)\n setError(null)\n }\n } catch (renderErr) {\n if (!cancelled) {\n console.warn('Mermaid render failed despite parse success', renderErr)\n setError('Failed to render diagram')\n setSvg(null)\n }\n }\n }\n\n render()\n return () => {\n cancelled = true\n }\n }, [chart, uniqueId])\n\n if (error) {\n // Fall back to showing the raw source in a code block\n return (\n <div className=\"code-block\" data-testid=\"mermaid-error\">\n <div className=\"text-sm text-muted-foreground mb-1\">{error}</div>\n <code className=\"language-mermaid\">{chart}</code>\n </div>\n )\n }\n\n if (!svg) {\n return (\n <div\n className=\"flex items-center justify-center py-8 text-muted-foreground text-sm\"\n data-testid=\"mermaid-loading\"\n >\n Rendering diagram...\n </div>\n )\n }\n\n return (\n <div\n className=\"mermaid-diagram my-4 overflow-x-auto rounded-md border border-border bg-background p-4\"\n data-testid=\"mermaid-diagram\"\n >\n <div className=\"mb-2 flex justify-end\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => downloadMermaidSvg(svg)}>\n <Download className=\"mr-2 size-4\" aria-hidden=\"true\" />\n Download SVG\n </Button>\n </div>\n <div dangerouslySetInnerHTML={{ __html: svg }} />\n </div>\n )\n}\n","/**\n * The workspace a conversation's document references belong to, when it is not the open one: an\n * agent's direct-message thread runs in the agent's workspace, so the documents it names are there.\n * A reference then opens that workspace first (`openDocument(id, { workspaceId })`).\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useBlocksEnvironment } from '../../provider/environment'\n\n/** The workspace of the documents referenced inside it (null: the open workspace). */\nexport const DocumentWorkspaceContext = createContext<string | null>(null)\nexport const useDocumentWorkspace = () => useContext(DocumentWorkspaceContext)\n\n/** A reference to a document of another workspace: opening it opens that workspace first. */\nexport function WorkspaceDocumentReference({\n workspaceId,\n docId,\n children,\n className = 'inline-flex rounded-full border px-2 py-0.5 text-xs hover:bg-muted',\n}: {\n workspaceId: string\n docId: string\n children?: ReactNode\n className?: string\n}) {\n const { openDocument } = useBlocksEnvironment()\n return (\n <button\n type=\"button\"\n className={className}\n onClick={() => openDocument(docId, { workspaceId })}\n >\n {children ?? docId}\n </button>\n )\n}\n","/**\n * The conversation's markdown: the kit's `MarkdownRenderer` (`@arbidocs/react`: sanitised HTML,\n * slugs, lazy KaTeX, streaming blocks, tables, code) with what a conversation adds: @mention chips,\n * workspace documents opening in the viewer, quiet external links, document and email pills (the\n * host's chips, `ArbiChatHost.renderDocumentChip` / `renderMailChip`) and Mermaid diagrams.\n */\nimport { useArbiHost, useArbiSession, useDocument } from '@arbidocs/react'\nimport { mentionFromHref, type MentionKind } from '@arbidocs/react/shell'\nimport {\n EntityPill,\n getDocumentTitle,\n MarkdownCode,\n MarkdownLink,\n MarkdownRenderer as KitMarkdownRenderer,\n MarkdownStreamingContext,\n type MarkdownRendererProps as KitMarkdownRendererProps,\n DocumentEntity,\n} from '@arbidocs/react/ui'\nimport React, { useContext, useMemo } from 'react'\nimport { FileText, Mail } from 'lucide-react'\n\n/** The markdown element overrides, as the kit's renderer takes them. */\ntype Components = NonNullable<KitMarkdownRendererProps['components']>\nimport { useCompactChat } from '../../chat/CompactChatContext'\nimport { MentionChip } from '../../chat/MentionMenu'\nimport { QuietLink } from '../../citations/QuietMarks'\nimport { rehypeDocEntityPills } from '../../chat/rehype-doc-entity-pills'\nimport { workspaceDocIdFromHref } from '../../chat/doc-links'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { MermaidDiagram } from './MermaidDiagram'\nimport { useDocumentWorkspace, WorkspaceDocumentReference } from './DocumentWorkspaceContext'\n\n/** Plain text of a link's children (the `@Label` of a mention link). */\nfunction childrenText(children: React.ReactNode): string {\n return React.Children.toArray(children)\n .map((child) => (typeof child === 'string' || typeof child === 'number' ? String(child) : ''))\n .join('')\n}\n\n/** A mention chip; a mention of the reader stands out. */\nfunction MentionLink({ kind, id, text }: { kind: MentionKind; id: string; text: string }) {\n const currentUserId = useArbiSession().user?.external_id\n return (\n <MentionChip\n kind={kind}\n id={id}\n label={text.replace(/^@/, '')}\n isSelf={kind === 'user' && id === currentUserId}\n />\n )\n}\n\n/**\n * A link to elsewhere, as quiet text. Its menu (Open link / Copy link) is the deliberate step\n * the old confirmation dialog used to be; nothing opens until the menu's primary row is chosen.\n */\nexport function ExternalLink({ href, children }: React.ComponentPropsWithoutRef<'a'>) {\n return (\n <QuietLink href={href} kind=\"external\">\n {children}\n </QuietLink>\n )\n}\n\n/**\n * A workspace document referenced by a link's href rather than by its text.\n *\n * `rehypeDocEntityPills` turns a bare `doc-…` id into a pill, but it only walks\n * TEXT nodes — so `[NVDA DCF Valuation Report](…doc-abc12345…)`, which is how an\n * answer links an artifact it just saved, keeps the id in the href where the\n * plugin never looks. The link then fell through to `ExternalLink`, and opening\n * your own workspace document asked you to confirm an \"external link\" and\n * launched a new tab. It opens in the document viewer, like the pill and the\n * artifact card already do.\n */\nexport function InternalDocLink({\n docId,\n href,\n children,\n}: React.ComponentPropsWithoutRef<'a'> & { docId: string }) {\n const { openDocument } = useBlocksEnvironment()\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) {\n return (\n <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId}>\n {children}\n </WorkspaceDocumentReference>\n )\n }\n\n return (\n <QuietLink href={href} kind=\"document\" onOpen={() => openDocument(docId)}>\n {children}\n </QuietLink>\n )\n}\n\n/** A document of the workspace, as a pill: the host's chip, else the document entity. */\nexport function DocumentChip({ docId }: { docId: string }) {\n const render = useArbiHost().chat?.renderDocumentChip\n const workspaceId = useDocumentWorkspace()\n if (workspaceId) return <WorkspaceDocumentReference workspaceId={workspaceId} docId={docId} />\n return render ? <>{render(docId)}</> : <DefaultDocumentChip docId={docId} />\n}\n\nfunction DefaultDocumentChip({ docId }: { docId: string }) {\n const compact = useCompactChat()\n const { data: doc } = useDocument(docId)\n const { openDocument } = useBlocksEnvironment()\n if (compact && doc)\n return (\n <button\n type=\"button\"\n className=\"inline text-left text-primary underline decoration-primary/30 underline-offset-2 hover:decoration-primary\"\n onClick={() => openDocument(docId)}\n >\n {getDocumentTitle(doc)}\n </button>\n )\n if (!doc)\n return (\n <EntityPill\n icon={<FileText className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label={docId}\n size=\"sm\"\n onClick={() => openDocument(docId)}\n data-testid=\"doc-entity-pill\"\n />\n )\n return (\n <DocumentEntity doc={doc} onClick={() => openDocument(docId)} data-testid=\"doc-entity-pill\" />\n )\n}\n\n/** An email of the person's mailbox, as a pill: the host's chip, else a plain \"Email\". */\nfunction MailChip({ mailId }: { mailId: string }) {\n const render = useArbiHost().chat?.renderMailChip\n if (render) return <>{render(mailId)}</>\n return (\n <EntityPill\n icon={<Mail className=\"w-3.5 h-3.5 flex-shrink-0\" />}\n label=\"Email\"\n size=\"sm\"\n data-testid=\"mail-entity-pill\"\n />\n )\n}\n\n/**\n * The conversation's overrides, layered on the kit's defaults. Module scope, so the reference is stable\n * and memoised markdown blocks do not re-parse.\n */\nconst conversationMarkdownComponents: Partial<Components> = {\n a: function ConversationMarkdownLink({\n href,\n children,\n ...props\n }: React.ComponentPropsWithoutRef<'a'>) {\n const deploymentDomain = useBlocksEnvironment().runtimeConfig.deploymentDomain\n // @mentions: `linkMentions` turned them into `#mention-<id>` links; draw them as chips.\n const mention = mentionFromHref(href)\n if (mention) {\n return <MentionLink kind={mention.kind} id={mention.id} text={childrenText(children)} />\n }\n // Bookmarks: in-page anchors are near-invisible text; the menu jumps or copies the place.\n if (href?.startsWith('#') && !href.startsWith('#cite-')) {\n return (\n <QuietLink href={href} kind=\"anchor\">\n {children}\n </QuietLink>\n )\n }\n // Citations, `cite:` references and bare links: the kit's link.\n if (!href || href.startsWith('#') || href.startsWith('cite:')) {\n return (\n <MarkdownLink href={href} {...props}>\n {children}\n </MarkdownLink>\n )\n }\n // A workspace document is not an external link, wherever it is hosted: it opens in the viewer.\n const docId = workspaceDocIdFromHref(href, deploymentDomain)\n if (docId) {\n return (\n <InternalDocLink docId={docId} href={href} {...props}>\n {children}\n </InternalDocLink>\n )\n }\n return (\n <ExternalLink href={href} {...props}>\n {children}\n </ExternalLink>\n )\n },\n code: function ConversationMarkdownCode(\n props: React.ComponentPropsWithoutRef<'code'> & { inline?: boolean }\n ) {\n const isStreaming = useContext(MarkdownStreamingContext)\n const { className, children } = props\n const language = /language-(\\w+)/.exec(className || '')?.[1]\n if (!language) {\n // Answers often backtick a bare doc id (`doc-f7b3eeb5`). The text-node pass skips code, so\n // the id would stay monospace text; show it as the document pill. Only a whole id (eight\n // alphanumerics): while streaming, a partial one (\"doc-e\") would be looked up and 404.\n const codeText = typeof children === 'string' ? children.trim() : ''\n if (/^doc-[a-zA-Z0-9]{8}$/.test(codeText)) return <DocumentChip docId={codeText} />\n if (/^eml-[a-zA-Z0-9]{8}$/.test(codeText)) return <MailChip mailId={codeText} />\n }\n // Mermaid lazy-loads its own bundle and re-renders SVG on every change. While streaming the\n // fence is almost always partial, so it stays a code block until generation completes.\n if (language === 'mermaid' && !isStreaming) {\n return <MermaidDiagram chart={String(children).replace(/\\n$/, '')} />\n }\n return <MarkdownCode {...props} />\n },\n span: ({ children, className, ...props }: React.ComponentPropsWithoutRef<'span'>) => {\n const docId = (props as Record<string, unknown>)['data-doc-id'] as string | undefined\n if (docId) return <DocumentChip docId={docId} />\n const mailId = (props as Record<string, unknown>)['data-mail-id'] as string | undefined\n if (mailId) return <MailChip mailId={mailId} />\n return (\n <span className={className} {...props}>\n {children}\n </span>\n )\n },\n}\n\n/** Bare `doc-…` / `eml-…` ids in text become `<span data-doc-id>` / `<span data-mail-id>` pills. */\nconst conversationRehypePlugins = [rehypeDocEntityPills]\n\nexport type ConnectedMarkdownProps = Omit<\n KitMarkdownRendererProps,\n 'rehypePlugins' | 'allowHtml' | 'renderCitation'\n>\n\n/**\n * The kit's renderer with the conversation's overrides; a caller's `components` (e.g. the citation\n * core's) still win over both.\n */\nfunction ConnectedMarkdownComponent({ components, ...props }: ConnectedMarkdownProps) {\n const merged = useMemo(\n () =>\n components\n ? { ...conversationMarkdownComponents, ...components }\n : conversationMarkdownComponents,\n [components]\n )\n return (\n <KitMarkdownRenderer {...props} components={merged} rehypePlugins={conversationRehypePlugins} />\n )\n}\n\nexport const ConnectedMarkdown = React.memo(ConnectedMarkdownComponent)\n"]}
|
|
@@ -6,7 +6,7 @@ var chunk7NLO7ASW_cjs = require('./chunk-7NLO7ASW.cjs');
|
|
|
6
6
|
var chunk7PN3YENO_cjs = require('./chunk-7PN3YENO.cjs');
|
|
7
7
|
var chunkTJY7XPDE_cjs = require('./chunk-TJY7XPDE.cjs');
|
|
8
8
|
var chunkXNW62J54_cjs = require('./chunk-XNW62J54.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunkERRXU2HL_cjs = require('./chunk-ERRXU2HL.cjs');
|
|
10
10
|
var chunkT73BHNQX_cjs = require('./chunk-T73BHNQX.cjs');
|
|
11
11
|
var chunk223D4727_cjs = require('./chunk-223D4727.cjs');
|
|
12
12
|
var chunkQQMMCXBP_cjs = require('./chunk-QQMMCXBP.cjs');
|
|
@@ -310,7 +310,7 @@ var screenRuntimes = /* @__PURE__ */ new WeakMap();
|
|
|
310
310
|
function screenRuntime(session) {
|
|
311
311
|
let runtime = screenRuntimes.get(session);
|
|
312
312
|
if (!runtime) {
|
|
313
|
-
runtime = { sharing: createScreenSharing(), generation: 0, setup: "" };
|
|
313
|
+
runtime = { sharing: createScreenSharing(), generation: 0, setup: "", opening: false };
|
|
314
314
|
screenRuntimes.set(session, runtime);
|
|
315
315
|
}
|
|
316
316
|
return runtime;
|
|
@@ -321,6 +321,7 @@ function stopScreen(session) {
|
|
|
321
321
|
runtime.generation++;
|
|
322
322
|
runtime.sharing.stop();
|
|
323
323
|
runtime.setup = "";
|
|
324
|
+
runtime.opening = false;
|
|
324
325
|
const actions = react.remoteControlActions(session);
|
|
325
326
|
if (react.remoteControlStateOf(session.getState()).sharing) actions.setSharing(false);
|
|
326
327
|
}
|
|
@@ -353,12 +354,14 @@ function createRemoteControl(session, guided, screenTransport) {
|
|
|
353
354
|
actions.setControllingAgent({ name: req.agentName, extId: req.agentExtId });
|
|
354
355
|
try {
|
|
355
356
|
if (!runtime.sharing.active) {
|
|
357
|
+
runtime.opening = true;
|
|
356
358
|
await runtime.sharing.start(disable);
|
|
357
359
|
if (!current()) {
|
|
358
360
|
runtime.sharing.stop();
|
|
359
361
|
await reply(req, "stopped");
|
|
360
362
|
return;
|
|
361
363
|
}
|
|
364
|
+
runtime.opening = false;
|
|
362
365
|
actions.setSharing(true);
|
|
363
366
|
if (screenTransport.diagnose)
|
|
364
367
|
runtime.setup = await screenTransport.diagnose().catch(() => "Setup checks unavailable.");
|
|
@@ -383,7 +386,9 @@ ${runtime.setup}`.slice(0, 24e3)
|
|
|
383
386
|
if (current()) disable();
|
|
384
387
|
} finally {
|
|
385
388
|
if (current()) {
|
|
386
|
-
|
|
389
|
+
const currentAgent = state().controllingAgent;
|
|
390
|
+
if (currentAgent?.name === req.agentName && currentAgent.extId === req.agentExtId)
|
|
391
|
+
actions.setControllingAgent(null);
|
|
387
392
|
if (!keepSharing) disable();
|
|
388
393
|
}
|
|
389
394
|
}
|
|
@@ -489,6 +494,17 @@ function useRemoteControlSessionReset() {
|
|
|
489
494
|
];
|
|
490
495
|
return () => off.forEach((unsubscribe) => unsubscribe?.());
|
|
491
496
|
}, [arbi, session]);
|
|
497
|
+
React6.useEffect(
|
|
498
|
+
() => session.subscribe(() => {
|
|
499
|
+
const permission = react.remoteControlStateOf(session.getState());
|
|
500
|
+
const runtime = screenRuntimes.get(session);
|
|
501
|
+
if (runtime && (runtime.sharing.active || runtime.opening) && !permission.enabled && !permission.controllingAgent) {
|
|
502
|
+
stopScreen(session);
|
|
503
|
+
chunkORELHENJ_cjs.cancelGuidedRun();
|
|
504
|
+
}
|
|
505
|
+
}),
|
|
506
|
+
[session]
|
|
507
|
+
);
|
|
492
508
|
const lastUser = React6.useRef(userId);
|
|
493
509
|
React6.useEffect(() => {
|
|
494
510
|
if (lastUser.current === userId) return;
|
|
@@ -510,7 +526,7 @@ function useRemoteControlHandlers() {
|
|
|
510
526
|
react.remoteControlActions(session).setEnabled(false);
|
|
511
527
|
chunkORELHENJ_cjs.cancelGuidedRun();
|
|
512
528
|
},
|
|
513
|
-
[session, workspaceId]
|
|
529
|
+
[session, workspaceId, remoteControl]
|
|
514
530
|
);
|
|
515
531
|
return React6.useMemo(
|
|
516
532
|
() => remoteControl ? {
|
|
@@ -1738,7 +1754,7 @@ var AgentStepsComponent = ({
|
|
|
1738
1754
|
summary && !isActive && (step.narration ? (
|
|
1739
1755
|
/* Narration is PROSE (headings, bold, lists): render markdown, not raw asterisks.
|
|
1740
1756
|
Tool summaries stay plain text: one-line headlines where a clamp matters. */
|
|
1741
|
-
/* @__PURE__ */ jsxRuntime.jsx(chunkTP5PGWIO_cjs.StepNarration, { index: step.index, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1757
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkTP5PGWIO_cjs.StepNarration, { index: step.index, children: /* @__PURE__ */ jsxRuntime.jsx(chunkERRXU2HL_cjs.ConnectedMarkdown, { isStreaming: false, children: summary }) })
|
|
1742
1758
|
) : /* @__PURE__ */ jsxRuntime.jsx(chunkTP5PGWIO_cjs.StepSummary, { index: step.index, multiLine: isMultiLine, children: summary })),
|
|
1743
1759
|
details.map((d, di) => /* @__PURE__ */ jsxRuntime.jsx(chunkTP5PGWIO_cjs.StepDetail, { index: step.index, children: d }, di)),
|
|
1744
1760
|
showOutcome && /* @__PURE__ */ jsxRuntime.jsx(chunkTP5PGWIO_cjs.StepOutcome, { index: step.index, failed: outcomeFailed, children: step.outcome }),
|
|
@@ -2120,13 +2136,13 @@ function withAnswerTable(components) {
|
|
|
2120
2136
|
}
|
|
2121
2137
|
return merged;
|
|
2122
2138
|
}
|
|
2123
|
-
var renderMarkdown = ({ components, isStreaming, children }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2139
|
+
var renderMarkdown = ({ components, isStreaming, children }) => /* @__PURE__ */ jsxRuntime.jsx(chunkERRXU2HL_cjs.ConnectedMarkdown, { components: withAnswerTable(components), isStreaming, children });
|
|
2124
2140
|
function LinkInAnswer({ href, children, ...props }) {
|
|
2125
2141
|
const docId = chunkZ2XZ2D4N_cjs.workspaceDocIdFromHref(href, chunkTKHCIHE2_cjs.useBlocksEnvironment().runtimeConfig.deploymentDomain);
|
|
2126
2142
|
if (docId) {
|
|
2127
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2143
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkERRXU2HL_cjs.InternalDocLink, { docId, href, ...props, children });
|
|
2128
2144
|
}
|
|
2129
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2145
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkERRXU2HL_cjs.ExternalLink, { href, ...props, children });
|
|
2130
2146
|
}
|
|
2131
2147
|
var ConnectedCitationRendererComponent = (props) => {
|
|
2132
2148
|
const session = react.useArbiSessionStore();
|
|
@@ -2856,7 +2872,7 @@ var MessageComponent = ({
|
|
|
2856
2872
|
),
|
|
2857
2873
|
subagentTaskRecord && /* @__PURE__ */ jsxRuntime.jsx(chunkM2FOXGJU_cjs.MessageSubagentBadge, { messageId }),
|
|
2858
2874
|
/* @__PURE__ */ jsxRuntime.jsxs(chunkM2FOXGJU_cjs.MessageBody, { messageId, children: [
|
|
2859
|
-
settledNarration ? /* @__PURE__ */ jsxRuntime.jsx(chunkM2FOXGJU_cjs.MessageNarration, { messageId, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2875
|
+
settledNarration ? /* @__PURE__ */ jsxRuntime.jsx(chunkM2FOXGJU_cjs.MessageNarration, { messageId, children: /* @__PURE__ */ jsxRuntime.jsx(chunkERRXU2HL_cjs.ConnectedMarkdown, { isStreaming: false, children: settledNarration }) }) : null,
|
|
2860
2876
|
liveContent ? role === "assistant" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2861
2877
|
ConnectedCitationRenderer,
|
|
2862
2878
|
{
|
|
@@ -2866,7 +2882,7 @@ var MessageComponent = ({
|
|
|
2866
2882
|
messageId: message.external_id || "unknown",
|
|
2867
2883
|
isStreaming: isGenerating
|
|
2868
2884
|
}
|
|
2869
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2885
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(chunkERRXU2HL_cjs.ConnectedMarkdown, { isStreaming: isGenerating, children: linkMentions(
|
|
2870
2886
|
isUser && liveContent.startsWith("/pa ") ? liveContent.slice(4) : liveContent,
|
|
2871
2887
|
message.mentions
|
|
2872
2888
|
) }) : null,
|
|
@@ -5607,5 +5623,5 @@ exports.useRemoteControlHandlers = useRemoteControlHandlers;
|
|
|
5607
5623
|
exports.useRemoteControlSessionReset = useRemoteControlSessionReset;
|
|
5608
5624
|
exports.useSsoSignIn = useSsoSignIn;
|
|
5609
5625
|
exports.useWorkspaceDocTitles = useWorkspaceDocTitles;
|
|
5610
|
-
//# sourceMappingURL=chunk-
|
|
5611
|
-
//# sourceMappingURL=chunk-
|
|
5626
|
+
//# sourceMappingURL=chunk-IWMHQTVL.cjs.map
|
|
5627
|
+
//# sourceMappingURL=chunk-IWMHQTVL.cjs.map
|