@arbidocs/blocks 0.5.149 → 0.5.150

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.
Files changed (127) hide show
  1. package/README.md +1 -1
  2. package/bin/arbidocs-record-take.mjs +122 -0
  3. package/dist/{ConnectedCallDock-EASMNJXB.cjs → ConnectedCallDock-L3QIWXAA.cjs} +22 -22
  4. package/dist/{ConnectedCallDock-EASMNJXB.cjs.map → ConnectedCallDock-L3QIWXAA.cjs.map} +1 -1
  5. package/dist/{ConnectedCallRoom-BWZ2FHXN.cjs → ConnectedCallRoom-S7INF4I5.cjs} +15 -15
  6. package/dist/{ConnectedCallRoom-BWZ2FHXN.cjs.map → ConnectedCallRoom-S7INF4I5.cjs.map} +1 -1
  7. package/dist/{ConnectedNativeDocxComparison-4FAJDXPT.cjs → ConnectedNativeDocxComparison-BVECWYJ5.cjs} +20 -20
  8. package/dist/{ConnectedNativeDocxComparison-4FAJDXPT.cjs.map → ConnectedNativeDocxComparison-BVECWYJ5.cjs.map} +1 -1
  9. package/dist/{ConnectedPresentation-EIWVV7ON.cjs → ConnectedPresentation-F6NYQ2X7.cjs} +21 -21
  10. package/dist/{ConnectedPresentation-EIWVV7ON.cjs.map → ConnectedPresentation-F6NYQ2X7.cjs.map} +1 -1
  11. package/dist/{ConnectedProductionSetDialog-SDHD5KTG.cjs → ConnectedProductionSetDialog-T5J4YLA7.cjs} +3 -3
  12. package/dist/{ConnectedProductionSetDialog-SDHD5KTG.cjs.map → ConnectedProductionSetDialog-T5J4YLA7.cjs.map} +1 -1
  13. package/dist/{ConnectedSlidesTab-4FN5ZRRI.cjs → ConnectedSlidesTab-WY6JCGWZ.cjs} +18 -18
  14. package/dist/{ConnectedSlidesTab-4FN5ZRRI.cjs.map → ConnectedSlidesTab-WY6JCGWZ.cjs.map} +1 -1
  15. package/dist/{ConnectedStreamedWordArtifact-D7EZFIJ7.cjs → ConnectedStreamedWordArtifact-ELNWWKZD.cjs} +20 -20
  16. package/dist/{ConnectedStreamedWordArtifact-D7EZFIJ7.cjs.map → ConnectedStreamedWordArtifact-ELNWWKZD.cjs.map} +1 -1
  17. package/dist/{DocumentReviewCard-7MVNPVZC.cjs → DocumentReviewCard-KV2B7BD3.cjs} +19 -19
  18. package/dist/{DocumentReviewCard-7MVNPVZC.cjs.map → DocumentReviewCard-KV2B7BD3.cjs.map} +1 -1
  19. package/dist/{FilesViewerDialog-6363IOTL.cjs → FilesViewerDialog-HJABYPOA.cjs} +46 -46
  20. package/dist/{FilesViewerDialog-6363IOTL.cjs.map → FilesViewerDialog-HJABYPOA.cjs.map} +1 -1
  21. package/dist/{WorkspaceTableView-HHATEV2H.cjs → WorkspaceTableView-XXCJ7LBO.cjs} +10 -10
  22. package/dist/{WorkspaceTableView-HHATEV2H.cjs.map → WorkspaceTableView-XXCJ7LBO.cjs.map} +1 -1
  23. package/dist/agents/index.cjs +303 -303
  24. package/dist/{ai-NC4ZE3UT.cjs → ai-RKRKOYO4.cjs} +26 -26
  25. package/dist/ai-RKRKOYO4.cjs.map +1 -0
  26. package/dist/auth/index.cjs +1 -1
  27. package/dist/calls/index.cjs +120 -120
  28. package/dist/chat/index.cjs +18 -18
  29. package/dist/{chunk-ZLJP6447.cjs → chunk-2XIENKEI.cjs} +31 -31
  30. package/dist/{chunk-ZLJP6447.cjs.map → chunk-2XIENKEI.cjs.map} +1 -1
  31. package/dist/{chunk-JARRHAQW.cjs → chunk-5636X4OX.cjs} +9 -9
  32. package/dist/{chunk-JARRHAQW.cjs.map → chunk-5636X4OX.cjs.map} +1 -1
  33. package/dist/{chunk-MKJBEL4W.cjs → chunk-6LTUUXRL.cjs} +4 -4
  34. package/dist/{chunk-MKJBEL4W.cjs.map → chunk-6LTUUXRL.cjs.map} +1 -1
  35. package/dist/{chunk-47NBCI3E.cjs → chunk-7PUVSSXX.cjs} +4 -4
  36. package/dist/{chunk-47NBCI3E.cjs.map → chunk-7PUVSSXX.cjs.map} +1 -1
  37. package/dist/{chunk-54Y4LWTA.cjs → chunk-AUEFLW3V.cjs} +50 -50
  38. package/dist/{chunk-54Y4LWTA.cjs.map → chunk-AUEFLW3V.cjs.map} +1 -1
  39. package/dist/{chunk-SQHR7564.cjs → chunk-BDLXTMOK.cjs} +70 -70
  40. package/dist/{chunk-SQHR7564.cjs.map → chunk-BDLXTMOK.cjs.map} +1 -1
  41. package/dist/{chunk-6KT6BEP4.cjs → chunk-BL3UUWIU.cjs} +8 -8
  42. package/dist/{chunk-6KT6BEP4.cjs.map → chunk-BL3UUWIU.cjs.map} +1 -1
  43. package/dist/{chunk-43GIESOM.cjs → chunk-CFSLZW4Y.cjs} +4 -4
  44. package/dist/{chunk-43GIESOM.cjs.map → chunk-CFSLZW4Y.cjs.map} +1 -1
  45. package/dist/{chunk-STFIBNND.cjs → chunk-CSN52UFI.cjs} +49 -49
  46. package/dist/{chunk-STFIBNND.cjs.map → chunk-CSN52UFI.cjs.map} +1 -1
  47. package/dist/{chunk-JZWLIOTP.cjs → chunk-DEJTECAY.cjs} +3 -3
  48. package/dist/{chunk-JZWLIOTP.cjs.map → chunk-DEJTECAY.cjs.map} +1 -1
  49. package/dist/{chunk-DHQH4EYB.cjs → chunk-FE4H7Z37.cjs} +4 -4
  50. package/dist/{chunk-DHQH4EYB.cjs.map → chunk-FE4H7Z37.cjs.map} +1 -1
  51. package/dist/{chunk-CRN64MYK.cjs → chunk-FVFIAQ2S.cjs} +12 -12
  52. package/dist/{chunk-CRN64MYK.cjs.map → chunk-FVFIAQ2S.cjs.map} +1 -1
  53. package/dist/{chunk-IIOFQKQV.cjs → chunk-IC3NREIK.cjs} +3 -3
  54. package/dist/{chunk-IIOFQKQV.cjs.map → chunk-IC3NREIK.cjs.map} +1 -1
  55. package/dist/{chunk-H5ITWXUA.cjs → chunk-JUFSJGTN.cjs} +4 -4
  56. package/dist/{chunk-H5ITWXUA.cjs.map → chunk-JUFSJGTN.cjs.map} +1 -1
  57. package/dist/{chunk-LXQMTVAB.cjs → chunk-KGAYY7LB.cjs} +7 -7
  58. package/dist/{chunk-LXQMTVAB.cjs.map → chunk-KGAYY7LB.cjs.map} +1 -1
  59. package/dist/{chunk-YV36BZE7.cjs → chunk-L7QNPS52.cjs} +11 -11
  60. package/dist/{chunk-YV36BZE7.cjs.map → chunk-L7QNPS52.cjs.map} +1 -1
  61. package/dist/{chunk-UHT2Q6IF.cjs → chunk-LW7TDQ63.cjs} +12 -12
  62. package/dist/{chunk-UHT2Q6IF.cjs.map → chunk-LW7TDQ63.cjs.map} +1 -1
  63. package/dist/{chunk-5QEPUONH.cjs → chunk-M53KQLFA.cjs} +4 -4
  64. package/dist/{chunk-5QEPUONH.cjs.map → chunk-M53KQLFA.cjs.map} +1 -1
  65. package/dist/{chunk-GPP7E3OQ.cjs → chunk-N2IQSGYU.cjs} +3 -3
  66. package/dist/{chunk-GPP7E3OQ.cjs.map → chunk-N2IQSGYU.cjs.map} +1 -1
  67. package/dist/{chunk-2ZH4KVAZ.cjs → chunk-P65JMN57.cjs} +36 -36
  68. package/dist/{chunk-2ZH4KVAZ.cjs.map → chunk-P65JMN57.cjs.map} +1 -1
  69. package/dist/{chunk-J5YEEWZT.cjs → chunk-QRCYKBLX.cjs} +7 -7
  70. package/dist/{chunk-J5YEEWZT.cjs.map → chunk-QRCYKBLX.cjs.map} +1 -1
  71. package/dist/{chunk-3WXAGCUL.cjs → chunk-QVKSN3G3.cjs} +6 -6
  72. package/dist/{chunk-3WXAGCUL.cjs.map → chunk-QVKSN3G3.cjs.map} +1 -1
  73. package/dist/{chunk-X5H2STK4.cjs → chunk-RBBUKGG4.cjs} +7 -7
  74. package/dist/{chunk-X5H2STK4.cjs.map → chunk-RBBUKGG4.cjs.map} +1 -1
  75. package/dist/{chunk-2E5AODIC.cjs → chunk-RCUM5HQN.cjs} +28 -28
  76. package/dist/{chunk-2E5AODIC.cjs.map → chunk-RCUM5HQN.cjs.map} +1 -1
  77. package/dist/{chunk-U6XMZG6G.cjs → chunk-RDBUQCAS.cjs} +3 -3
  78. package/dist/{chunk-U6XMZG6G.cjs.map → chunk-RDBUQCAS.cjs.map} +1 -1
  79. package/dist/{chunk-ZUYY3JRO.cjs → chunk-TBLQCML6.cjs} +3 -3
  80. package/dist/{chunk-ZUYY3JRO.cjs.map → chunk-TBLQCML6.cjs.map} +1 -1
  81. package/dist/{chunk-TJDCTRB5.cjs → chunk-TGZAJVDV.cjs} +4 -4
  82. package/dist/{chunk-TJDCTRB5.cjs.map → chunk-TGZAJVDV.cjs.map} +1 -1
  83. package/dist/{chunk-CFJAWCVX.cjs → chunk-UBKJNCWY.cjs} +16 -16
  84. package/dist/{chunk-CFJAWCVX.cjs.map → chunk-UBKJNCWY.cjs.map} +1 -1
  85. package/dist/{chunk-FHNWK5RO.cjs → chunk-VGRLKOIZ.cjs} +6 -6
  86. package/dist/{chunk-FHNWK5RO.cjs.map → chunk-VGRLKOIZ.cjs.map} +1 -1
  87. package/dist/{chunk-WSUHF676.cjs → chunk-VZZ2YIN4.cjs} +3 -3
  88. package/dist/{chunk-WSUHF676.cjs.map → chunk-VZZ2YIN4.cjs.map} +1 -1
  89. package/dist/{chunk-MHGZZ6IJ.cjs → chunk-WECRDCH4.cjs} +3 -3
  90. package/dist/{chunk-MHGZZ6IJ.cjs.map → chunk-WECRDCH4.cjs.map} +1 -1
  91. package/dist/{chunk-FZASPI2Q.cjs → chunk-XJAPT42P.cjs} +5 -5
  92. package/dist/{chunk-FZASPI2Q.cjs.map → chunk-XJAPT42P.cjs.map} +1 -1
  93. package/dist/{chunk-JARBYN6Z.cjs → chunk-Y3OI7ZP7.cjs} +3 -3
  94. package/dist/{chunk-JARBYN6Z.cjs.map → chunk-Y3OI7ZP7.cjs.map} +1 -1
  95. package/dist/{chunk-C7EGCNLV.cjs → chunk-YF5J44EA.cjs} +62 -62
  96. package/dist/{chunk-C7EGCNLV.cjs.map → chunk-YF5J44EA.cjs.map} +1 -1
  97. package/dist/{chunk-MIYEIACV.cjs → chunk-YRU6ZJUW.cjs} +6 -6
  98. package/dist/{chunk-MIYEIACV.cjs.map → chunk-YRU6ZJUW.cjs.map} +1 -1
  99. package/dist/{chunk-WXMD4AA4.cjs → chunk-ZNPBC4MK.cjs} +4 -4
  100. package/dist/{chunk-WXMD4AA4.cjs.map → chunk-ZNPBC4MK.cjs.map} +1 -1
  101. package/dist/{chunk-A5ZNAZ7Q.cjs → chunk-ZX76KVRE.cjs} +13 -13
  102. package/dist/{chunk-A5ZNAZ7Q.cjs.map → chunk-ZX76KVRE.cjs.map} +1 -1
  103. package/dist/collaboration/index.cjs +13 -13
  104. package/dist/connect/docx.cjs +23 -23
  105. package/dist/connect/index.cjs +1046 -1046
  106. package/dist/connect/viewer.cjs +34 -34
  107. package/dist/dashboards/index.cjs +1 -1
  108. package/dist/embed/index.cjs +44 -44
  109. package/dist/facts/index.cjs +43 -43
  110. package/dist/files/index.cjs +227 -227
  111. package/dist/home/index.cjs +31 -31
  112. package/dist/index.cjs +1584 -1584
  113. package/dist/pages/index.cjs +4 -4
  114. package/dist/record/index.cjs +234 -3
  115. package/dist/record/index.cjs.map +1 -1
  116. package/dist/record/index.d.ts +29 -2
  117. package/dist/record/index.js +231 -4
  118. package/dist/record/index.js.map +1 -1
  119. package/dist/record/runs.d.ts +101 -0
  120. package/dist/settings/index.cjs +148 -148
  121. package/dist/shell/index.cjs +87 -87
  122. package/dist/studio/index.cjs +29 -29
  123. package/dist/workflow-canvas/index.cjs +64 -64
  124. package/node_modules/@arbidocs/coedit/package.json +1 -1
  125. package/package.json +7 -5
  126. package/record/SKILL.md +126 -0
  127. package/dist/ai-NC4ZE3UT.cjs.map +0 -1
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkZUYY3JRO_cjs = require('./chunk-ZUYY3JRO.cjs');
5
- var chunkMIYEIACV_cjs = require('./chunk-MIYEIACV.cjs');
6
- var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
4
+ var chunkTBLQCML6_cjs = require('./chunk-TBLQCML6.cjs');
5
+ var chunkYRU6ZJUW_cjs = require('./chunk-YRU6ZJUW.cjs');
7
6
  var chunkM55XUF4L_cjs = require('./chunk-M55XUF4L.cjs');
8
- var chunkJARRHAQW_cjs = require('./chunk-JARRHAQW.cjs');
7
+ var chunk5636X4OX_cjs = require('./chunk-5636X4OX.cjs');
9
8
  var chunkSQCCQU3K_cjs = require('./chunk-SQCCQU3K.cjs');
9
+ var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
10
10
  var chunkVMXTOIXB_cjs = require('./chunk-VMXTOIXB.cjs');
11
11
  var browser = require('@arbidocs/sdk/browser');
12
12
  var react = require('@arbidocs/react');
@@ -49,11 +49,11 @@ function useLaunchWorkflow({
49
49
  } = {}) {
50
50
  const { data: documents = [] } = react.useDocuments();
51
51
  const { data: workspaceTags = [] } = react.useTags();
52
- const tags = react$1.useMemo(() => chunkJARRHAQW_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
52
+ const tags = react$1.useMemo(() => chunk5636X4OX_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
53
53
  const createTag = react.useCreateTag();
54
54
  const updateTag = react.useUpdateTag();
55
55
  const generate = react.useGenerateDocTags();
56
- const { create: createTask } = chunkZUYY3JRO_cjs.useWorkflowTasks();
56
+ const { create: createTask } = chunkTBLQCML6_cjs.useWorkflowTasks();
57
57
  const applyModel = react.useApplyChatModel();
58
58
  const session = react.useArbiSessionStore();
59
59
  const { notify, openFiles, openNewConversation } = chunkVMXTOIXB_cjs.useBlocksEnvironment();
@@ -61,7 +61,7 @@ function useLaunchWorkflow({
61
61
  async ({ inputs, scope }) => {
62
62
  const description = text(inputs, "description");
63
63
  const name = text(inputs, "name") || chunkM55XUF4L_cjs.deriveAnnotationName(description);
64
- const matching = chunkJARRHAQW_cjs.matchWorkflowScope(documents, scope);
64
+ const matching = chunk5636X4OX_cjs.matchWorkflowScope(documents, scope);
65
65
  if (!name || !description || matching.length === 0) return;
66
66
  try {
67
67
  const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase());
@@ -161,7 +161,7 @@ function useLaunchWorkflow({
161
161
  const binding = PROMPT_BINDINGS[workflow.id];
162
162
  const prepare = () => {
163
163
  if (binding?.attachScope !== false && !chunkSQCCQU3K_cjs.isEmptyWorkflowScope(scope)) {
164
- const ids = chunkJARRHAQW_cjs.matchWorkflowScope(documents, scope).map((d) => d.external_id);
164
+ const ids = chunk5636X4OX_cjs.matchWorkflowScope(documents, scope).map((d) => d.external_id);
165
165
  if (ids.length > 0) {
166
166
  session.setConversationDocuments(
167
167
  inPlace ? session.getState().conversationId ?? "new" : "new",
@@ -215,7 +215,7 @@ function ConnectedWorkflowStart({
215
215
  );
216
216
  const { openUpload } = chunkVMXTOIXB_cjs.useBlocksEnvironment();
217
217
  const { data: workspaceTags = [] } = react.useTags();
218
- const tags = react$1.useMemo(() => chunkJARRHAQW_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
218
+ const tags = react$1.useMemo(() => chunk5636X4OX_cjs.documentScopeLabels(workspaceTags), [workspaceTags]);
219
219
  const fieldPlaceholder = react$1.useCallback(
220
220
  (field, inputs, workflow) => {
221
221
  if (workflow.id !== chunkM55XUF4L_cjs.ANNOTATE_ID || field.name !== "name") return void 0;
@@ -225,7 +225,7 @@ function ConnectedWorkflowStart({
225
225
  []
226
226
  );
227
227
  return /* @__PURE__ */ jsxRuntime.jsx(
228
- chunkMIYEIACV_cjs.ConnectedWorkflowLauncher,
228
+ chunkYRU6ZJUW_cjs.ConnectedWorkflowLauncher,
229
229
  {
230
230
  ...rest,
231
231
  workflows,
@@ -265,5 +265,5 @@ function ConnectedWorkflowStart({
265
265
  exports.ConnectedWorkflowStart = ConnectedWorkflowStart;
266
266
  exports.PROMPT_BINDINGS = PROMPT_BINDINGS;
267
267
  exports.useLaunchWorkflow = useLaunchWorkflow;
268
- //# sourceMappingURL=chunk-UHT2Q6IF.cjs.map
269
- //# sourceMappingURL=chunk-UHT2Q6IF.cjs.map
268
+ //# sourceMappingURL=chunk-LW7TDQ63.cjs.map
269
+ //# sourceMappingURL=chunk-LW7TDQ63.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDocumentTitle","composeWorkflowPrompt","isEmptyWorkflowScope","useHost","renderWorkflowIcon","jsx","ConnectedWorkflowLauncher","jsxs","TriangleAlert"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAM,YAAA,GAAe,CAAC,MAAA,KAAqC;AACzD,EAAA,MAAM,QAAQ,MAAA,CAAO,UAAA;AACrB,EAAA,OAAO,KAAA,EAAO,aAAa,EAAC;AAC9B,CAAA;AAEO,IAAM,eAAA,GAAiD;AAAA,EAC5D,CAACA,mCAAiB,GAAG;AAAA,IACnB,WAAA,EAAa,KAAA;AAAA,IACb,KAAA,EAAO,CAAC,MAAA,KAAW;AACjB,MAAA,MAAM,cAAc,OAAO,MAAA,CAAO,YAAA,KAAiB,QAAA,GAAW,OAAO,YAAA,GAAe,EAAA;AACpF,MAAA,OAAO;AAAA,QACL,eAAA,EAAiBC,+BAAA,CAAwB,EAAE,CAAA;AAAA,QAC3C,sBAAA,EAAwBC,qCAAA,CAA8B,YAAA,CAAa,MAAM,CAAC,CAAA;AAAA,QAC1E,GAAI,WAAA,IAAe,WAAA,KAAgBC,mCAAA,GAC/B;AAAA,UACE,gBAAA,EAAkB;AAAA,YAChB,IAAA,EAAM,kBAAA;AAAA,YACN,WAAA,EAAa,kBAAA;AAAA,YAC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AA,EAAK,IAAKF,sCAAA,CAAqB,MAAA,CAAO,MAAA,CAAO,WAAA,IAAe,EAAE,CAAC,CAAA;AAC3F,QAAA,MAAM,QAAA,GAAW,IAAA,GACb,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,CAAK,WAAA,EAAY,KAAM,IAAA,CAAK,WAAA,EAAa,CAAA,GAC5D,MAAA;AACJ,QAAA,IAAI,CAAC,UAAU,OAAO,IAAA;AACtB,QAAA,uBACEW,eAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,mIAAA;AAAA,YACV,IAAA,EAAK,QAAA;AAAA,YACL,aAAA,EAAY,iCAAA;AAAA,YAEZ,QAAA,EAAA;AAAA,8BAAAF,cAAA,CAACG,yBAAA,EAAA,EAAc,WAAU,uCAAA,EAAwC,CAAA;AAAA,8CAChE,MAAA,EAAA,EAAK,QAAA,EAAA;AAAA,gBAAA,uBAAA;AAAA,gCACiBH,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,aAAA,EAAe,mBAAS,IAAA,EAAK,CAAA;AAAA,gBAAO;AAAA,eAAA,EAG3E;AAAA;AAAA;AAAA,SACF;AAAA,MAEJ;AAAA;AAAA,GACF;AAEJ","file":"chunk-UHT2Q6IF.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/workflows/launch-bindings.ts","../src/connection/workflows/useLaunchWorkflow.ts","../src/connection/workflows/ConnectedWorkflowStart.tsx"],"names":["GENERATE_IMAGE_ID","buildRetrievalChunkTool","buildRetrievalFullContextTool","IMAGE_ASPECT_AUTO","useDocuments","useTags","useMemo","documentScopeLabels","useCreateTag","useUpdateTag","useGenerateDocTags","useWorkflowTasks","useApplyChatModel","useArbiSessionStore","useBlocksEnvironment","useCallback","deriveAnnotationName","matchWorkflowScope","ANNOTATE_ID","recordWorkflowUse","getDocumentTitle","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AAA,EAAA;AAAA,8BAAAF,cAAA,CAACG,yBAAA,EAAA,EAAc,WAAU,uCAAA,EAAwC,CAAA;AAAA,8CAChE,MAAA,EAAA,EAAK,QAAA,EAAA;AAAA,gBAAA,uBAAA;AAAA,gCACiBH,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,aAAA,EAAe,mBAAS,IAAA,EAAK,CAAA;AAAA,gBAAO;AAAA,eAAA,EAG3E;AAAA;AAAA;AAAA,SACF;AAAA,MAEJ;AAAA;AAAA,GACF;AAEJ","file":"chunk-LW7TDQ63.cjs","sourcesContent":["/**\n * Host bindings of prompt workflows that need more than words on send. Bound by workflow id, the\n * same way the annotation operation is: blocks and the registry stay declarative, and the one\n * place that knows the wire shape is here.\n *\n * Generate image: the reference images and the aspect ratio ride structured tool arguments\n * (`retrieval_full_context` over every reference, `image_generation.aspect_ratio`), never the\n * prompt text: the image model does not reliably honour a shape or sources worded into the prompt,\n * and the references go to the separate image model in its own request, so (unlike the app's\n * one-at-a-time pinned document) several of them do not compound against the agent's context.\n */\n\nimport type { WorkflowInputs, WorkflowScope } from '../../agents/workflows/types'\nimport { buildRetrievalChunkTool, buildRetrievalFullContextTool } from '@arbidocs/sdk/browser'\nimport type { TurnTools } from '@arbidocs/react'\nimport { GENERATE_IMAGE_ID, IMAGE_ASPECT_AUTO } from '../../agents/workflows/catalogue/seed'\n\nexport interface PromptBinding {\n /** Attach the scoped files to the chat (default true). Off when the files are tool inputs. */\n attachScope: boolean\n /** Structured tools for the one send, from the form's inputs. */\n tools?: (inputs: WorkflowInputs) => TurnTools\n}\n\nconst referencesOf = (inputs: WorkflowInputs): string[] => {\n const value = inputs.references as WorkflowScope | undefined\n return value?.documents ?? []\n}\n\nexport const PROMPT_BINDINGS: Record<string, PromptBinding> = {\n [GENERATE_IMAGE_ID]: {\n attachScope: false,\n tools: (inputs) => {\n const aspectRatio = typeof inputs.aspect_ratio === 'string' ? inputs.aspect_ratio : ''\n return {\n retrieval_chunk: buildRetrievalChunkTool([]),\n retrieval_full_context: buildRetrievalFullContextTool(referencesOf(inputs)),\n ...(aspectRatio && aspectRatio !== IMAGE_ASPECT_AUTO\n ? {\n image_generation: {\n name: 'image_generation' as const,\n description: 'image generation',\n tool_args: { aspect_ratio: aspectRatio },\n tool_responses: {},\n },\n }\n : {}),\n }\n },\n },\n}\n","/**\n * The host side of the launch contract: `onLaunch({workflow, inputs, scope, agentId})`.\n *\n * Blocks only say WHAT to run; this performs it, so workspace isolation stays host-side:\n *\n * - prompt workflow, my assistant: open a fresh chat (or stay in this one when `inPlace`), scope\n * its documents, set the composed draft and ask for it to be sent (`autoSendDraft`). The host's\n * send waits for the new chat's documents to be seeded, so a scoped run is never sent with the\n * wrong files. Order matters: `openNewConversation` resets the draft, so it is set after it.\n * - prompt workflow, another agent: a run-now task assigned to that agent (the interactive chat\n * query has no agent parameter), created through the same path as the task composer.\n * - operation workflow (tier B): the handler bound to its id (annotation).\n * - a workflow's own model becomes the chat's (`useApplyChatModel`).\n *\n * The prompt is composed in exactly one place: `composeWorkflowPrompt(workflow, inputs)`.\n */\n\nimport {\n useApplyChatModel,\n useArbiSessionStore,\n useCreateTag,\n useDocuments,\n useGenerateDocTags,\n useTags,\n useUpdateTag,\n} from '@arbidocs/react'\nimport { getDocumentTitle } from '@arbidocs/react/ui'\nimport { useCallback, useMemo } from 'react'\nimport { composeWorkflowPrompt, isEmptyWorkflowScope } from '../../agents/workflows/workflow'\nimport { documentScopeLabels, matchWorkflowScope } from '../../agents/workflows/workspaceScope'\nimport {\n type WorkflowInputs,\n type WorkflowLanding,\n type WorkflowLaunch,\n} from '../../agents/workflows/types'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { PROMPT_BINDINGS } from './launch-bindings'\nimport { ANNOTATE_ID } from '../../agents/workflows/catalogue/seed'\nimport { useWorkflowTasks } from './useWorkflowTasks'\nimport { recordWorkflowUse } from '../../agents/workflows/catalogue/workflow-usage'\n\nexport interface UseLaunchWorkflowOptions {\n /**\n * Where launches from this surface land, over each workflow's own default. The empty chat and\n * the slash menu send into the conversation on screen (`current-chat`); everything else opens a\n * fresh one. A single launch can still override it (`WorkflowLaunch.landing`).\n */\n landing?: WorkflowLanding\n /**\n * A prompt run on the user's own assistant is sent here instead of through the session's draft:\n * the surface's own chat (`ChatPage`) or its own ask (the document ask). Everything else is the\n * same: the file scope, the workflow's model and its bound tools are set on the session in scope\n * (before a send in place, after a send that opens a fresh chat), so the turn carries them.\n */\n send?: (prompt: string) => void\n}\n\nconst text = (inputs: WorkflowInputs, name: string): string => {\n const v = inputs[name]\n return typeof v === 'string' ? v.trim() : ''\n}\n\nexport function useLaunchWorkflow({\n landing: surfaceLanding,\n send,\n}: UseLaunchWorkflowOptions = {}) {\n const { data: documents = [] } = useDocuments()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n const createTag = useCreateTag()\n const updateTag = useUpdateTag()\n const generate = useGenerateDocTags()\n const { create: createTask } = useWorkflowTasks()\n const applyModel = useApplyChatModel()\n const session = useArbiSessionStore()\n const { notify, openFiles, openNewConversation } = useBlocksEnvironment()\n\n /** Annotation: create (or reuse) the label, start the AI run, land on Files filtered to the set. */\n const annotate = useCallback(\n async ({ inputs, scope }: WorkflowLaunch) => {\n const description = text(inputs, 'description')\n const name = text(inputs, 'name') || deriveAnnotationName(description)\n const matching = matchWorkflowScope(documents, scope)\n if (!name || !description || matching.length === 0) return\n try {\n // A same-named label is reused rather than duplicated, the rule the Files page's\n // label-creation paths follow.\n const existing = tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n let tagId: string\n if (existing) {\n tagId = existing.external_id\n await updateTag.mutateAsync({\n tagId: tagId,\n change: { instruction: description },\n })\n } else {\n const created = await createTag.mutateAsync({\n name,\n tagType: { type: 'text', options: [] },\n shared: true,\n instruction: description,\n })\n const createdId = (created as { external_id?: string } | undefined)?.external_id\n if (!createdId) throw new Error('tag create returned no id')\n tagId = createdId\n }\n const docIds = matching.map((d) => d.external_id)\n // overwrite=true so a re-run on an existing field refreshes stale values, matching the\n // Files page's default review behaviour.\n await generate.mutateAsync({ tagIds: [tagId], docIds: docIds, overwrite: true })\n // Land on Files with those documents selected and the view narrowed to the annotated set\n // through the same tri-state quick filter the pickers write to. An empty scope selected\n // every file, so no filter is applied.\n const filters: Record<string, 'include'> = {}\n scope.folders.forEach((folder) => {\n filters[folder === '' ? 'folder:none' : `folder:${folder}`] = 'include'\n })\n scope.labels.forEach((labelId) => {\n filters[labelId] = 'include'\n })\n openFiles({ select: docIds, filters })\n } catch (error) {\n notify('Could not start the annotation', 'error')\n throw error\n }\n },\n [documents, tags, createTag, updateTag, generate, openFiles, notify]\n )\n\n return useCallback(\n async (launch: WorkflowLaunch) => {\n const { workflow, inputs, scope, agentId } = launch\n if (workflow.run.kind === 'operation') {\n if (workflow.id === ANNOTATE_ID) {\n await annotate(launch)\n recordWorkflowUse(workflow.id)\n return\n }\n throw new Error(`No host handler for workflow \"${workflow.id}\"`)\n }\n\n // Names for the wording: a `documents` field quotes the files it picked.\n const documentTitles = Object.fromEntries(\n documents.map((d) => [d.external_id, getDocumentTitle(d, d.external_id)])\n )\n const prompt = composeWorkflowPrompt(workflow, inputs, { documentTitles })\n if (!prompt) return\n recordWorkflowUse(workflow.id)\n\n if (agentId) {\n try {\n const created = await createTask({\n workflow,\n values: {\n assignee: 'agent',\n workflowId: workflow.id,\n inputs,\n when: 'now',\n runAt: '',\n rrule: '',\n timezone: 'UTC',\n eventKind: '',\n afterTaskId: '',\n parentTaskId: '',\n shared: true,\n description: '',\n dueAt: '',\n agentId,\n name: '',\n notifyOnComplete: true,\n access: 'ask_each_run',\n },\n })\n const ran = created.kind === 'work' ? created.ran : null\n const title = created.kind === 'work' ? created.task.title : created.workflow.name\n notify(\n ran === false\n ? 'Task created, but the run could not start'\n : `Running \\u201c${title ?? workflow.title}\\u201d`,\n ran === false ? 'warning' : 'success'\n )\n } catch (error) {\n notify(\n error instanceof Error && error.message.startsWith('Open a workspace')\n ? error.message\n : 'Could not start the run',\n 'error'\n )\n throw error\n }\n return\n }\n\n const landing = launch.landing ?? surfaceLanding ?? workflow.landing\n const inPlace = landing === 'current-chat'\n const binding = PROMPT_BINDINGS[workflow.id]\n /** The run's setup on the session in scope: its file scope, its model, its bound tools. */\n const prepare = () => {\n // Scope the chat to the chosen files when a restriction was made; otherwise the\n // workspace's usual \"all documents\" attachment (useDocumentAutoAdd) applies.\n if (binding?.attachScope !== false && !isEmptyWorkflowScope(scope)) {\n const ids = matchWorkflowScope(documents, scope).map((d) => d.external_id)\n if (ids.length > 0) {\n session.setConversationDocuments(\n inPlace ? (session.getState().conversationId ?? 'new') : 'new',\n ids.map((docId) => ({ docId, isPinned: false }))\n )\n }\n }\n if (workflow.model) void applyModel(workflow.model, `Workflow - ${workflow.title}`)\n // The tools ride the next send of the session in scope.\n session.setPendingTools(binding?.tools?.(inputs) ?? null)\n }\n // A fresh chat's reset clears the draft and the model, so the setup follows it. A surface\n // with its own send sends in its chat (set up first) or opens a fresh one (set up after).\n if (send) {\n if (inPlace) prepare()\n send(prompt)\n if (!inPlace) prepare()\n return\n }\n if (!inPlace) openNewConversation()\n prepare()\n session.setDraft(prompt)\n session.setAutoSendDraft(true)\n },\n [\n annotate,\n applyModel,\n createTask,\n documents,\n surfaceLanding,\n session,\n notify,\n openNewConversation,\n send,\n ]\n )\n}\n","/**\n * The workflow launcher, wired to run what it launches: `ConnectedWorkflowLauncher` (the\n * workspace's files behind scope and file fields, the user's agents behind \"Run as\") with the one\n * launch handler (`useLaunchWorkflow`), the host's upload dialog for adding files\n * (`environment.openUpload`), and the touches of the annotation operation (its derived name and\n * overwrite warning, \"Annotate N documents\").\n *\n * The dashboard's Start band, Files (\"Create new\") and, headless, the slash menu use it.\n */\n\nimport { useTags } from '@arbidocs/react'\nimport { useCallback, useMemo, type ReactNode } from 'react'\nimport { TriangleAlert } from 'lucide-react'\nimport { documentScopeLabels } from '../../agents/workflows/workspaceScope'\nimport {\n type OnWorkflowLaunch,\n type WorkflowDefinition,\n type WorkflowField,\n type WorkflowInputs,\n type WorkflowLanding,\n} from '../../agents/workflows/types'\nimport { ConnectedWorkflowLauncher } from '../ConnectedWorkflowLauncher'\nimport { type StartTile } from '../../home/StartTiles'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useHost } from '../../provider/host'\nimport { deriveAnnotationName } from '../../agents/workflows/catalogue/annotation-name'\nimport { ANNOTATE_ID, renderWorkflowIcon } from '../../agents/workflows/catalogue/seed'\nimport { useLaunchWorkflow } from './useLaunchWorkflow'\n\n// The agent picker names the person it hands the work to: the default \"Run as\" / \"My assistant\"\n// copy did not say who an assistant is.\nconst AGENT_LABELS = { label: 'Who this runs for', myAssistant: 'Me (your own assistant)' }\n\nexport interface ConnectedWorkflowStartProps {\n workflows: WorkflowDefinition[]\n /** Which of `workflows` get a tile (a filtered or capped view). */\n tileWorkflows?: WorkflowDefinition[]\n /** Render the Start band (off when another surface opens the dialog). */\n showTiles?: boolean\n caption?: string\n captionTestId?: string\n testId?: string\n /** Plain tiles appended to the band (e.g. the \"Create a file\" menu). */\n extraTiles?: StartTile[]\n /** Controlled open workflow id. */\n activeId?: string | null\n onActiveIdChange?: (id: string | null) => void\n initialInputsFor?: (workflow: WorkflowDefinition) => Partial<WorkflowInputs> | undefined\n /** Where launches land, over each workflow's default (`current-chat` = the chat on screen). */\n landing?: WorkflowLanding\n /** A prompt run's own send (a chat that is not the session's conversation). See `useLaunchWorkflow`. */\n send?: (prompt: string) => void\n /**\n * Run a launch here instead of the usual way (`useLaunchWorkflow`): a surface that wants the\n * result itself, e.g. the presentation, which adds a generated image to its clips. The dialog\n * shows it running until it resolves, closes then, and stays open if it throws.\n */\n onLaunch?: OnWorkflowLaunch\n /**\n * Files added from a `documents` field are uploaded right in the field instead of through the\n * host's upload dialog: for a dialog in a popped-out window, where the host's dialog would open\n * in the app's window, out of sight, and block this one.\n */\n uploadInPlace?: boolean\n /** The host's own \"Add\" control, offered when a workflow needs files and there are none. */\n addFilesAction?: ReactNode\n tileTestId?: (workflow: WorkflowDefinition) => string | undefined\n disabledReason?: (workflow: WorkflowDefinition) => string | undefined\n}\n\nexport function ConnectedWorkflowStart({\n workflows,\n landing,\n send,\n addFilesAction,\n onLaunch: launchHere,\n uploadInPlace = false,\n ...rest\n}: ConnectedWorkflowStartProps) {\n const launchUsually = useLaunchWorkflow({ landing, send })\n const onLaunch = launchHere ?? launchUsually\n // The host's icons first (a skill pack names its own), then the kit's, then the skill icon.\n const hostIcon = useHost().workflows?.renderIcon\n const renderIcon = useCallback(\n (key: string) => hostIcon?.(key) ?? renderWorkflowIcon(key) ?? renderWorkflowIcon('skill'),\n [hostIcon]\n )\n const { openUpload } = useBlocksEnvironment()\n const { data: workspaceTags = [] } = useTags()\n const tags = useMemo(() => documentScopeLabels(workspaceTags), [workspaceTags])\n\n // The annotation's name is optional: left blank it is taken from the question, which the\n // field's placeholder shows before anything runs.\n const fieldPlaceholder = useCallback(\n (field: WorkflowField, inputs: WorkflowInputs, workflow: WorkflowDefinition) => {\n if (workflow.id !== ANNOTATE_ID || field.name !== 'name') return undefined\n const derived = deriveAnnotationName(String(inputs.description ?? ''))\n return derived ? `Otherwise “${derived}”` : 'Taken from the description'\n },\n []\n )\n\n return (\n <ConnectedWorkflowLauncher\n {...rest}\n workflows={workflows}\n onLaunch={onLaunch}\n renderIcon={renderIcon}\n onAddFiles={uploadInPlace ? undefined : openUpload}\n agentLabels={AGENT_LABELS}\n addFilesAction={addFilesAction}\n fieldPlaceholder={fieldPlaceholder}\n submitLabel={({ workflow, matchedCount }) =>\n workflow.id === ANNOTATE_ID && matchedCount !== null\n ? `Annotate ${matchedCount} document${matchedCount !== 1 ? 's' : ''}`\n : undefined\n }\n renderNotice={({ workflow, inputs }) => {\n if (workflow.id !== ANNOTATE_ID) return null\n // A same-named label is reused: warn that this overwrites its stored description and the\n // cell values for the selected documents.\n const name =\n String(inputs.name ?? '').trim() || deriveAnnotationName(String(inputs.description ?? ''))\n const existing = name\n ? tags.find((t) => t.name.toLowerCase() === name.toLowerCase())\n : undefined\n if (!existing) return null\n return (\n <div\n className=\"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200\"\n role=\"status\"\n data-testid=\"workflow-existing-label-warning\"\n >\n <TriangleAlert className=\"mt-0.5 size-4 shrink-0 text-amber-500\" />\n <span>\n An annotation called <span className=\"font-medium\">{existing.name}</span> already\n exists. Annotating will overwrite its description and the current cell values for the\n selected files.\n </span>\n </div>\n )\n }}\n />\n )\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkZLJP6447_cjs = require('./chunk-ZLJP6447.cjs');
4
+ var chunk2XIENKEI_cjs = require('./chunk-2XIENKEI.cjs');
5
5
  var chunkY3GJBLAI_cjs = require('./chunk-Y3GJBLAI.cjs');
6
6
  var react = require('react');
7
7
 
@@ -45,7 +45,7 @@ function useWorkflowPreview(workflow, { answer = "{prompt}", delayMs = 400, reso
45
45
  }, delayMs)
46
46
  );
47
47
  }, [states, steps, workflow]);
48
- return chunkZLJP6447_cjs.useWorkflowView({
48
+ return chunk2XIENKEI_cjs.useWorkflowView({
49
49
  steps,
50
50
  states,
51
51
  inputs,
@@ -58,5 +58,5 @@ function useWorkflowPreview(workflow, { answer = "{prompt}", delayMs = 400, reso
58
58
  }
59
59
 
60
60
  exports.useWorkflowPreview = useWorkflowPreview;
61
- //# sourceMappingURL=chunk-5QEPUONH.cjs.map
62
- //# sourceMappingURL=chunk-5QEPUONH.cjs.map
61
+ //# sourceMappingURL=chunk-M53KQLFA.cjs.map
62
+ //# sourceMappingURL=chunk-M53KQLFA.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/agents/workflows/useWorkflowPreview.ts"],"names":["workflowSteps","useState","initialRunInputs","useRef","useEffect","stepPhase","composeSt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,OAAOC,iCAAA,CAAgB;AAAA,IACrB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU,CAAC,IAAA,EAAM,KAAA,KAAU,UAAU,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,IAAI,GAAG,OAAM,CAAE,CAAA;AAAA,IACrE,QAAA,EAAU,OAAO,IAAA,KAAS,GAAA,CAAI,KAAK,EAAA,EAAI,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACzD,IAAA,EAAM,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IACjD,KAAA,EAAO,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IAClD,UAAU,CAAC,EAAA,KAAO,MAAA,CAAO,EAAE,GAAG,MAAA,KAAW;AAAA,GAC1C,CAAA;AACH","file":"chunk-5QEPUONH.cjs","sourcesContent":["/**\n * A stepped workflow run on screen only (the builder's preview): agent steps run one at a time,\n * the way the server does, and answer with the prompt they would send; action steps just finish.\n * No thread, no agent.\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport {\n composeStepPrompt,\n initialRunInputs,\n stepPhase,\n workflowSteps,\n type StepComposeOptions,\n} from './run'\nimport type { WorkflowDefinition, WorkflowInputs, WorkflowStepState } from './types'\nimport { useWorkflowView, type WorkflowRunView } from './useWorkflowView'\n\nexport interface UseWorkflowPreviewOptions extends StepComposeOptions {\n /** What a stand-in agent step answers; `{prompt}` is replaced with the prompt it would send. */\n answer?: string\n /** How long a stand-in step takes. */\n delayMs?: number\n}\n\nexport function useWorkflowPreview(\n workflow: WorkflowDefinition,\n { answer = '{prompt}', delayMs = 400, resolveWorkflow, compose }: UseWorkflowPreviewOptions = {}\n): WorkflowRunView {\n const steps = workflowSteps(workflow)\n const [inputs, setInputs] = useState<WorkflowInputs>(() => initialRunInputs(workflow))\n const [states, setStates] = useState<Record<string, WorkflowStepState>>({})\n const set = (id: string, state: WorkflowStepState) => setStates((s) => ({ ...s, [id]: state }))\n\n // A stand-in step's timer outlives the re-render its start causes; it is cleared on unmount, and\n // a step it cut short starts again (StrictMode mounts twice).\n const timers = useRef(new Map<string, ReturnType<typeof setTimeout>>())\n useEffect(() => {\n const pending = timers.current\n return () => {\n for (const t of pending.values()) clearTimeout(t)\n pending.clear()\n setStates((s) =>\n Object.fromEntries(\n Object.entries(s).map(([id, v]) => [\n id,\n v.status === 'running' ? { status: 'pending' } : v,\n ])\n )\n )\n }\n }, [])\n\n // One turn at a time: start the first ready agent step when nothing is running.\n useEffect(() => {\n if (Object.values(states).some((s) => s.status === 'running')) return\n // An action step (a signature, an email, a review) stands in the same way, with no answer.\n const next = steps.find(\n (s) =>\n (s.kind === 'agent' || s.kind === 'action') && stepPhase(steps, states, s.id) === 'ready'\n )\n if (!next || (next.kind !== 'agent' && next.kind !== 'action')) return\n const prompt =\n next.kind === 'agent'\n ? composeStepPrompt(workflow, next, inputs, { resolveWorkflow, compose })\n : ''\n set(next.id, { status: 'running', startedAt: new Date().toISOString() })\n timers.current.set(\n next.id,\n setTimeout(() => {\n timers.current.delete(next.id)\n set(\n next.id,\n next.kind === 'agent'\n ? { status: 'done', text: answer.replace('{prompt}', prompt) }\n : { status: 'done' }\n )\n }, delayMs)\n )\n // `inputs` are read when a step starts, not watched.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [states, steps, workflow])\n\n return useWorkflowView({\n steps,\n states,\n inputs,\n setInput: (name, value) => setInputs((i) => ({ ...i, [name]: value })),\n complete: async (step) => set(step.id, { status: 'done' }),\n skip: async (id) => set(id, { status: 'skipped' }),\n retry: async (id) => set(id, { status: 'pending' }),\n isLocked: (id) => states[id]?.status === 'done',\n })\n}\n"]}
1
+ {"version":3,"sources":["../src/agents/workflows/useWorkflowPreview.ts"],"names":["workflowSteps","useState","initialRunInputs","useRef","useEffect","stepPhase","composeStepPrompt","useW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CAAA,CAAgB;AAAA,IACrB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU,CAAC,IAAA,EAAM,KAAA,KAAU,UAAU,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,IAAI,GAAG,OAAM,CAAE,CAAA;AAAA,IACrE,QAAA,EAAU,OAAO,IAAA,KAAS,GAAA,CAAI,KAAK,EAAA,EAAI,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAAA,IACzD,IAAA,EAAM,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IACjD,KAAA,EAAO,OAAO,EAAA,KAAO,GAAA,CAAI,IAAI,EAAE,MAAA,EAAQ,WAAW,CAAA;AAAA,IAClD,UAAU,CAAC,EAAA,KAAO,MAAA,CAAO,EAAE,GAAG,MAAA,KAAW;AAAA,GAC1C,CAAA;AACH","file":"chunk-M53KQLFA.cjs","sourcesContent":["/**\n * A stepped workflow run on screen only (the builder's preview): agent steps run one at a time,\n * the way the server does, and answer with the prompt they would send; action steps just finish.\n * No thread, no agent.\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport {\n composeStepPrompt,\n initialRunInputs,\n stepPhase,\n workflowSteps,\n type StepComposeOptions,\n} from './run'\nimport type { WorkflowDefinition, WorkflowInputs, WorkflowStepState } from './types'\nimport { useWorkflowView, type WorkflowRunView } from './useWorkflowView'\n\nexport interface UseWorkflowPreviewOptions extends StepComposeOptions {\n /** What a stand-in agent step answers; `{prompt}` is replaced with the prompt it would send. */\n answer?: string\n /** How long a stand-in step takes. */\n delayMs?: number\n}\n\nexport function useWorkflowPreview(\n workflow: WorkflowDefinition,\n { answer = '{prompt}', delayMs = 400, resolveWorkflow, compose }: UseWorkflowPreviewOptions = {}\n): WorkflowRunView {\n const steps = workflowSteps(workflow)\n const [inputs, setInputs] = useState<WorkflowInputs>(() => initialRunInputs(workflow))\n const [states, setStates] = useState<Record<string, WorkflowStepState>>({})\n const set = (id: string, state: WorkflowStepState) => setStates((s) => ({ ...s, [id]: state }))\n\n // A stand-in step's timer outlives the re-render its start causes; it is cleared on unmount, and\n // a step it cut short starts again (StrictMode mounts twice).\n const timers = useRef(new Map<string, ReturnType<typeof setTimeout>>())\n useEffect(() => {\n const pending = timers.current\n return () => {\n for (const t of pending.values()) clearTimeout(t)\n pending.clear()\n setStates((s) =>\n Object.fromEntries(\n Object.entries(s).map(([id, v]) => [\n id,\n v.status === 'running' ? { status: 'pending' } : v,\n ])\n )\n )\n }\n }, [])\n\n // One turn at a time: start the first ready agent step when nothing is running.\n useEffect(() => {\n if (Object.values(states).some((s) => s.status === 'running')) return\n // An action step (a signature, an email, a review) stands in the same way, with no answer.\n const next = steps.find(\n (s) =>\n (s.kind === 'agent' || s.kind === 'action') && stepPhase(steps, states, s.id) === 'ready'\n )\n if (!next || (next.kind !== 'agent' && next.kind !== 'action')) return\n const prompt =\n next.kind === 'agent'\n ? composeStepPrompt(workflow, next, inputs, { resolveWorkflow, compose })\n : ''\n set(next.id, { status: 'running', startedAt: new Date().toISOString() })\n timers.current.set(\n next.id,\n setTimeout(() => {\n timers.current.delete(next.id)\n set(\n next.id,\n next.kind === 'agent'\n ? { status: 'done', text: answer.replace('{prompt}', prompt) }\n : { status: 'done' }\n )\n }, delayMs)\n )\n // `inputs` are read when a step starts, not watched.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [states, steps, workflow])\n\n return useWorkflowView({\n steps,\n states,\n inputs,\n setInput: (name, value) => setInputs((i) => ({ ...i, [name]: value })),\n complete: async (step) => set(step.id, { status: 'done' }),\n skip: async (id) => set(id, { status: 'skipped' }),\n retry: async (id) => set(id, { status: 'pending' }),\n isLocked: (id) => states[id]?.status === 'done',\n })\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkGAVQFR6P_cjs = require('./chunk-GAVQFR6P.cjs');
5
4
  var chunkKQF7POTG_cjs = require('./chunk-KQF7POTG.cjs');
5
+ var chunkGAVQFR6P_cjs = require('./chunk-GAVQFR6P.cjs');
6
6
  var chunkPLIF5CUV_cjs = require('./chunk-PLIF5CUV.cjs');
7
7
  var lucideReact = require('lucide-react');
8
8
  var ui = require('@arbidocs/react/ui');
@@ -555,5 +555,5 @@ exports.prefetchChunk = prefetchChunk;
555
555
  exports.requestReload = requestReload;
556
556
  exports.workspaceKindColor = workspaceKindColor;
557
557
  exports.workspaceKindMeta = workspaceKindMeta;
558
- //# sourceMappingURL=chunk-GPP7E3OQ.cjs.map
559
- //# sourceMappingURL=chunk-GPP7E3OQ.cjs.map
558
+ //# sourceMappingURL=chunk-N2IQSGYU.cjs.map
559
+ //# sourceMappingURL=chunk-N2IQSGYU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shell/Workspace.tsx","../src/shell/MobileBars.tsx","../src/shell/reload-policy.ts"],"names":["Globe","Users","Lock","jsxs","jsx","testIdOr","cn","Fragment","DropdownMenu","DropdownMenuTrigger","ChevronDown","DropdownMenuContent","DropdownMenuItem","LayoutGrid","Plus","DropdownMenuSeparator","DropdownMenuLabel","prefixedTestId","Menu","useRef","useShellBottomInset","ActionLink","notify"],"mappings":";;;;;;;;;;;AAqBO,IAAM,6BAAA,GAAqD;AAAA,EAChE,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS;AACX;AAQO,SAAS,iBAAA,CACd,MACA,MAAA,EAKA;AACA,EAAA,MAAM,CAAA,GAAI,EAAE,GAAG,6BAAA,EAA+B,GAAG,MAAA,EAAO;AACxD,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAAE,IAAA,EAAMA,iBAAA,EAAO,OAAO,CAAA,CAAE,MAAA,EAAQ,MAAM,gCAAA,EAAiC;AAChF,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAAE,IAAA,EAAMC,iBAAA,E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AA,KAAW,WAAA,EAAa;AAChD,EAAA,SAAA,GAAY,IAAA;AACZ,EAAA,YAAA,GAAe,KAAK,GAAA,EAAI;AACxB,EAAA,MAAA,CAAO,gBAAA,CAAiB,qBAAqB,oBAAoB,CAAA;AACjE,EAAA,KAAA,MAAW,QAAQ,eAAA,EAAiB;AAClC,IAAA,QAAA,CAAS,gBAAA,CAAiB,MAAM,UAAA,EAAY,EAAE,SAAS,IAAA,EAAM,OAAA,EAAS,MAAM,CAAA;AAAA,EAC9E;AACF","file":"chunk-GPP7E3OQ.cjs","sourcesContent":["import type { ComponentType } from 'react'\nimport { ChevronDown, Globe, LayoutGrid, Lock, Plus, Users } from 'lucide-react'\nimport {\n cn,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '@arbidocs/react/ui'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport type { ShellRecentWorkspace, ShellWorkspace, ShellWorkspaceKind } from './types'\n\n/** The three workspace-kind names (badge title, type glyph name, subtitle). */\nexport interface WorkspaceKindLabels {\n common: string\n shared: string\n private: string\n}\n\nexport const DEFAULT_WORKSPACE_KIND_LABELS: WorkspaceKindLabels = {\n common: 'Common',\n shared: 'Shared',\n private: 'Private',\n}\n\n/**\n * Workspace type drives the initial-badge fill and a quiet secondary glyph:\n * private (just you) -> navy, lock shared (several) -> selection tint, people\n * common (public) -> neutral, globe\n * Navy is identity and cyan is reserved for ARBI/AI, so \"shared\" is the selection tint.\n */\nexport function workspaceKindMeta(\n kind: ShellWorkspaceKind,\n labels?: Partial<WorkspaceKindLabels>\n): {\n Icon: ComponentType<{ className?: string; 'aria-label'?: string; 'data-testid'?: string }>\n label: string\n fill: string\n} {\n const l = { ...DEFAULT_WORKSPACE_KIND_LABELS, ...labels }\n if (kind === 'common')\n return { Icon: Globe, label: l.common, fill: 'bg-muted text-muted-foreground' }\n if (kind === 'shared')\n return { Icon: Users, label: l.shared, fill: 'bg-secondary text-secondary-foreground' }\n return { Icon: Lock, label: l.private, fill: 'bg-primary text-primary-foreground' }\n}\n\n/** The kind's hue as a CSS colour, for glyphs painted by SVG fill (the workspace shield). */\nexport function workspaceKindColor(kind: ShellWorkspaceKind): string {\n if (kind === 'common') return 'var(--color-muted-foreground)'\n if (kind === 'shared') return 'var(--color-secondary)'\n return 'var(--color-primary)'\n}\n\n/** Overridable ids of the workspace identity; defaults are the current ids. */\ntype WorkspaceIdentityTestIds = Partial<Record<'initial' | 'type' | 'projectName', string>>\n\nexport interface WorkspaceIdentityProps {\n workspace: ShellWorkspace\n /** Show name + type/project line beside the badge; otherwise the badge alone. */\n expanded: boolean\n /** Selected (nav-row) styling of the name. */\n isActive?: boolean\n /** Reword the kind names. */\n labels?: Partial<WorkspaceKindLabels>\n /** Part ids; defaults are the current ids. */\n testIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * Non-interactive guts of the workspace head: the initial badge (with a tiny type glyph) and,\n * when expanded, the name and the project/type line. Hosted by the switcher trigger and by the\n * workspace settings header, so it never nests a button.\n */\nexport function WorkspaceIdentity({\n workspace,\n expanded,\n isActive = false,\n labels,\n testIds,\n}: WorkspaceIdentityProps) {\n const kind = workspaceKindMeta(workspace.kind, labels)\n const badge = (\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n data-testid={testIdOr(testIds?.initial, { testId: 'sidebar-workspace-card-initial' })}\n className={cn(\n 'flex size-7 flex-shrink-0 items-center justify-center rounded-md text-sm font-semibold leading-none',\n kind.fill\n )}\n >\n {workspace.name.charAt(0).toUpperCase()}\n </span>\n {/* Type as a tiny overlay on the badge: status reads at the icon, not after the name. */}\n <span className=\"absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={testIdOr(testIds?.type, { testId: 'sidebar-workspace-card-type' })}\n className=\"size-2.5 text-muted-foreground\"\n />\n </span>\n </span>\n )\n\n if (!expanded)\n return <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n\n return (\n <>\n <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n <div className=\"ml-2.5 flex min-w-0 flex-1 flex-col text-left\">\n <span\n // 600: the name of the thing you are inside, above a lighter project line.\n className={cn(\n 'min-w-0 truncate text-left text-sm font-semibold capitalize leading-tight transition-colors duration-100',\n isActive ? 'text-accent-foreground' : 'text-foreground'\n )}\n >\n {workspace.name}\n </span>\n {!workspace.projectName && (\n <span className=\"mt-0.5 truncate text-xs text-muted-foreground\">{kind.label}</span>\n )}\n {workspace.projectName && (\n <span\n className=\"mt-0.5 flex min-w-0\"\n data-testid={testIdOr(testIds?.projectName, {\n testId: 'sidebar-workspace-card-project-name',\n })}\n >\n {workspace.projectLine ?? (\n <span className=\"truncate text-xs text-muted-foreground\">\n {workspace.projectName}\n </span>\n )}\n </span>\n )}\n </div>\n </>\n )\n}\n\n/**\n * Entity nouns plus the switcher's strings. `plural` arrives lowercased and `singular`\n * capitalized in the functions below.\n */\nexport interface WorkspaceSwitcherLabels extends WorkspaceKindLabels {\n /** Entity nouns, e.g. { plural: 'workspaces', singular: 'workspace' }. */\n plural: string\n singular: string\n /** The trigger's accessible name. */\n switchWorkspace: (name: string, plural: string) => string\n allWorkspaces: (plural: string) => string\n newWorkspace: (singular: string) => string\n recentWorkspaces: (plural: string) => string\n}\n\nexport const DEFAULT_WORKSPACE_SWITCHER_LABELS: WorkspaceSwitcherLabels = {\n ...DEFAULT_WORKSPACE_KIND_LABELS,\n plural: 'workspaces',\n singular: 'workspace',\n switchWorkspace: (name, plural) => `${name} — switch ${plural}`,\n allWorkspaces: (plural) => `All ${plural}`,\n newWorkspace: (singular) => `New ${singular}`,\n recentWorkspaces: (plural) => `Recent ${plural}`,\n}\n\nexport interface WorkspaceSwitcherProps {\n workspace: ShellWorkspace\n /** Other workspaces to jump to (the app orders and caps them). */\n recent?: ShellRecentWorkspace[]\n /** Icon-only trigger (the sidebar rail). */\n compact?: boolean\n /** `appbar`: the phone app bar's title, name + chevron on one line. */\n variant?: 'sidebar' | 'appbar'\n onSwitch: (workspace: ShellWorkspace) => void\n /** Return to the workspaces list; leaves the workspace open. */\n onGoToList: () => void\n onNewWorkspace: () => void\n /**\n * When set, \"New workspace\" is shown disabled with this explanation under it (e.g. the user may\n * not create workspaces on this deployment).\n */\n newWorkspaceDisabledReason?: string\n /** Entity nouns and menu strings; any subset (the nouns default to workspace(s)). */\n labels?: Partial<WorkspaceSwitcherLabels>\n className?: string\n /** Trigger id (default `workspace-switcher-trigger`). */\n testId?: string\n /**\n * Part ids; defaults are the current ids. `switchItem`, `type` and `lastSeen` are prefixes\n * (`<prefix>-<workspace id>`).\n */\n testIds?: Partial<Record<'menu' | 'all' | 'new' | 'switchItem' | 'type' | 'lastSeen', string>>\n /** Ids forwarded to the trigger's workspace identity. */\n identityTestIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * The current-workspace control as a dropdown: \"All workspaces\", \"New workspace\", then the\n * recent workspaces to jump straight into.\n */\nexport function WorkspaceSwitcher({\n workspace,\n recent = [],\n compact = false,\n variant = 'sidebar',\n onSwitch,\n onGoToList,\n onNewWorkspace,\n newWorkspaceDisabledReason,\n labels,\n className,\n testId,\n testIds,\n identityTestIds,\n}: WorkspaceSwitcherProps) {\n const l = { ...DEFAULT_WORKSPACE_SWITCHER_LABELS, ...labels }\n const plural = l.plural.toLowerCase()\n const singular = l.singular.charAt(0).toUpperCase() + l.singular.slice(1)\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n data-slot=\"workspace-switcher\"\n data-testid={testIdOr(testId, { testId: 'workspace-switcher-trigger' })}\n aria-label={l.switchWorkspace(workspace.name, plural)}\n className={cn(\n 'group flex min-w-0 items-center rounded-md transition-colors duration-100 hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',\n variant === 'appbar'\n ? 'h-11 max-w-full gap-1 px-2'\n : compact\n ? 'h-12 w-12 justify-center'\n : 'h-12 w-full px-2',\n className\n )}\n >\n {variant === 'appbar' ? (\n <span className=\"min-w-0 truncate text-base font-semibold text-foreground\">\n {workspace.name}\n </span>\n ) : (\n <WorkspaceIdentity\n workspace={workspace}\n expanded={!compact}\n labels={l}\n testIds={identityTestIds}\n />\n )}\n {!(compact && variant === 'sidebar') && (\n <ChevronDown\n aria-hidden=\"true\"\n className=\"ml-auto size-4 flex-shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180\"\n />\n )}\n </button>\n </DropdownMenuTrigger>\n {/* Expanded menus follow the trigger width so they stay inside the sidebar. */}\n <DropdownMenuContent\n align=\"start\"\n className={cn(\n 'border-0 max-w-[calc(100vw-1.5rem)]',\n variant === 'sidebar' && !compact\n ? 'w-[var(--radix-dropdown-menu-trigger-width)]'\n : 'w-60'\n )}\n data-testid={testIdOr(testIds?.menu, { testId: 'workspace-switcher-menu' })}\n >\n <DropdownMenuItem\n onClick={onGoToList}\n data-testid={testIdOr(testIds?.all, { testId: 'workspace-switcher-all' })}\n className=\"gap-2\"\n >\n <LayoutGrid className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n {l.allWorkspaces(plural)}\n </DropdownMenuItem>\n <DropdownMenuItem\n onClick={newWorkspaceDisabledReason ? undefined : onNewWorkspace}\n disabled={!!newWorkspaceDisabledReason}\n title={newWorkspaceDisabledReason}\n data-testid={testIdOr(testIds?.new, { testId: 'workspace-switcher-new' })}\n className=\"gap-2\"\n >\n <Plus className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n <span className=\"flex min-w-0 flex-col\">\n {l.newWorkspace(singular)}\n {newWorkspaceDisabledReason && (\n <span className=\"text-xs text-muted-foreground\">{newWorkspaceDisabledReason}</span>\n )}\n </span>\n </DropdownMenuItem>\n {recent.length > 0 && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuLabel className=\"text-xs font-normal text-muted-foreground\">\n {l.recentWorkspaces(plural)}\n </DropdownMenuLabel>\n {recent.map((w) => {\n const kind = workspaceKindMeta(w.kind, l)\n return (\n <DropdownMenuItem\n key={w.id}\n onClick={() => onSwitch(w)}\n data-testid={prefixedTestId(testIds?.switchItem, w.id, {\n testId: `workspace-switch-${w.id}`,\n })}\n className=\"gap-2\"\n >\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n className={cn(\n 'flex size-6 flex-shrink-0 items-center justify-center rounded text-xs font-semibold leading-none',\n kind.fill\n )}\n >\n {w.name.charAt(0).toUpperCase()}\n </span>\n <span className=\"absolute -bottom-1 -right-1 flex size-3 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={prefixedTestId(testIds?.type, w.id, {\n testId: `workspace-type-${w.id}`,\n })}\n className=\"size-2 text-muted-foreground\"\n />\n </span>\n </span>\n <span className=\"min-w-0 flex-1 truncate capitalize\">{w.name}</span>\n {w.lastSeen && (\n <span\n className=\"ml-2 flex-shrink-0 text-xs tabular-nums text-muted-foreground\"\n data-testid={prefixedTestId(testIds?.lastSeen, w.id, {\n testId: `workspace-last-seen-${w.id}`,\n })}\n >\n {w.lastSeen}\n </span>\n )}\n </DropdownMenuItem>\n )\n })}\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n","import { useRef, type ReactNode } from 'react'\nimport { Menu } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ActionLink } from '../components/ActionLink'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport { useShellBottomInset } from '../lib/bottom-inset'\nimport type { NavItem } from './types'\n\n/** Fixed strings of the phone bars. */\nexport interface MobileBarsLabels {\n /** The menu button (the `menuLabel` prop wins). */\n openNavigationMenu: string\n /** The tab bar's accessible name (the `label` prop wins). */\n workspaceSections: string\n}\n\nexport const DEFAULT_MOBILE_BARS_LABELS: MobileBarsLabels = {\n openNavigationMenu: 'Open navigation menu',\n workspaceSections: 'Workspace sections',\n}\n\nexport interface MobileAppBarProps {\n /** Show the menu button that opens the drawer (nothing to open on a list page with no sidebar). */\n showMenu?: boolean\n onMenu?: () => void\n /** Replaces the brand mark (e.g. the workspace switcher). */\n title?: ReactNode\n /** Brand mark shown when there is no `title`. */\n logo?: ReactNode\n /** Right-aligned controls that fit (ask, offline pill, bell, account). */\n actions?: ReactNode\n menuLabel?: string\n labels?: Partial<Pick<MobileBarsLabels, 'openNavigationMenu'>>\n className?: string\n 'data-testid'?: string\n /** Menu button id (default `mobile-nav-toggle`). */\n menuTestId?: string\n}\n\n/**\n * The slim phone app bar (56px): menu button, a title slot and an actions slot. The app mounts\n * it only on small screens; the controls that do not fit live in the drawer.\n */\nexport function MobileAppBar({\n showMenu = true,\n onMenu,\n title,\n logo,\n actions,\n menuLabel,\n labels,\n className,\n 'data-testid': testId,\n menuTestId,\n}: MobileAppBarProps) {\n return (\n <div\n data-slot=\"mobile-app-bar\"\n data-testid={testId}\n className={cn(\n 'sm:hidden flex h-14 flex-shrink-0 items-center gap-1 bg-background pl-1 pr-2 pt-safe',\n className\n )}\n >\n {showMenu && (\n <button\n type=\"button\"\n onClick={onMenu}\n className=\"flex size-11 shrink-0 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted\"\n aria-label={\n menuLabel ?? labels?.openNavigationMenu ?? DEFAULT_MOBILE_BARS_LABELS.openNavigationMenu\n }\n data-testid={testIdOr(menuTestId, { testId: 'mobile-nav-toggle' })}\n >\n <Menu className=\"size-5\" />\n </button>\n )}\n <div className={cn('flex min-w-0 flex-1 items-center', !showMenu && 'pl-3')}>\n {title ?? logo}\n </div>\n {actions && <div className=\"flex shrink-0 items-center gap-0.5\">{actions}</div>}\n </div>\n )\n}\n\n/**\n * A tab's label. It wraps at word boundaries and is never clipped or cut with an ellipsis; a tab\n * narrower than 4.5rem sets it one size smaller so a long single word still fits, and an item with\n * a `shortLabel` shows that one while its tab is narrower than 5.5rem.\n */\nfunction TabLabel({ item }: { item: NavItem }) {\n const wrap =\n 'max-w-full text-balance px-0.5 text-center [overflow-wrap:normal] @max-[4.5rem]:text-[10px]'\n if (!item.shortLabel) return <span className={wrap}>{item.label}</span>\n return (\n <>\n <span data-slot=\"tab-short-label\" aria-hidden=\"true\" className={cn(wrap, '@[5.5rem]:hidden')}>\n {item.shortLabel}\n </span>\n <span className={cn(wrap, 'hidden @[5.5rem]:block')}>{item.label}</span>\n <span className=\"sr-only @[5.5rem]:hidden\">{item.label}</span>\n </>\n )\n}\n\nexport interface MobileTabBarProps {\n /** The workspace's main areas; test ids are `{testIdPrefix}-{id}` (prefix default `mobile-tab`). */\n items: NavItem[]\n label?: string\n labels?: Partial<Pick<MobileBarsLabels, 'workspaceSections'>>\n testIdPrefix?: string\n className?: string\n 'data-testid'?: string\n}\n\n/**\n * Phone bottom navigation: a 64px tinted bar of the main areas. The drawer carries the same\n * destinations with counts, so nothing is reachable only here. The app mounts it on small\n * screens only.\n */\nexport function MobileTabBar({\n items,\n label,\n labels,\n testIdPrefix,\n className,\n 'data-testid': testId,\n}: MobileTabBarProps) {\n const navRef = useRef<HTMLElement>(null)\n // Floating elements (install prompt, toasts) read the bar's height from `--shell-bottom-inset`.\n useShellBottomInset(navRef)\n return (\n <nav\n ref={navRef}\n aria-label={\n label ?? labels?.workspaceSections ?? DEFAULT_MOBILE_BARS_LABELS.workspaceSections\n }\n data-slot=\"mobile-tab-bar\"\n data-testid={testIdOr(testId, { testId: 'mobile-tab-bar' })}\n className={cn(\n 'flex min-h-16 flex-shrink-0 items-stretch bg-sidebar px-2 pb-safe sm:hidden',\n className\n )}\n >\n {items.map((item) => (\n <ActionLink\n key={item.id}\n href={item.href}\n external={item.external}\n onSelect={item.onSelect}\n disabled={item.disabled}\n aria-current={item.active ? 'page' : undefined}\n className={cn(\n // Each tab is a size container: a `shortLabel` replaces the label when it is narrow.\n '@container flex min-h-12 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md text-[11px] leading-tight transition-colors',\n item.active\n ? 'font-semibold text-primary'\n : 'font-medium text-muted-foreground hover:text-foreground'\n )}\n data-testid={prefixedTestId(testIdPrefix, item.id, { testId: `mobile-tab-${item.id}` })}\n >\n {item.icon}\n <TabLabel item={item} />\n </ActionLink>\n ))}\n </nav>\n )\n}\n","/**\n * One policy for every automatic reload: when the running build is out of date, pick a moment\n * that costs the user nothing.\n *\n * After a deploy (or mid-rollout, while old and new pods both serve) the previous build's hashed\n * chunks can 404. Vite reports that as `vite:preloadError`. Reloading fetches the current\n * index.html (served no-cache) and its chunks, but reloading at once throws away whatever the\n * user is typing, so:\n *\n * - A failed prefetch (`prefetchChunk`) never reloads. Nothing on screen depends on it.\n * - A failed chunk the user is waiting for reloads at once, unless the user is on a sign-in form\n * or has unsaved input (a focused or edited field, or a `[data-reload-guard]` region).\n * - Otherwise the reload waits: the next route navigation becomes a full page load of its target,\n * or the page reloads once the user is idle with nothing unsaved.\n * - Per tab, at most one policy reload a minute. A second failure right after one is not a stale\n * build (a genuinely missing chunk, say), so it surfaces to the error boundary instead of looping.\n */\n\nimport { notify } from '@arbidocs/react/shell'\n\nexport const CHUNK_RELOAD_KEY = 'arbi_chunk_reload_at'\n\n/** A second failure within this window after a reload is not a stale build: let it surface. */\nconst RELOAD_GUARD_MS = 60_000\n/** A deferred reload waits until the user has done nothing for this long. */\nconst IDLE_MS = 10_000\nconst IDLE_CHECK_MS = 2_000\n\n/** Sign-in pages, and regions a host marks as holding unsaved work. */\nconst GUARD_SELECTOR =\n '[data-slot=\"auth-layout\"], input[type=\"password\"], input[autocomplete=\"one-time-code\"], [data-reload-guard]'\nconst NON_TEXT_INPUTS = new Set([\n 'button',\n 'submit',\n 'reset',\n 'checkbox',\n 'radio',\n 'hidden',\n 'range',\n 'color',\n 'file',\n 'image',\n])\n\nexport interface ReloadPolicyDeps {\n /** Reload the current page. */\n reload: () => void\n /** Full page load of `url` (instead of a client-side navigation). */\n load: (url: string, replace: boolean) => void\n now: () => number\n}\n\nconst browserDeps: ReloadPolicyDeps = {\n reload: () => window.location.reload(),\n load: (url, replace) => (replace ? window.location.replace(url) : window.location.assign(url)),\n now: () => Date.now(),\n}\n\nlet deps = browserDeps\nlet installed = false\n/** The build is out of date: the next route navigation loads the page fresh. */\nlet stale = false\n/** A chunk the user needed failed: reload as soon as nothing would be lost. */\nlet reloadWanted = false\nlet lastActivity = 0\nlet idleTimer: ReturnType<typeof setInterval> | undefined\nlet restoreNavigation: (() => void) | null = null\n/** Fields the user typed into. */\nconst edited = new Set<Element>()\n/** Errors from `prefetchChunk` loads, so the preload-error handler can tell them apart. */\nconst prefetchFailures = new WeakSet<object>()\n\nfunction isTextField(el: Element): boolean {\n if (el instanceof HTMLInputElement) return !NON_TEXT_INPUTS.has(el.type)\n return el instanceof HTMLTextAreaElement || (el as HTMLElement).isContentEditable === true\n}\n\nfunction hasText(el: Element): boolean {\n if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {\n return el.value.trim() !== ''\n }\n return (el.textContent ?? '').trim() !== ''\n}\n\n/**\n * Whether reloading now could cost the user something: a sign-in form, a `[data-reload-guard]`\n * region, a focused text field, or a field they typed into that still holds text.\n */\nexport function hasUnsavedInput(doc: Document = document): boolean {\n if (doc.querySelector(GUARD_SELECTOR)) return true\n const active = doc.activeElement\n if (active && active !== doc.body && isTextField(active)) return true\n for (const el of edited) {\n if (!el.isConnected) edited.delete(el)\n else if (hasText(el)) return true\n }\n return false\n}\n\n/** Take this tab's reload slot. False within the guard window, or when storage can't record it. */\nfunction claimReload(): boolean {\n const now = deps.now()\n let last = 0\n try {\n last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n } catch {\n // Unreadable: treat as never reloaded. Writing below decides.\n }\n if (last && now - last < RELOAD_GUARD_MS) return false\n try {\n sessionStorage.setItem(CHUNK_RELOAD_KEY, String(now))\n } catch {\n // Without the guard we can't tell a loop from a stale build: don't risk one.\n return false\n }\n return true\n}\n\nfunction guardHot(): boolean {\n try {\n const last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n return !!last && deps.now() - last < RELOAD_GUARD_MS\n } catch {\n return false\n }\n}\n\nfunction settle(): void {\n stale = false\n reloadWanted = false\n if (idleTimer !== undefined) clearInterval(idleTimer)\n idleTimer = undefined\n restoreNavigation?.()\n restoreNavigation = null\n}\n\nfunction reloadNow(): boolean {\n if (!claimReload()) {\n settle()\n return false\n }\n settle()\n deps.reload()\n return true\n}\n\n/** A client-side navigation to `url` becomes a full page load of it while the build is stale. */\nfunction loadsFresh(url: string | URL | null | undefined): string | null {\n if (!stale || url == null) return null\n const target = new URL(String(url), window.location.href)\n if (target.pathname === window.location.pathname) return null\n // Leaving a sign-in page establishes the session: a full load there races its persistence.\n if (document.querySelector(GUARD_SELECTOR)) return null\n return target.href\n}\n\nfunction interceptNavigation(): void {\n if (restoreNavigation) return\n const history = window.history\n const push = history.pushState\n const replace = history.replaceState\n let shownPath = window.location.pathname\n const wrap = (original: History['pushState'], replaceEntry: boolean): History['pushState'] =>\n function (this: History, data, unused, url) {\n const target = loadsFresh(url)\n if (target && claimReload()) {\n settle()\n deps.load(target, replaceEntry)\n return\n }\n original.call(this, data, unused, url)\n shownPath = window.location.pathname\n }\n history.pushState = wrap(push, false)\n history.replaceState = wrap(replace, true)\n // Back/forward already changed the address: reloading loads that target.\n const onPopState = () => {\n if (window.location.pathname === shownPath) return\n shownPath = window.location.pathname\n if (!document.querySelector(GUARD_SELECTOR)) reloadNow()\n }\n window.addEventListener('popstate', onPopState)\n restoreNavigation = () => {\n history.pushState = push\n history.replaceState = replace\n window.removeEventListener('popstate', onPopState)\n }\n}\n\nfunction watchForIdle(): void {\n if (idleTimer !== undefined) return\n idleTimer = setInterval(() => {\n if (!reloadWanted) return\n const idle = document.visibilityState === 'hidden' || deps.now() - lastActivity >= IDLE_MS\n if (idle && !hasUnsavedInput()) reloadNow()\n }, IDLE_CHECK_MS)\n}\n\n/**\n * The running build is out of date (a chunk 404'd, or a new service worker took over): the next\n * route navigation loads its target fresh instead of rendering it client-side.\n */\nexport function markBuildStale(): void {\n stale = true\n interceptNavigation()\n}\n\nexport type ReloadOutcome = 'reloaded' | 'deferred' | 'guarded'\n\n/**\n * Reload onto the current build when nothing would be lost; otherwise defer to the next route\n * navigation or to the moment the user is idle with nothing unsaved. `guarded` means a policy\n * reload just happened in this tab, so the failure should surface instead.\n */\nexport function requestReload(): ReloadOutcome {\n if (guardHot()) return 'guarded'\n if (!hasUnsavedInput()) return reloadNow() ? 'reloaded' : 'guarded'\n reloadWanted = true\n markBuildStale()\n watchForIdle()\n return 'deferred'\n}\n\n/**\n * Load a chunk ahead of need (warming a route the user may open next). Never rejects, and a\n * failure never reloads the page: it only marks the build stale so the next navigation loads\n * fresh.\n */\nexport function prefetchChunk(load: () => Promise<unknown>): Promise<void> {\n let loading: Promise<unknown>\n try {\n loading = load()\n } catch (error) {\n loading = Promise.reject(error)\n }\n return loading.then(\n () => undefined,\n (error: unknown) => {\n if (typeof error === 'object' && error !== null) prefetchFailures.add(error)\n }\n )\n}\n\nfunction decide(payload: unknown): void {\n const prefetch = typeof payload === 'object' && payload !== null && prefetchFailures.has(payload)\n // Offline the chunk simply couldn't be downloaded (it isn't cached yet). Reloading can't fix\n // that and would throw away what's on screen; say what happened instead, and let the failed\n // import reach the nearest error boundary as usual.\n if (typeof navigator !== 'undefined' && navigator.onLine === false) {\n if (!prefetch) {\n notify.warning(\"This part of ARBI isn't available offline yet\", {\n description: 'Reconnect to open it. Once you have, it will work offline too.',\n })\n }\n return\n }\n markBuildStale()\n if (prefetch) return\n const outcome = requestReload()\n console.warn(`[chunk] A code chunk failed to load (stale build?): ${outcome}`, payload)\n}\n\n/**\n * The `vite:preloadError` handler. Decides once the failed import's own handlers have run, so a\n * `prefetchChunk` failure is known as one. Never cancels the event: the import rejects as usual\n * and, if a reload follows, the page is replaced anyway.\n */\nexport function handleChunkLoadError(event: Event): void {\n const payload = (event as Event & { payload?: unknown }).payload\n setTimeout(() => decide(payload), 0)\n}\n\nfunction onActivity(event: Event): void {\n lastActivity = deps.now()\n if (event.type === 'input' && event.target instanceof Element && isTextField(event.target)) {\n edited.add(event.target)\n }\n}\n\nconst ACTIVITY_EVENTS = ['input', 'keydown', 'pointerdown', 'wheel', 'touchstart'] as const\n\n/** Install the reload policy. Call once at startup; later calls are no-ops. */\nexport function installReloadPolicy(overrides: Partial<ReloadPolicyDeps> = {}): void {\n deps = { ...browserDeps, ...overrides }\n if (installed || typeof window === 'undefined') return\n installed = true\n lastActivity = deps.now()\n window.addEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) {\n document.addEventListener(type, onActivity, { capture: true, passive: true })\n }\n}\n\n/** Undo `installReloadPolicy` and forget all state (tests). */\nexport function resetReloadPolicy(): void {\n settle()\n edited.clear()\n if (installed) {\n window.removeEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) document.removeEventListener(type, onActivity, true)\n }\n installed = false\n deps = browserDeps\n}\n"]}
1
+ {"version":3,"sources":["../src/shell/Workspace.tsx","../src/shell/MobileBars.tsx","../src/shell/reload-policy.ts"],"names":["Globe","Users","Lock","jsxs","jsx","testIdOr","cn","Fragment","DropdownMenu","DropdownMenuTrigger","ChevronDown","DropdownMenuContent","DropdownMenuItem","LayoutGrid","Plus","DropdownMenuSeparator","DropdownMenuLabel","prefixedTestId","Menu","useRef","useShellBottomInset","ActionLink","notify"],"mappings":";;;;;;;;;;;AAqBO,IAAM,6BAAA,GAAqD;AAAA,EAChE,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS;AACX;AAQO,SAAS,iBAAA,CACd,MACA,MAAA,EAKA;AACA,EAAA,MAAM,CAAA,GAAI,EAAE,GAAG,6BAAA,EAA+B,GAAG,MAAA,EAAO;AACxD,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAAE,IAAA,EAAMA,iBAAA,EAAO,OAAO,CAAA,CAAE,MAAA,EAAQ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nF,EAAA,IAAA,GAAO,EAAE,GAAG,WAAA,EAAa,GAAG,SAAA,EAAU;AACtC,EAAA,IAAI,SAAA,IAAa,OAAO,MAAA,KAAW,WAAA,EAAa;AAChD,EAAA,SAAA,GAAY,IAAA;AACZ,EAAA,YAAA,GAAe,KAAK,GAAA,EAAI;AACxB,EAAA,MAAA,CAAO,gBAAA,CAAiB,qBAAqB,oBAAoB,CAAA;AACjE,EAAA,KAAA,MAAW,QAAQ,eAAA,EAAiB;AAClC,IAAA,QAAA,CAAS,gBAAA,CAAiB,MAAM,UAAA,EAAY,EAAE,SAAS,IAAA,EAAM,OAAA,EAAS,MAAM,CAAA;AAAA,EAC9E;AACF","file":"chunk-N2IQSGYU.cjs","sourcesContent":["import type { ComponentType } from 'react'\nimport { ChevronDown, Globe, LayoutGrid, Lock, Plus, Users } from 'lucide-react'\nimport {\n cn,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '@arbidocs/react/ui'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport type { ShellRecentWorkspace, ShellWorkspace, ShellWorkspaceKind } from './types'\n\n/** The three workspace-kind names (badge title, type glyph name, subtitle). */\nexport interface WorkspaceKindLabels {\n common: string\n shared: string\n private: string\n}\n\nexport const DEFAULT_WORKSPACE_KIND_LABELS: WorkspaceKindLabels = {\n common: 'Common',\n shared: 'Shared',\n private: 'Private',\n}\n\n/**\n * Workspace type drives the initial-badge fill and a quiet secondary glyph:\n * private (just you) -> navy, lock shared (several) -> selection tint, people\n * common (public) -> neutral, globe\n * Navy is identity and cyan is reserved for ARBI/AI, so \"shared\" is the selection tint.\n */\nexport function workspaceKindMeta(\n kind: ShellWorkspaceKind,\n labels?: Partial<WorkspaceKindLabels>\n): {\n Icon: ComponentType<{ className?: string; 'aria-label'?: string; 'data-testid'?: string }>\n label: string\n fill: string\n} {\n const l = { ...DEFAULT_WORKSPACE_KIND_LABELS, ...labels }\n if (kind === 'common')\n return { Icon: Globe, label: l.common, fill: 'bg-muted text-muted-foreground' }\n if (kind === 'shared')\n return { Icon: Users, label: l.shared, fill: 'bg-secondary text-secondary-foreground' }\n return { Icon: Lock, label: l.private, fill: 'bg-primary text-primary-foreground' }\n}\n\n/** The kind's hue as a CSS colour, for glyphs painted by SVG fill (the workspace shield). */\nexport function workspaceKindColor(kind: ShellWorkspaceKind): string {\n if (kind === 'common') return 'var(--color-muted-foreground)'\n if (kind === 'shared') return 'var(--color-secondary)'\n return 'var(--color-primary)'\n}\n\n/** Overridable ids of the workspace identity; defaults are the current ids. */\ntype WorkspaceIdentityTestIds = Partial<Record<'initial' | 'type' | 'projectName', string>>\n\nexport interface WorkspaceIdentityProps {\n workspace: ShellWorkspace\n /** Show name + type/project line beside the badge; otherwise the badge alone. */\n expanded: boolean\n /** Selected (nav-row) styling of the name. */\n isActive?: boolean\n /** Reword the kind names. */\n labels?: Partial<WorkspaceKindLabels>\n /** Part ids; defaults are the current ids. */\n testIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * Non-interactive guts of the workspace head: the initial badge (with a tiny type glyph) and,\n * when expanded, the name and the project/type line. Hosted by the switcher trigger and by the\n * workspace settings header, so it never nests a button.\n */\nexport function WorkspaceIdentity({\n workspace,\n expanded,\n isActive = false,\n labels,\n testIds,\n}: WorkspaceIdentityProps) {\n const kind = workspaceKindMeta(workspace.kind, labels)\n const badge = (\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n data-testid={testIdOr(testIds?.initial, { testId: 'sidebar-workspace-card-initial' })}\n className={cn(\n 'flex size-7 flex-shrink-0 items-center justify-center rounded-md text-sm font-semibold leading-none',\n kind.fill\n )}\n >\n {workspace.name.charAt(0).toUpperCase()}\n </span>\n {/* Type as a tiny overlay on the badge: status reads at the icon, not after the name. */}\n <span className=\"absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={testIdOr(testIds?.type, { testId: 'sidebar-workspace-card-type' })}\n className=\"size-2.5 text-muted-foreground\"\n />\n </span>\n </span>\n )\n\n if (!expanded)\n return <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n\n return (\n <>\n <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n <div className=\"ml-2.5 flex min-w-0 flex-1 flex-col text-left\">\n <span\n // 600: the name of the thing you are inside, above a lighter project line.\n className={cn(\n 'min-w-0 truncate text-left text-sm font-semibold capitalize leading-tight transition-colors duration-100',\n isActive ? 'text-accent-foreground' : 'text-foreground'\n )}\n >\n {workspace.name}\n </span>\n {!workspace.projectName && (\n <span className=\"mt-0.5 truncate text-xs text-muted-foreground\">{kind.label}</span>\n )}\n {workspace.projectName && (\n <span\n className=\"mt-0.5 flex min-w-0\"\n data-testid={testIdOr(testIds?.projectName, {\n testId: 'sidebar-workspace-card-project-name',\n })}\n >\n {workspace.projectLine ?? (\n <span className=\"truncate text-xs text-muted-foreground\">\n {workspace.projectName}\n </span>\n )}\n </span>\n )}\n </div>\n </>\n )\n}\n\n/**\n * Entity nouns plus the switcher's strings. `plural` arrives lowercased and `singular`\n * capitalized in the functions below.\n */\nexport interface WorkspaceSwitcherLabels extends WorkspaceKindLabels {\n /** Entity nouns, e.g. { plural: 'workspaces', singular: 'workspace' }. */\n plural: string\n singular: string\n /** The trigger's accessible name. */\n switchWorkspace: (name: string, plural: string) => string\n allWorkspaces: (plural: string) => string\n newWorkspace: (singular: string) => string\n recentWorkspaces: (plural: string) => string\n}\n\nexport const DEFAULT_WORKSPACE_SWITCHER_LABELS: WorkspaceSwitcherLabels = {\n ...DEFAULT_WORKSPACE_KIND_LABELS,\n plural: 'workspaces',\n singular: 'workspace',\n switchWorkspace: (name, plural) => `${name} — switch ${plural}`,\n allWorkspaces: (plural) => `All ${plural}`,\n newWorkspace: (singular) => `New ${singular}`,\n recentWorkspaces: (plural) => `Recent ${plural}`,\n}\n\nexport interface WorkspaceSwitcherProps {\n workspace: ShellWorkspace\n /** Other workspaces to jump to (the app orders and caps them). */\n recent?: ShellRecentWorkspace[]\n /** Icon-only trigger (the sidebar rail). */\n compact?: boolean\n /** `appbar`: the phone app bar's title, name + chevron on one line. */\n variant?: 'sidebar' | 'appbar'\n onSwitch: (workspace: ShellWorkspace) => void\n /** Return to the workspaces list; leaves the workspace open. */\n onGoToList: () => void\n onNewWorkspace: () => void\n /**\n * When set, \"New workspace\" is shown disabled with this explanation under it (e.g. the user may\n * not create workspaces on this deployment).\n */\n newWorkspaceDisabledReason?: string\n /** Entity nouns and menu strings; any subset (the nouns default to workspace(s)). */\n labels?: Partial<WorkspaceSwitcherLabels>\n className?: string\n /** Trigger id (default `workspace-switcher-trigger`). */\n testId?: string\n /**\n * Part ids; defaults are the current ids. `switchItem`, `type` and `lastSeen` are prefixes\n * (`<prefix>-<workspace id>`).\n */\n testIds?: Partial<Record<'menu' | 'all' | 'new' | 'switchItem' | 'type' | 'lastSeen', string>>\n /** Ids forwarded to the trigger's workspace identity. */\n identityTestIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * The current-workspace control as a dropdown: \"All workspaces\", \"New workspace\", then the\n * recent workspaces to jump straight into.\n */\nexport function WorkspaceSwitcher({\n workspace,\n recent = [],\n compact = false,\n variant = 'sidebar',\n onSwitch,\n onGoToList,\n onNewWorkspace,\n newWorkspaceDisabledReason,\n labels,\n className,\n testId,\n testIds,\n identityTestIds,\n}: WorkspaceSwitcherProps) {\n const l = { ...DEFAULT_WORKSPACE_SWITCHER_LABELS, ...labels }\n const plural = l.plural.toLowerCase()\n const singular = l.singular.charAt(0).toUpperCase() + l.singular.slice(1)\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n data-slot=\"workspace-switcher\"\n data-testid={testIdOr(testId, { testId: 'workspace-switcher-trigger' })}\n aria-label={l.switchWorkspace(workspace.name, plural)}\n className={cn(\n 'group flex min-w-0 items-center rounded-md transition-colors duration-100 hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',\n variant === 'appbar'\n ? 'h-11 max-w-full gap-1 px-2'\n : compact\n ? 'h-12 w-12 justify-center'\n : 'h-12 w-full px-2',\n className\n )}\n >\n {variant === 'appbar' ? (\n <span className=\"min-w-0 truncate text-base font-semibold text-foreground\">\n {workspace.name}\n </span>\n ) : (\n <WorkspaceIdentity\n workspace={workspace}\n expanded={!compact}\n labels={l}\n testIds={identityTestIds}\n />\n )}\n {!(compact && variant === 'sidebar') && (\n <ChevronDown\n aria-hidden=\"true\"\n className=\"ml-auto size-4 flex-shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180\"\n />\n )}\n </button>\n </DropdownMenuTrigger>\n {/* Expanded menus follow the trigger width so they stay inside the sidebar. */}\n <DropdownMenuContent\n align=\"start\"\n className={cn(\n 'border-0 max-w-[calc(100vw-1.5rem)]',\n variant === 'sidebar' && !compact\n ? 'w-[var(--radix-dropdown-menu-trigger-width)]'\n : 'w-60'\n )}\n data-testid={testIdOr(testIds?.menu, { testId: 'workspace-switcher-menu' })}\n >\n <DropdownMenuItem\n onClick={onGoToList}\n data-testid={testIdOr(testIds?.all, { testId: 'workspace-switcher-all' })}\n className=\"gap-2\"\n >\n <LayoutGrid className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n {l.allWorkspaces(plural)}\n </DropdownMenuItem>\n <DropdownMenuItem\n onClick={newWorkspaceDisabledReason ? undefined : onNewWorkspace}\n disabled={!!newWorkspaceDisabledReason}\n title={newWorkspaceDisabledReason}\n data-testid={testIdOr(testIds?.new, { testId: 'workspace-switcher-new' })}\n className=\"gap-2\"\n >\n <Plus className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n <span className=\"flex min-w-0 flex-col\">\n {l.newWorkspace(singular)}\n {newWorkspaceDisabledReason && (\n <span className=\"text-xs text-muted-foreground\">{newWorkspaceDisabledReason}</span>\n )}\n </span>\n </DropdownMenuItem>\n {recent.length > 0 && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuLabel className=\"text-xs font-normal text-muted-foreground\">\n {l.recentWorkspaces(plural)}\n </DropdownMenuLabel>\n {recent.map((w) => {\n const kind = workspaceKindMeta(w.kind, l)\n return (\n <DropdownMenuItem\n key={w.id}\n onClick={() => onSwitch(w)}\n data-testid={prefixedTestId(testIds?.switchItem, w.id, {\n testId: `workspace-switch-${w.id}`,\n })}\n className=\"gap-2\"\n >\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n className={cn(\n 'flex size-6 flex-shrink-0 items-center justify-center rounded text-xs font-semibold leading-none',\n kind.fill\n )}\n >\n {w.name.charAt(0).toUpperCase()}\n </span>\n <span className=\"absolute -bottom-1 -right-1 flex size-3 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={prefixedTestId(testIds?.type, w.id, {\n testId: `workspace-type-${w.id}`,\n })}\n className=\"size-2 text-muted-foreground\"\n />\n </span>\n </span>\n <span className=\"min-w-0 flex-1 truncate capitalize\">{w.name}</span>\n {w.lastSeen && (\n <span\n className=\"ml-2 flex-shrink-0 text-xs tabular-nums text-muted-foreground\"\n data-testid={prefixedTestId(testIds?.lastSeen, w.id, {\n testId: `workspace-last-seen-${w.id}`,\n })}\n >\n {w.lastSeen}\n </span>\n )}\n </DropdownMenuItem>\n )\n })}\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n","import { useRef, type ReactNode } from 'react'\nimport { Menu } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ActionLink } from '../components/ActionLink'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport { useShellBottomInset } from '../lib/bottom-inset'\nimport type { NavItem } from './types'\n\n/** Fixed strings of the phone bars. */\nexport interface MobileBarsLabels {\n /** The menu button (the `menuLabel` prop wins). */\n openNavigationMenu: string\n /** The tab bar's accessible name (the `label` prop wins). */\n workspaceSections: string\n}\n\nexport const DEFAULT_MOBILE_BARS_LABELS: MobileBarsLabels = {\n openNavigationMenu: 'Open navigation menu',\n workspaceSections: 'Workspace sections',\n}\n\nexport interface MobileAppBarProps {\n /** Show the menu button that opens the drawer (nothing to open on a list page with no sidebar). */\n showMenu?: boolean\n onMenu?: () => void\n /** Replaces the brand mark (e.g. the workspace switcher). */\n title?: ReactNode\n /** Brand mark shown when there is no `title`. */\n logo?: ReactNode\n /** Right-aligned controls that fit (ask, offline pill, bell, account). */\n actions?: ReactNode\n menuLabel?: string\n labels?: Partial<Pick<MobileBarsLabels, 'openNavigationMenu'>>\n className?: string\n 'data-testid'?: string\n /** Menu button id (default `mobile-nav-toggle`). */\n menuTestId?: string\n}\n\n/**\n * The slim phone app bar (56px): menu button, a title slot and an actions slot. The app mounts\n * it only on small screens; the controls that do not fit live in the drawer.\n */\nexport function MobileAppBar({\n showMenu = true,\n onMenu,\n title,\n logo,\n actions,\n menuLabel,\n labels,\n className,\n 'data-testid': testId,\n menuTestId,\n}: MobileAppBarProps) {\n return (\n <div\n data-slot=\"mobile-app-bar\"\n data-testid={testId}\n className={cn(\n 'sm:hidden flex h-14 flex-shrink-0 items-center gap-1 bg-background pl-1 pr-2 pt-safe',\n className\n )}\n >\n {showMenu && (\n <button\n type=\"button\"\n onClick={onMenu}\n className=\"flex size-11 shrink-0 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted\"\n aria-label={\n menuLabel ?? labels?.openNavigationMenu ?? DEFAULT_MOBILE_BARS_LABELS.openNavigationMenu\n }\n data-testid={testIdOr(menuTestId, { testId: 'mobile-nav-toggle' })}\n >\n <Menu className=\"size-5\" />\n </button>\n )}\n <div className={cn('flex min-w-0 flex-1 items-center', !showMenu && 'pl-3')}>\n {title ?? logo}\n </div>\n {actions && <div className=\"flex shrink-0 items-center gap-0.5\">{actions}</div>}\n </div>\n )\n}\n\n/**\n * A tab's label. It wraps at word boundaries and is never clipped or cut with an ellipsis; a tab\n * narrower than 4.5rem sets it one size smaller so a long single word still fits, and an item with\n * a `shortLabel` shows that one while its tab is narrower than 5.5rem.\n */\nfunction TabLabel({ item }: { item: NavItem }) {\n const wrap =\n 'max-w-full text-balance px-0.5 text-center [overflow-wrap:normal] @max-[4.5rem]:text-[10px]'\n if (!item.shortLabel) return <span className={wrap}>{item.label}</span>\n return (\n <>\n <span data-slot=\"tab-short-label\" aria-hidden=\"true\" className={cn(wrap, '@[5.5rem]:hidden')}>\n {item.shortLabel}\n </span>\n <span className={cn(wrap, 'hidden @[5.5rem]:block')}>{item.label}</span>\n <span className=\"sr-only @[5.5rem]:hidden\">{item.label}</span>\n </>\n )\n}\n\nexport interface MobileTabBarProps {\n /** The workspace's main areas; test ids are `{testIdPrefix}-{id}` (prefix default `mobile-tab`). */\n items: NavItem[]\n label?: string\n labels?: Partial<Pick<MobileBarsLabels, 'workspaceSections'>>\n testIdPrefix?: string\n className?: string\n 'data-testid'?: string\n}\n\n/**\n * Phone bottom navigation: a 64px tinted bar of the main areas. The drawer carries the same\n * destinations with counts, so nothing is reachable only here. The app mounts it on small\n * screens only.\n */\nexport function MobileTabBar({\n items,\n label,\n labels,\n testIdPrefix,\n className,\n 'data-testid': testId,\n}: MobileTabBarProps) {\n const navRef = useRef<HTMLElement>(null)\n // Floating elements (install prompt, toasts) read the bar's height from `--shell-bottom-inset`.\n useShellBottomInset(navRef)\n return (\n <nav\n ref={navRef}\n aria-label={\n label ?? labels?.workspaceSections ?? DEFAULT_MOBILE_BARS_LABELS.workspaceSections\n }\n data-slot=\"mobile-tab-bar\"\n data-testid={testIdOr(testId, { testId: 'mobile-tab-bar' })}\n className={cn(\n 'flex min-h-16 flex-shrink-0 items-stretch bg-sidebar px-2 pb-safe sm:hidden',\n className\n )}\n >\n {items.map((item) => (\n <ActionLink\n key={item.id}\n href={item.href}\n external={item.external}\n onSelect={item.onSelect}\n disabled={item.disabled}\n aria-current={item.active ? 'page' : undefined}\n className={cn(\n // Each tab is a size container: a `shortLabel` replaces the label when it is narrow.\n '@container flex min-h-12 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md text-[11px] leading-tight transition-colors',\n item.active\n ? 'font-semibold text-primary'\n : 'font-medium text-muted-foreground hover:text-foreground'\n )}\n data-testid={prefixedTestId(testIdPrefix, item.id, { testId: `mobile-tab-${item.id}` })}\n >\n {item.icon}\n <TabLabel item={item} />\n </ActionLink>\n ))}\n </nav>\n )\n}\n","/**\n * One policy for every automatic reload: when the running build is out of date, pick a moment\n * that costs the user nothing.\n *\n * After a deploy (or mid-rollout, while old and new pods both serve) the previous build's hashed\n * chunks can 404. Vite reports that as `vite:preloadError`. Reloading fetches the current\n * index.html (served no-cache) and its chunks, but reloading at once throws away whatever the\n * user is typing, so:\n *\n * - A failed prefetch (`prefetchChunk`) never reloads. Nothing on screen depends on it.\n * - A failed chunk the user is waiting for reloads at once, unless the user is on a sign-in form\n * or has unsaved input (a focused or edited field, or a `[data-reload-guard]` region).\n * - Otherwise the reload waits: the next route navigation becomes a full page load of its target,\n * or the page reloads once the user is idle with nothing unsaved.\n * - Per tab, at most one policy reload a minute. A second failure right after one is not a stale\n * build (a genuinely missing chunk, say), so it surfaces to the error boundary instead of looping.\n */\n\nimport { notify } from '@arbidocs/react/shell'\n\nexport const CHUNK_RELOAD_KEY = 'arbi_chunk_reload_at'\n\n/** A second failure within this window after a reload is not a stale build: let it surface. */\nconst RELOAD_GUARD_MS = 60_000\n/** A deferred reload waits until the user has done nothing for this long. */\nconst IDLE_MS = 10_000\nconst IDLE_CHECK_MS = 2_000\n\n/** Sign-in pages, and regions a host marks as holding unsaved work. */\nconst GUARD_SELECTOR =\n '[data-slot=\"auth-layout\"], input[type=\"password\"], input[autocomplete=\"one-time-code\"], [data-reload-guard]'\nconst NON_TEXT_INPUTS = new Set([\n 'button',\n 'submit',\n 'reset',\n 'checkbox',\n 'radio',\n 'hidden',\n 'range',\n 'color',\n 'file',\n 'image',\n])\n\nexport interface ReloadPolicyDeps {\n /** Reload the current page. */\n reload: () => void\n /** Full page load of `url` (instead of a client-side navigation). */\n load: (url: string, replace: boolean) => void\n now: () => number\n}\n\nconst browserDeps: ReloadPolicyDeps = {\n reload: () => window.location.reload(),\n load: (url, replace) => (replace ? window.location.replace(url) : window.location.assign(url)),\n now: () => Date.now(),\n}\n\nlet deps = browserDeps\nlet installed = false\n/** The build is out of date: the next route navigation loads the page fresh. */\nlet stale = false\n/** A chunk the user needed failed: reload as soon as nothing would be lost. */\nlet reloadWanted = false\nlet lastActivity = 0\nlet idleTimer: ReturnType<typeof setInterval> | undefined\nlet restoreNavigation: (() => void) | null = null\n/** Fields the user typed into. */\nconst edited = new Set<Element>()\n/** Errors from `prefetchChunk` loads, so the preload-error handler can tell them apart. */\nconst prefetchFailures = new WeakSet<object>()\n\nfunction isTextField(el: Element): boolean {\n if (el instanceof HTMLInputElement) return !NON_TEXT_INPUTS.has(el.type)\n return el instanceof HTMLTextAreaElement || (el as HTMLElement).isContentEditable === true\n}\n\nfunction hasText(el: Element): boolean {\n if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {\n return el.value.trim() !== ''\n }\n return (el.textContent ?? '').trim() !== ''\n}\n\n/**\n * Whether reloading now could cost the user something: a sign-in form, a `[data-reload-guard]`\n * region, a focused text field, or a field they typed into that still holds text.\n */\nexport function hasUnsavedInput(doc: Document = document): boolean {\n if (doc.querySelector(GUARD_SELECTOR)) return true\n const active = doc.activeElement\n if (active && active !== doc.body && isTextField(active)) return true\n for (const el of edited) {\n if (!el.isConnected) edited.delete(el)\n else if (hasText(el)) return true\n }\n return false\n}\n\n/** Take this tab's reload slot. False within the guard window, or when storage can't record it. */\nfunction claimReload(): boolean {\n const now = deps.now()\n let last = 0\n try {\n last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n } catch {\n // Unreadable: treat as never reloaded. Writing below decides.\n }\n if (last && now - last < RELOAD_GUARD_MS) return false\n try {\n sessionStorage.setItem(CHUNK_RELOAD_KEY, String(now))\n } catch {\n // Without the guard we can't tell a loop from a stale build: don't risk one.\n return false\n }\n return true\n}\n\nfunction guardHot(): boolean {\n try {\n const last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n return !!last && deps.now() - last < RELOAD_GUARD_MS\n } catch {\n return false\n }\n}\n\nfunction settle(): void {\n stale = false\n reloadWanted = false\n if (idleTimer !== undefined) clearInterval(idleTimer)\n idleTimer = undefined\n restoreNavigation?.()\n restoreNavigation = null\n}\n\nfunction reloadNow(): boolean {\n if (!claimReload()) {\n settle()\n return false\n }\n settle()\n deps.reload()\n return true\n}\n\n/** A client-side navigation to `url` becomes a full page load of it while the build is stale. */\nfunction loadsFresh(url: string | URL | null | undefined): string | null {\n if (!stale || url == null) return null\n const target = new URL(String(url), window.location.href)\n if (target.pathname === window.location.pathname) return null\n // Leaving a sign-in page establishes the session: a full load there races its persistence.\n if (document.querySelector(GUARD_SELECTOR)) return null\n return target.href\n}\n\nfunction interceptNavigation(): void {\n if (restoreNavigation) return\n const history = window.history\n const push = history.pushState\n const replace = history.replaceState\n let shownPath = window.location.pathname\n const wrap = (original: History['pushState'], replaceEntry: boolean): History['pushState'] =>\n function (this: History, data, unused, url) {\n const target = loadsFresh(url)\n if (target && claimReload()) {\n settle()\n deps.load(target, replaceEntry)\n return\n }\n original.call(this, data, unused, url)\n shownPath = window.location.pathname\n }\n history.pushState = wrap(push, false)\n history.replaceState = wrap(replace, true)\n // Back/forward already changed the address: reloading loads that target.\n const onPopState = () => {\n if (window.location.pathname === shownPath) return\n shownPath = window.location.pathname\n if (!document.querySelector(GUARD_SELECTOR)) reloadNow()\n }\n window.addEventListener('popstate', onPopState)\n restoreNavigation = () => {\n history.pushState = push\n history.replaceState = replace\n window.removeEventListener('popstate', onPopState)\n }\n}\n\nfunction watchForIdle(): void {\n if (idleTimer !== undefined) return\n idleTimer = setInterval(() => {\n if (!reloadWanted) return\n const idle = document.visibilityState === 'hidden' || deps.now() - lastActivity >= IDLE_MS\n if (idle && !hasUnsavedInput()) reloadNow()\n }, IDLE_CHECK_MS)\n}\n\n/**\n * The running build is out of date (a chunk 404'd, or a new service worker took over): the next\n * route navigation loads its target fresh instead of rendering it client-side.\n */\nexport function markBuildStale(): void {\n stale = true\n interceptNavigation()\n}\n\nexport type ReloadOutcome = 'reloaded' | 'deferred' | 'guarded'\n\n/**\n * Reload onto the current build when nothing would be lost; otherwise defer to the next route\n * navigation or to the moment the user is idle with nothing unsaved. `guarded` means a policy\n * reload just happened in this tab, so the failure should surface instead.\n */\nexport function requestReload(): ReloadOutcome {\n if (guardHot()) return 'guarded'\n if (!hasUnsavedInput()) return reloadNow() ? 'reloaded' : 'guarded'\n reloadWanted = true\n markBuildStale()\n watchForIdle()\n return 'deferred'\n}\n\n/**\n * Load a chunk ahead of need (warming a route the user may open next). Never rejects, and a\n * failure never reloads the page: it only marks the build stale so the next navigation loads\n * fresh.\n */\nexport function prefetchChunk(load: () => Promise<unknown>): Promise<void> {\n let loading: Promise<unknown>\n try {\n loading = load()\n } catch (error) {\n loading = Promise.reject(error)\n }\n return loading.then(\n () => undefined,\n (error: unknown) => {\n if (typeof error === 'object' && error !== null) prefetchFailures.add(error)\n }\n )\n}\n\nfunction decide(payload: unknown): void {\n const prefetch = typeof payload === 'object' && payload !== null && prefetchFailures.has(payload)\n // Offline the chunk simply couldn't be downloaded (it isn't cached yet). Reloading can't fix\n // that and would throw away what's on screen; say what happened instead, and let the failed\n // import reach the nearest error boundary as usual.\n if (typeof navigator !== 'undefined' && navigator.onLine === false) {\n if (!prefetch) {\n notify.warning(\"This part of ARBI isn't available offline yet\", {\n description: 'Reconnect to open it. Once you have, it will work offline too.',\n })\n }\n return\n }\n markBuildStale()\n if (prefetch) return\n const outcome = requestReload()\n console.warn(`[chunk] A code chunk failed to load (stale build?): ${outcome}`, payload)\n}\n\n/**\n * The `vite:preloadError` handler. Decides once the failed import's own handlers have run, so a\n * `prefetchChunk` failure is known as one. Never cancels the event: the import rejects as usual\n * and, if a reload follows, the page is replaced anyway.\n */\nexport function handleChunkLoadError(event: Event): void {\n const payload = (event as Event & { payload?: unknown }).payload\n setTimeout(() => decide(payload), 0)\n}\n\nfunction onActivity(event: Event): void {\n lastActivity = deps.now()\n if (event.type === 'input' && event.target instanceof Element && isTextField(event.target)) {\n edited.add(event.target)\n }\n}\n\nconst ACTIVITY_EVENTS = ['input', 'keydown', 'pointerdown', 'wheel', 'touchstart'] as const\n\n/** Install the reload policy. Call once at startup; later calls are no-ops. */\nexport function installReloadPolicy(overrides: Partial<ReloadPolicyDeps> = {}): void {\n deps = { ...browserDeps, ...overrides }\n if (installed || typeof window === 'undefined') return\n installed = true\n lastActivity = deps.now()\n window.addEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) {\n document.addEventListener(type, onActivity, { capture: true, passive: true })\n }\n}\n\n/** Undo `installReloadPolicy` and forget all state (tests). */\nexport function resetReloadPolicy(): void {\n settle()\n edited.clear()\n if (installed) {\n window.removeEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) document.removeEventListener(type, onActivity, true)\n }\n installed = false\n deps = browserDeps\n}\n"]}