arco-workbench 0.2.4 → 0.2.6

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 (254) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/THIRD_PARTY_NOTICES +2 -2
  3. package/client/dist/assets/{PhosphorBackdrop-CHXVFLGT.js → PhosphorBackdrop-YsHTmZJh.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-Bhs4I9jA.js → ThemedBackgroundShaderImpl-BEjpgoBW.js} +1 -1
  5. package/client/dist/assets/{XtermView-CdfurwFx.js → XtermView-wh7jNKvk.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-DYjZZ4cf.js → galleryEditor-CaOS2mmM.js} +1 -1
  7. package/client/dist/assets/{index-BjDmFvqG.js → index-j68SfA-l.js} +271 -271
  8. package/client/dist/index.html +1 -1
  9. package/client/src/App.tsx +2 -2
  10. package/client/src/components/AuthReloginNotice.tsx +7 -6
  11. package/client/src/components/ChatMessage.tsx +41 -29
  12. package/client/src/components/ChatPanel.tsx +17 -4
  13. package/client/src/components/ClaudeNativeAccountPicker.tsx +32 -0
  14. package/client/src/components/ClaudeNativeAuthRow.tsx +71 -19
  15. package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +11 -281
  16. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +1 -1
  17. package/client/src/components/ClusterRightPanel/FreshMemberForm.tsx +315 -0
  18. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +17 -7
  19. package/client/src/components/ClusterRightPanel/index.tsx +1 -1
  20. package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +6 -4
  21. package/client/src/components/ClusterTab.tsx +2 -2
  22. package/client/src/components/Connections/Connections.tsx +5 -9
  23. package/client/src/components/Connections/model.ts +3 -1
  24. package/client/src/components/FileViewerModal.tsx +54 -17
  25. package/client/src/components/GitHubPanel/index.tsx +9 -5
  26. package/client/src/components/HandoffDialog.tsx +5 -3
  27. package/client/src/components/MobileShell.tsx +1 -33
  28. package/client/src/components/OperatorQuestionNotice.tsx +5 -4
  29. package/client/src/components/ProvidersPopover.tsx +6 -2
  30. package/client/src/components/RightPanel/ActivityTab.tsx +2 -1
  31. package/client/src/components/RightPanel/ConfigTab.tsx +23 -5
  32. package/client/src/components/RightPanel/OutputsPanel.tsx +21 -9
  33. package/client/src/components/RightPanel/outputsReconcile.ts +31 -0
  34. package/client/src/components/SettingsPanel.tsx +7 -10
  35. package/client/src/components/SpawnDialog.tsx +14 -3
  36. package/client/src/components/TabBar.tsx +2 -2
  37. package/client/src/components/TabContextMenu.tsx +73 -133
  38. package/client/src/components/TerminalInput.tsx +4 -3
  39. package/client/src/components/TranscriptWorkerDialog.tsx +14 -4
  40. package/client/src/components/UpdateAction.tsx +30 -7
  41. package/client/src/components/UsageBar.tsx +37 -18
  42. package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +29 -3
  43. package/client/src/components/WorkflowCreator/index.tsx +29 -15
  44. package/client/src/components/WorkflowView.tsx +1 -1
  45. package/client/src/components/providerIndicator.ts +7 -3
  46. package/client/src/components/settings/GitHubAuthRow.tsx +34 -0
  47. package/client/src/explorer/ArtifactsLens.tsx +17 -8
  48. package/client/src/explorer/ExplorerApp.tsx +3 -3
  49. package/client/src/explorer/types.ts +3 -1
  50. package/client/src/help/content/cluster.tsx +10 -4
  51. package/client/src/help/content/composer.tsx +3 -2
  52. package/client/src/help/content/header.tsx +11 -4
  53. package/client/src/help/content/misc.tsx +7 -5
  54. package/client/src/help/content/rightPanel.tsx +8 -4
  55. package/client/src/help/content/settings.tsx +15 -4
  56. package/client/src/help/content/tabbar.tsx +1 -1
  57. package/client/src/help/manualSections/actions.tsx +5 -1
  58. package/client/src/help/manualSections/clusters.tsx +20 -14
  59. package/client/src/help/manualSections/configuration.tsx +6 -4
  60. package/client/src/help/manualSections/gettingStarted.tsx +4 -2
  61. package/client/src/help/manualSections/maintenance.tsx +31 -0
  62. package/client/src/help/manualSections/powerFeatures.tsx +1 -0
  63. package/client/src/help/manualSections/providers.tsx +11 -4
  64. package/client/src/help/manualSections/workspace.tsx +3 -3
  65. package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
  66. package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
  67. package/client/src/hooks/useWebSocket.ts +4 -2
  68. package/client/src/layout/layoutRange.ts +4 -5
  69. package/client/src/questions/waitingQuestion.ts +2 -0
  70. package/client/src/stores/appStore.ts +5 -1
  71. package/client/src/stores/appStore.types.ts +2 -0
  72. package/client/src/stores/replayContext.ts +20 -0
  73. package/client/src/utils/chatFileLinks.ts +34 -3
  74. package/client/src/utils/claudeAuth.ts +9 -1
  75. package/client/src/ws/handleServerMessage.ts +11 -3
  76. package/docs/ARCHITECTURE.md +3 -3
  77. package/docs/BACKUP.md +1 -1
  78. package/docs/CLIENT.md +10 -5
  79. package/docs/EXTENDING.md +1 -1
  80. package/docs/FEATURES.md +3 -3
  81. package/docs/GETTING_STARTED.md +5 -4
  82. package/docs/GIT_WORKBENCH.md +8 -0
  83. package/docs/GLOSSARY.md +2 -2
  84. package/docs/GOTCHAS.md +4 -4
  85. package/docs/HTTP_API.md +54 -23
  86. package/docs/OPERATIONS.md +17 -1
  87. package/docs/OPERATOR_ACTIONS.md +2 -2
  88. package/docs/OUTPUTS.md +48 -6
  89. package/docs/PERSISTENCE.md +1 -1
  90. package/docs/PRIMITIVES.md +4 -2
  91. package/docs/PROTOCOL_CLUSTER.md +12 -6
  92. package/docs/PROTOCOL_PRIMITIVES.md +1 -1
  93. package/docs/PROVIDERS.md +46 -9
  94. package/docs/RESEARCH.md +1 -1
  95. package/docs/SETTINGS.md +9 -4
  96. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
  97. package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
  98. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
  99. package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  100. package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
  101. package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
  102. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  103. package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
  104. package/node_modules/@arco/shared/package.json +1 -1
  105. package/package.json +2 -2
  106. package/scripts/packaging/services.mjs +20 -1
  107. package/scripts/packaging/update.mjs +37 -2
  108. package/server/dist/attention.d.ts +6 -0
  109. package/server/dist/attention.js +6 -0
  110. package/server/dist/auth.d.ts +5 -0
  111. package/server/dist/auth.js +31 -20
  112. package/server/dist/clusterAutoTurn.d.ts +5 -1
  113. package/server/dist/clusterAutoTurn.js +31 -9
  114. package/server/dist/clusterPresets.js +3 -3
  115. package/server/dist/effortValidation.d.ts +2 -2
  116. package/server/dist/effortValidation.js +4 -4
  117. package/server/dist/explorerArtifacts.d.ts +1 -0
  118. package/server/dist/explorerArtifacts.js +12 -1
  119. package/server/dist/geminiMembers.d.ts +7 -1
  120. package/server/dist/geminiMembers.js +28 -14
  121. package/server/dist/http/conversationFiles.d.ts +36 -0
  122. package/server/dist/http/conversationFiles.js +222 -0
  123. package/server/dist/http/fileBytes.d.ts +3 -0
  124. package/server/dist/http/fileBytes.js +33 -0
  125. package/server/dist/http/fileContentRoute.d.ts +2 -0
  126. package/server/dist/http/fileContentRoute.js +139 -0
  127. package/server/dist/http/fileRead.d.ts +54 -2
  128. package/server/dist/http/fileRead.js +31 -24
  129. package/server/dist/http/outputRoutes.js +14 -21
  130. package/server/dist/http/readConfinement.d.ts +0 -11
  131. package/server/dist/http/readConfinement.js +4 -30
  132. package/server/dist/http/router.js +40 -66
  133. package/server/dist/index.js +26 -12
  134. package/server/dist/management/initHubLink.js +1 -1
  135. package/server/dist/outputs.js +8 -0
  136. package/server/dist/primitives/exportContext.d.ts +2 -0
  137. package/server/dist/primitives/exportContext.js +13 -2
  138. package/server/dist/primitives/runCompare.d.ts +7 -1
  139. package/server/dist/primitives/runCompare.js +44 -20
  140. package/server/dist/project/taskLedger.js +46 -34
  141. package/server/dist/providerAccounts.d.ts +4 -0
  142. package/server/dist/providerAccounts.js +20 -1
  143. package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
  144. package/server/dist/providers/antigravity/artifacts.js +140 -0
  145. package/server/dist/providers/antigravity/index.js +85 -7
  146. package/server/dist/providers/antigravity/questions.d.ts +2 -0
  147. package/server/dist/providers/antigravity/questions.js +58 -0
  148. package/server/dist/providers/claude-native/auth.d.ts +9 -8
  149. package/server/dist/providers/claude-native/auth.js +50 -58
  150. package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
  151. package/server/dist/providers/claude-native/authStatus.js +9 -7
  152. package/server/dist/providers/claude-native/catalog.d.ts +6 -5
  153. package/server/dist/providers/claude-native/catalog.js +50 -39
  154. package/server/dist/providers/claude-native/oauth.d.ts +10 -9
  155. package/server/dist/providers/claude-native/oauth.js +120 -96
  156. package/server/dist/providers/claude-native/worker.d.ts +1 -0
  157. package/server/dist/providers/claude-native/worker.js +38 -23
  158. package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
  159. package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
  160. package/server/dist/server/broadcast.js +6 -0
  161. package/server/dist/settings.d.ts +1 -0
  162. package/server/dist/settings.js +39 -7
  163. package/server/dist/skills.js +1 -1
  164. package/server/dist/smartPickupAdapters.d.ts +1 -0
  165. package/server/dist/smartPickupAdapters.js +2 -2
  166. package/server/dist/smartPickupObserver.js +8 -5
  167. package/server/dist/thirdPartySkills.js +11 -5
  168. package/server/dist/usage.d.ts +1 -1
  169. package/server/dist/usage.js +39 -27
  170. package/server/dist/workers/WorkerManager.d.ts +1 -0
  171. package/server/dist/workers/WorkerManager.js +1 -0
  172. package/server/dist/workers/processKill.js +37 -24
  173. package/server/dist/workflowMeta.js +2 -2
  174. package/server/dist/ws/clusterHandlers.d.ts +2 -2
  175. package/server/dist/ws/clusterHandlers.js +127 -113
  176. package/server/dist/ws/clusterMembers.d.ts +1 -1
  177. package/server/dist/ws/clusterMembers.js +34 -4
  178. package/server/dist/ws/compactHandlers.js +30 -14
  179. package/server/dist/ws/compareHandlers.js +53 -21
  180. package/server/dist/ws/gateHandlers.js +2 -0
  181. package/server/dist/ws/genesisHandlers.js +5 -3
  182. package/server/dist/ws/handoffHandlers.d.ts +1 -1
  183. package/server/dist/ws/handoffHandlers.js +115 -39
  184. package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
  185. package/server/dist/ws/turnEngine.js +33 -18
  186. package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
  187. package/server/dist/ws/updatePrimaryConfig.js +236 -133
  188. package/server/dist/ws/workflowHandlers.js +21 -4
  189. package/server/package.json +1 -1
  190. package/server/src/attention.ts +7 -0
  191. package/server/src/auth.ts +33 -20
  192. package/server/src/clusterAutoTurn.ts +31 -11
  193. package/server/src/clusterPresets.ts +2 -2
  194. package/server/src/effortValidation.ts +4 -4
  195. package/server/src/explorerArtifacts.ts +12 -1
  196. package/server/src/geminiMembers.ts +26 -15
  197. package/server/src/http/conversationFiles.ts +231 -0
  198. package/server/src/http/fileBytes.ts +34 -0
  199. package/server/src/http/fileContentRoute.ts +123 -0
  200. package/server/src/http/fileRead.ts +30 -25
  201. package/server/src/http/outputRoutes.ts +13 -13
  202. package/server/src/http/readConfinement.ts +3 -30
  203. package/server/src/http/router.ts +38 -62
  204. package/server/src/index.ts +27 -18
  205. package/server/src/management/initHubLink.ts +1 -1
  206. package/server/src/outputs.ts +8 -0
  207. package/server/src/primitives/exportContext.ts +14 -2
  208. package/server/src/primitives/runCompare.ts +73 -46
  209. package/server/src/project/taskLedger.ts +47 -30
  210. package/server/src/providerAccounts.ts +20 -1
  211. package/server/src/providers/antigravity/artifacts.ts +121 -0
  212. package/server/src/providers/antigravity/index.ts +64 -6
  213. package/server/src/providers/antigravity/questions.ts +52 -0
  214. package/server/src/providers/claude-native/auth.ts +45 -60
  215. package/server/src/providers/claude-native/authStatus.ts +9 -8
  216. package/server/src/providers/claude-native/catalog.ts +52 -35
  217. package/server/src/providers/claude-native/oauth.ts +101 -77
  218. package/server/src/providers/claude-native/worker.ts +38 -22
  219. package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
  220. package/server/src/server/broadcast.ts +4 -0
  221. package/server/src/settings.ts +36 -8
  222. package/server/src/skills.ts +1 -1
  223. package/server/src/smartPickupAdapters.ts +3 -2
  224. package/server/src/smartPickupObserver.ts +8 -5
  225. package/server/src/thirdPartySkills.ts +11 -5
  226. package/server/src/usage.ts +30 -22
  227. package/server/src/workers/WorkerManager.ts +2 -0
  228. package/server/src/workers/processKill.ts +37 -23
  229. package/server/src/workflowMeta.ts +2 -2
  230. package/server/src/ws/clusterHandlers.ts +107 -104
  231. package/server/src/ws/clusterMembers.ts +25 -6
  232. package/server/src/ws/compactHandlers.ts +29 -15
  233. package/server/src/ws/compareHandlers.ts +59 -25
  234. package/server/src/ws/gateHandlers.ts +2 -0
  235. package/server/src/ws/genesisHandlers.ts +5 -4
  236. package/server/src/ws/handoffHandlers.ts +105 -37
  237. package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
  238. package/server/src/ws/turnEngine.ts +32 -17
  239. package/server/src/ws/updatePrimaryConfig.ts +230 -132
  240. package/server/src/ws/workflowHandlers.ts +20 -4
  241. package/shared/dist/protocol/clusters.d.ts +15 -3
  242. package/shared/dist/protocol/clusters.js +1 -1
  243. package/shared/dist/protocol/models.d.ts +6 -1
  244. package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  245. package/shared/dist/protocol/settings.d.ts +3 -0
  246. package/shared/dist/protocol/settings.js +5 -0
  247. package/shared/dist/protocol/workflows.d.ts +1 -0
  248. package/shared/dist/protocol/workflows.js +0 -2
  249. package/shared/src/protocol/clusters.ts +23 -5
  250. package/shared/src/protocol/compare.ts +2 -2
  251. package/shared/src/protocol/models.ts +8 -4
  252. package/shared/src/protocol/operatorQuestions.ts +2 -1
  253. package/shared/src/protocol/settings.ts +8 -1
  254. package/shared/src/protocol/workflows.ts +1 -1
@@ -9,7 +9,7 @@
9
9
  <link rel="preconnect" href="https://fonts.googleapis.com" />
10
10
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
11
11
  <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Share+Tech+Mono&display=swap" rel="stylesheet" />
12
- <script type="module" crossorigin src="/assets/index-BjDmFvqG.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-j68SfA-l.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-CVJVD2Vn.css">
14
14
  </head>
15
15
  <body>
@@ -836,7 +836,7 @@ ${scopeBody}
836
836
  onUpdatePrimary={(update) => {
837
837
  // Same optimistic-then-persist shape the workbench CONFIG tab
838
838
  // uses; the chat header is just a smaller surface onto it.
839
- updateJobPrimary(activeJob.id, update);
839
+ if ((activeJob.config.primaryProvider ?? 'claude') !== 'claude' || !('providerAccountRef' in update)) updateJobPrimary(activeJob.id, update);
840
840
  updatePrimaryConfig(activeJob.id, update);
841
841
  }}
842
842
  />
@@ -912,7 +912,7 @@ ${scopeBody}
912
912
  }}
913
913
  onUpdatePrimary={(update) => {
914
914
  // Optimistic local update, then WS notifies server to persist.
915
- updateJobPrimary(activeJob.id, update);
915
+ if ((activeJob.config.primaryProvider ?? 'claude') !== 'claude' || !('providerAccountRef' in update)) updateJobPrimary(activeJob.id, update);
916
916
  updatePrimaryConfig(activeJob.id, update);
917
917
  }}
918
918
  onLoadEarlier={() => loadEarlierMessages(activeJob.id)}
@@ -5,7 +5,7 @@ import { LoginFlow } from './LoginFlow';
5
5
  import { checkProviderStatus } from '../utils/providerStatusCheck';
6
6
  import { NativeLoginControls } from './NativeLoginControls';
7
7
  import { sameRecoveryBinding, useClaudeNativeLogin } from '../hooks/useClaudeNativeLogin';
8
- import { selectedClaudeTransport } from '../utils/claudeAuth';
8
+ import { nativeAccountStatus, selectedClaudeTransport } from '../utils/claudeAuth';
9
9
  import { useAppStore } from '../stores/appStore';
10
10
 
11
11
  // Recognize `[AUTH:<provider>] <body>` sentinel lines produced by:
@@ -44,11 +44,12 @@ export function AuthReloginNotice({ provider, body, workflowId, messageId, authR
44
44
  const [origin] = useState(() => {
45
45
  const store = useAppStore.getState(), job = workflowId ? store.jobs[workflowId] : undefined;
46
46
  const transport = authRecovery?.transport ?? selectedClaudeTransport(job?.config.claudeTransport, store.settings?.claude?.transport, !!job?.config.ultracode);
47
- return { transport, accountRef: job?.config.providerAccountRef, binding: authRecovery?.binding ?? (transport === 'native' ? store.authStatus?.claude?.native?.binding : store.authStatus?.claude?.cli?.binding) };
47
+ const accountRef = authRecovery?.accountRef ?? job?.config.providerAccountRef;
48
+ return { transport, accountRef, binding: authRecovery?.binding ?? (transport === 'native' ? nativeAccountStatus(store.authStatus?.claude, accountRef)?.binding : store.authStatus?.claude?.cli?.binding) };
48
49
  });
49
50
  const job = useAppStore(s => workflowId ? s.jobs[workflowId] : undefined);
50
- const currentNative = useAppStore(s => s.authStatus?.claude?.native);
51
- const nativeLogin = useClaudeNativeLogin(`notice:${workflowId ?? 'unknown'}:${messageId ?? body}`, workflowId, origin.binding);
51
+ const currentNative = useAppStore(s => nativeAccountStatus(s.authStatus?.claude, origin.accountRef));
52
+ const nativeLogin = useClaudeNativeLogin(`notice:${workflowId ?? 'unknown'}:${messageId ?? body}`, workflowId, origin.binding, origin.accountRef);
52
53
  const claudeNative = provider === 'claude' && origin.transport === 'native';
53
54
  const complete = claudeNative && nativeLogin.session?.flow?.status === 'complete'
54
55
  && nativeLogin.session.flow.workflowId === workflowId
@@ -150,7 +151,7 @@ export function AuthReloginNotice({ provider, body, workflowId, messageId, authR
150
151
  >
151
152
  {complete ? 'Native sign-in completed for this recovery. Review the original workflow before continuing; earlier actions may already have run.' : body}
152
153
  </span>
153
- <button
154
+ {!authRecovery?.accountUnavailable && <button
154
155
  onClick={complete ? () => { if (workflowId && useAppStore.getState().jobs[workflowId]) useAppStore.getState().setActiveJob(workflowId); } : startLogin}
155
156
  disabled={state === 'pending' || nativeLogin.session?.busy || (complete && !job)}
156
157
  className="display-font glow-border"
@@ -168,7 +169,7 @@ export function AuthReloginNotice({ provider, body, workflowId, messageId, authR
168
169
  }}
169
170
  >
170
171
  {complete ? 'REVIEW ORIGINAL WORKFLOW' : state === 'pending' ? 'STARTING...' : state === 'sent' ? `RE-LOGIN ${label}` : `RE-LOGIN ${label}`}
171
- </button>
172
+ </button>}
172
173
  </div>
173
174
  {hint && (
174
175
  <div
@@ -23,7 +23,7 @@ import { LongUserMessage } from './LongUserMessage';
23
23
  import { AttachmentPill } from './AttachmentPill';
24
24
  import { FileViewerModal } from './FileViewerModal';
25
25
  import { linkifyText } from '../utils/linkify';
26
- import { linkTextFiles, looksLikeFilename, resolveChatFilePath, type WrittenFilesIndex } from '../utils/chatFileLinks';
26
+ import { chatLinkTarget, linkTextFiles, looksLikeFilename, resolveChatFilePath, type WrittenFilesIndex } from '../utils/chatFileLinks';
27
27
  export type { WrittenFilesIndex };
28
28
  import { useOperatorLabel } from '../utils/operatorLabel';
29
29
  import { useTerminalStore } from '../stores/terminalStore';
@@ -95,9 +95,10 @@ function hasMarkdownFileRef(text: string): boolean {
95
95
  return MARKDOWN_FILE_REF_RE.test(text);
96
96
  }
97
97
 
98
- // A Windows drive path in a Markdown link is a local viewer target.
98
+ // A Windows drive path or a local `file:` URL in a Markdown link is a local
99
+ // viewer target; the link component resolves it through the authorized viewer.
99
100
  function chatMarkdownUrl(url: string, key: string): string {
100
- return key === 'href' && /^[A-Za-z]:[\\/]/.test(url) ? url : defaultUrlTransform(url);
101
+ return key === 'href' && (/^[A-Za-z]:[\\/]/.test(url) || /^file:/i.test(url)) ? url : defaultUrlTransform(url);
101
102
  }
102
103
 
103
104
  // Extract pure text from a ReactMarkdown children prop. Markdown headings /
@@ -248,6 +249,9 @@ interface Props {
248
249
  message: ChatMessageType;
249
250
  jobId?: string;
250
251
  jobCwd?: string;
252
+ sourceWorkflowId?: string;
253
+ onOpenFile?: (path: string) => void;
254
+ preserveLineBreaks?: boolean;
251
255
  // Built once per workflow in ChatPanel from every Read/Write/Edit tool call.
252
256
  // Powers chat-text filename clicks: when an agent writes a Write to
253
257
  // `<cwd>/reports/audit.md` and then says "I wrote `audit.md`", the resolver
@@ -272,7 +276,7 @@ interface Props {
272
276
  onRetryMessage?: (text: string, attachments?: string[]) => void;
273
277
  }
274
278
 
275
- function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued, onMakeTask, presentation = 'workbench', retryText, retryAttachments, onEditMessage, onRetryMessage }: Props) {
279
+ function ChatMessageInner({ message, jobId, jobCwd, sourceWorkflowId, onOpenFile, preserveLineBreaks = false, writtenFiles, onCancelQueued, onMakeTask, presentation = 'workbench', retryText, retryAttachments, onEditMessage, onRetryMessage }: Props) {
276
280
  const isAntigravity = useAppStore(s => !!jobId && s.jobs[jobId]?.config.primaryProvider === 'antigravity-cli');
277
281
  const latestSeedId = useAppStore(s => jobId ? latestHandoffSeed(s.jobs[jobId]?.messages ?? [])?.id : undefined);
278
282
  const batchQuestionClosed = useAppStore((s) => {
@@ -333,7 +337,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
333
337
  // visual variant; deliberately not collapsed into the existing tool-call
334
338
  // pill rendering (per Phase 2 brief).
335
339
  if (message.role === 'peer-sent' || message.role === 'peer-received') {
336
- return <PeerMessageBlock message={message} jobId={jobId} onMakeTask={onMakeTask} />;
340
+ return <PeerMessageBlock message={message} jobId={jobId} jobCwd={jobCwd} onMakeTask={onMakeTask} />;
337
341
  }
338
342
 
339
343
  // docs/PROVIDERS.md - ctx_action ledger divider. Synthetic
@@ -430,7 +434,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
430
434
  return cleanPrimaryText(message.content);
431
435
  }, [isAssistant, message.content]);
432
436
  const displayContent = cleaned ? cleaned.text : message.content;
433
- const renderSystemMarkdown = isSystem && hasMarkdownFileRef(displayContent);
437
+ const renderSystemMarkdown = (isSystem || isUser) && hasMarkdownFileRef(displayContent);
434
438
 
435
439
  // Filename auto-link: any markdown heading / inline `code` / `[link]` / image
436
440
  // whose text resolves to a project file opens FileViewerModal.
@@ -442,7 +446,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
442
446
  const fileLinkDownRef = useRef<{ x: number; y: number } | null>(null);
443
447
  const markdownComponents = useMemo<Components>(() => {
444
448
  const FileLink = ({ filePath, children }: { filePath: string; children: React.ReactNode }) => {
445
- // Plain inline span — no role="button"/tabIndex. Browsers treat
449
+ // The previous implementation used a plain inline span — no role="button"/tabIndex. Browsers treat
446
450
  // role="button" elements as interactive widgets and exclude them when
447
451
  // building a text selection across mixed inline content, which made
448
452
  // file-link pills the only thing in the chat that wouldn't highlight
@@ -450,7 +454,8 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
450
454
  // we detect click vs drag via mousedown/mouseup coordinate delta, not
451
455
  // via accessibility roles. (Lost keyboard activation of the modal —
452
456
  // worth it; the modal is reachable other ways and the loss is small.)
453
- const open = () => setViewerPath(filePath);
457
+ // The link role now restores keyboard access while retaining drag detection.
458
+ const open = () => onOpenFile ? onOpenFile(filePath) : setViewerPath(filePath);
454
459
  const handleMouseDown = (e: React.MouseEvent<HTMLSpanElement>) => {
455
460
  fileLinkDownRef.current = { x: e.clientX, y: e.clientY };
456
461
  };
@@ -466,6 +471,9 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
466
471
  };
467
472
  return (
468
473
  <span
474
+ role="link"
475
+ tabIndex={0}
476
+ onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); } }}
469
477
  onMouseDown={handleMouseDown}
470
478
  onMouseUp={handleMouseUp}
471
479
  title={filePath}
@@ -479,16 +487,16 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
479
487
  </span>
480
488
  );
481
489
  };
482
- // strict = inside a sentence: only files the agent wrote or the workflow's
490
+ // Previously strict = inside a sentence: only files the agent wrote or the workflow's
483
491
  // artifacts folder; otherwise (a whole line) any filename resolves.
484
- const resolveText = (name: string, strict: boolean): string | null => {
485
- if (strict) {
486
- if (!writtenFiles) return null;
487
- const s = name.startsWith('./') ? name.slice(2) : name;
488
- if (!writtenFiles.byTail.has(s) && !writtenFiles.byBasename.has(s.split(/[\\/]/).pop() || '')) return null;
489
- }
490
- return resolveChatFilePath(name, jobCwd, writtenFiles);
492
+ // The server now checks all filename mentions and resolves ambiguity.
493
+ const resolveMention = (name: string): string | null => {
494
+ // Only an unambiguous bare-name index entry is evidence; explicit paths
495
+ // and Markdown destinations always reach the server as written.
496
+ const evidence = !/[\\/]/.test(name) ? writtenFiles : undefined;
497
+ return resolveChatFilePath(name, jobCwd, evidence);
491
498
  };
499
+ const resolveText = (name: string): string | null => resolveMention(name);
492
500
  const renderTextLink = (filePath: string, label: React.ReactNode, key: string) => (
493
501
  <FileLink key={key} filePath={filePath}>{label}</FileLink>
494
502
  );
@@ -496,7 +504,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
496
504
  (Tag: 'h1' | 'h2' | 'h3'): Components[typeof Tag] =>
497
505
  ({ node: _node, children, ...props }) => {
498
506
  const text = nodeToText(children);
499
- const resolved = looksLikeFilename(text) ? resolveChatFilePath(text, jobCwd, writtenFiles) : null;
507
+ const resolved = looksLikeFilename(text) ? resolveMention(text) : null;
500
508
  return (
501
509
  <Tag {...props}>
502
510
  {resolved ? <FileLink filePath={resolved}>{children}</FileLink> : children}
@@ -508,11 +516,12 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
508
516
  <CopyablePre {...props} workflowId={jobId}>{children}</CopyablePre>
509
517
  ),
510
518
  a: ({ node: _node, href, children, ...props }) => {
511
- let target = href;
512
519
  // Markdown encodes local URL characters, including spaces in a checkout name.
513
- try { if (href) target = decodeURIComponent(href); } catch { /* keep the original spelling */ }
514
- const resolved = target ? resolveChatFilePath(target, jobCwd, writtenFiles) : null;
520
+ const resolved = href ? resolveChatFilePath(chatLinkTarget(href), jobCwd) : null;
515
521
  if (resolved) return <FileLink filePath={resolved}>{children}</FileLink>;
522
+ // A refused or emptied link stays text: an empty href would open the
523
+ // Arco page itself, and a local path outside the viewer is never opened.
524
+ if (!href || /^file:/i.test(href)) return <span title={href ? 'This file link cannot be opened here.' : undefined}>{children}</span>;
516
525
  return <a {...props} href={href} target="_blank" rel="noopener noreferrer">{children}</a>;
517
526
  },
518
527
  p: ({ node: _node, children, ...props }) => (
@@ -530,19 +539,19 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
530
539
  return <code className={className} {...props}>{children}</code>;
531
540
  }
532
541
  const text = nodeToText(children);
533
- const resolved = looksLikeFilename(text) ? resolveChatFilePath(text, jobCwd, writtenFiles) : null;
542
+ const resolved = looksLikeFilename(text) ? resolveMention(text) : null;
534
543
  if (resolved) {
535
544
  return <code {...props}><FileLink filePath={resolved}>{children}</FileLink></code>;
536
545
  }
537
546
  return <code {...props}>{children}</code>;
538
547
  },
539
548
  img: ({ node: _node, src, alt, ...props }) => {
540
- const resolved = typeof src === 'string' ? resolveChatFilePath(src, jobCwd, writtenFiles) : null;
549
+ const resolved = typeof src === 'string' ? resolveChatFilePath(src, jobCwd) : null;
541
550
  if (resolved) {
542
551
  return (
543
552
  <button
544
553
  type="button"
545
- onClick={() => setViewerPath(resolved)}
554
+ onClick={() => onOpenFile ? onOpenFile(resolved) : setViewerPath(resolved)}
546
555
  title={resolved}
547
556
  style={{ background: 'transparent', border: 'none', padding: 0, cursor: 'pointer' }}
548
557
  >
@@ -553,7 +562,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
553
562
  return <img {...props} src={src} alt={alt} />;
554
563
  },
555
564
  };
556
- }, [jobCwd, writtenFiles, jobId]);
565
+ }, [jobCwd, writtenFiles, jobId, onOpenFile]);
557
566
 
558
567
  const operatorLabel = useOperatorLabel();
559
568
  if (isSystem && /^\[SKILL\] (Applied|Loaded): /.test(message.content)) {
@@ -704,7 +713,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
704
713
  ? 'var(--color-accent-secondary-dim)'
705
714
  : 'var(--color-accent-primary)',
706
715
  fontStyle: isSystem ? 'italic' : 'normal',
707
- whiteSpace: isAssistant || renderSystemMarkdown ? 'normal' : 'pre-wrap',
716
+ whiteSpace: preserveLineBreaks ? 'pre-line' : isAssistant || renderSystemMarkdown ? 'normal' : 'pre-wrap',
708
717
  wordBreak: 'break-word',
709
718
  fontSize: isSystem ? '12px' : '14px',
710
719
  lineHeight: '1.7',
@@ -765,7 +774,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
765
774
  // but still need bare URLs to be clickable. Linkify emits a mix
766
775
  // of strings and <a> tags — inline inside the pre-wrap container
767
776
  // so newlines/whitespace are preserved untouched.
768
- linkifyText(displayContent)
777
+ linkTextFiles(linkifyText(displayContent), (name) => resolveChatFilePath(name, jobCwd, !/[\\/]/.test(name) ? writtenFiles : undefined), (path, label, key) => <span key={key} role="link" tabIndex={0} title={path} onClick={() => setViewerPath(path)} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setViewerPath(path); } }} style={{ cursor: 'pointer', textDecoration: 'underline dotted' }}>{label}</span>)
769
778
  )}
770
779
  {isUser && message.attachments && message.attachments.length > 0 && (
771
780
  <div
@@ -793,7 +802,7 @@ function ChatMessageInner({ message, jobId, jobCwd, writtenFiles, onCancelQueued
793
802
  <FileViewerModal
794
803
  path={viewerPath}
795
804
  onClose={() => setViewerPath(null)}
796
- fallback={jobCwd && jobId ? { cwd: jobCwd, workflowId: jobId } : undefined}
805
+ fallback={jobCwd && jobId ? { cwd: jobCwd, workflowId: jobId, sourceWorkflowId } : undefined}
797
806
  />
798
807
  )}
799
808
  </div>
@@ -906,7 +915,7 @@ function hashSenderColor(senderWorkflowId: string | undefined): string {
906
915
  return PEER_COLORS[Math.abs(h) % PEER_COLORS.length];
907
916
  }
908
917
 
909
- function PeerMessageBlock({ message, jobId, onMakeTask }: { message: ChatMessageType; jobId?: string; onMakeTask?: (content: string, fromWorkflowId: string) => void }) {
918
+ function PeerMessageBlock({ message, jobId, jobCwd, onMakeTask }: { message: ChatMessageType; jobId?: string; jobCwd?: string; onMakeTask?: (content: string, fromWorkflowId: string) => void }) {
910
919
  const selected = useMessageSelectionStore((s) => !!jobId && (s.selected[jobId]?.includes(message.id) ?? false));
911
920
  // Mobile view: a long press selects the message; there is no selection box.
912
921
  const phone = usePhoneLayout();
@@ -914,6 +923,7 @@ function PeerMessageBlock({ message, jobId, onMakeTask }: { message: ChatMessage
914
923
  const pressProps = useLongPressSelect(phone && !!jobId && true, selecting, () => { if (jobId) useMessageSelectionStore.getState().toggle(jobId, message.id); });
915
924
  const isSent = message.role === 'peer-sent';
916
925
  const [open, setOpen] = useState(false);
926
+ const [peerViewer, setPeerViewer] = useState<string | null>(null);
917
927
  const openButton = useRef<HTMLButtonElement>(null);
918
928
  const senderColor = hashSenderColor(message.senderWorkflowId);
919
929
  const arrow = isSent ? '→' : '←';
@@ -1009,8 +1019,10 @@ function PeerMessageBlock({ message, jobId, onMakeTask }: { message: ChatMessage
1009
1019
  <p>From: {isSent ? selfLabel : senderLabel}<br />To: {isSent ? senderLabel : selfLabel}<br />
1010
1020
  {message.timestamp ? `Sent: ${new Date(message.timestamp).toLocaleString()}` : 'Time unavailable'}</p>
1011
1021
  {isSent && message.peerFullContent === undefined && <p>Only the saved preview is available for this older sent message.</p>}
1012
- <div style={{ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }}>{isSent ? (message.peerFullContent ?? message.content) : message.content}</div>
1022
+ <ChatMessageInner message={{ ...message, role: 'assistant', content: isSent ? (message.peerFullContent ?? message.content) : message.content }} jobId={jobId} jobCwd={jobCwd} preserveLineBreaks onOpenFile={(path) => { setOpen(false); setPeerViewer(path); }} />
1013
1023
  </DialogShell>}
1024
+ {peerViewer && <FileViewerModal path={peerViewer} onClose={() => { setPeerViewer(null); setOpen(true); }}
1025
+ fallback={jobCwd && jobId ? { cwd: jobCwd, workflowId: jobId, sourceWorkflowId: isSent ? jobId : message.senderWorkflowId } : undefined} />}
1014
1026
  </>);
1015
1027
  }
1016
1028
 
@@ -137,23 +137,36 @@ export function ChatPanel({ job, onCancelQueued, onLoadEarlier, clusterContext,
137
137
  const writtenFiles = useMemo(() => {
138
138
  const byBasename = new Map<string, string>();
139
139
  const byTail = new Map<string, string>();
140
+ const ambiguousBasenames = new Set<string>();
141
+ const ambiguousTails = new Set<string>();
142
+ const addUnique = (map: Map<string, string>, ambiguous: Set<string>, key: string, value: string) => {
143
+ if (ambiguous.has(key)) return;
144
+ const previous = map.get(key);
145
+ if (previous && previous !== value) { map.delete(key); ambiguous.add(key); }
146
+ else map.set(key, value);
147
+ };
148
+ for (const fp of job.writtenFilePaths ?? []) {
149
+ const base = fp.split(/[\\/]/).pop() || '';
150
+ if (base) { addUnique(byBasename, ambiguousBasenames, base, fp); addUnique(byTail, ambiguousTails, base, fp); }
151
+ }
140
152
  for (const m of displayMessages) {
141
153
  const fp = m.toolUse?.filePath;
142
154
  if (typeof fp !== 'string' || !fp) continue;
143
155
  const base = fp.split(/[\\/]/).pop() || '';
144
- if (base) byBasename.set(base, fp);
156
+ if (base) addUnique(byBasename, ambiguousBasenames, base, fp);
145
157
  // Index "trailing-N-segments" → full path so a chat reference like
146
158
  // `reports/audit.md` resolves even when the recorded path is absolute.
147
159
  const segs = fp.split(/[\\/]/).filter(Boolean);
148
160
  for (let i = 1; i <= Math.min(segs.length, 4); i++) {
149
- byTail.set(segs.slice(-i).join('/'), fp);
161
+ addUnique(byTail, ambiguousTails, segs.slice(-i).join('/'), fp);
150
162
  }
151
163
  }
152
164
  for (const o of artifactFiles) {
153
- if (!byBasename.has(o.name)) byBasename.set(o.name, o.path);
165
+ addUnique(byBasename, ambiguousBasenames, o.name, o.path);
166
+ addUnique(byTail, ambiguousTails, o.name, o.path);
154
167
  }
155
168
  return { byBasename, byTail };
156
- }, [displayMessages, artifactFiles]);
169
+ }, [displayMessages, artifactFiles, job.writtenFilePaths]);
157
170
 
158
171
  // §10.7 follow-up — transcript peer→task bridge. The MAILBOX modal's → TASK
159
172
  // only catches the undelivered window; once a peer message is delivered it
@@ -0,0 +1,32 @@
1
+ import { DEFAULT_CLAUDE_NATIVE_ACCOUNT } from '@arco/shared';
2
+ import type { CSSProperties } from 'react';
3
+ import { useAppStore } from '../stores/appStore';
4
+ import { nativeAccountStatus } from '../utils/claudeAuth';
5
+
6
+ export function ClaudeNativeAccountPicker({ value, onChange, disabled, style, labelStyle }: {
7
+ value?: string;
8
+ onChange?: (accountRef: string) => void;
9
+ disabled?: boolean;
10
+ style?: CSSProperties;
11
+ labelStyle?: CSSProperties;
12
+ }) {
13
+ const settings = useAppStore(s => s.settings);
14
+ const auth = useAppStore(s => s.authStatus?.claude);
15
+ const profiles = settings?.providerAccounts?.claudeNative ?? [];
16
+ const selected = value ?? DEFAULT_CLAUDE_NATIVE_ACCOUNT;
17
+ const legacy = settings?.providerAccounts?.claude?.find(profile => profile.id === selected);
18
+ const missing = selected !== DEFAULT_CLAUDE_NATIVE_ACCOUNT && (!profiles.some(p => p.id === selected) || !!legacy);
19
+ const accounts = [{ id: DEFAULT_CLAUDE_NATIVE_ACCOUNT, label: 'Default' }, ...profiles.filter(profile =>
20
+ !settings?.providerAccounts?.claude?.some(old => old.id === profile.id))];
21
+ return <label data-help="claude-native.account-picker" style={{ display: 'grid', gap: 4, minWidth: 0 }}>
22
+ <span className="display-font" style={{ color: 'var(--color-fg-muted)', fontFamily: 'var(--font-display)', ...labelStyle }}>CLAUDE NATIVE ACCOUNT</span>
23
+ <select value={selected} disabled={disabled || !onChange} onChange={e => onChange?.(e.target.value)}
24
+ style={{ width: '100%', minWidth: 0, color: 'var(--color-fg)', background: 'var(--color-bg-input)', border: '1px solid var(--color-border-hairline)', fontFamily: 'var(--font-body)', fontSize: '11px', ...style }}>
25
+ {missing && <option value={selected} disabled>{legacy ? `${legacy.label} (old label)` : 'Unavailable account'}</option>}
26
+ {accounts.map(({ id, label }) => {
27
+ const status = nativeAccountStatus(auth, id);
28
+ return <option key={id} value={id}>{label}{status?.state === 'missing' ? ' (signed out)' : status?.state === 'needs-attention' ? ' (sign-in needed)' : ''}</option>;
29
+ })}
30
+ </select>
31
+ </label>;
32
+ }
@@ -1,31 +1,38 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
  import { useClaudeNativeLogin } from '../hooks/useClaudeNativeLogin';
3
3
  import { NativeLoginControls } from './NativeLoginControls';
4
- import { nativeAuthText } from '../utils/claudeAuth';
4
+ import type { ArcoSettings, AuthStatusByProvider, ClaudeNativeAuthStatus, ProviderAccountProfile } from '@arco/shared';
5
+ import { useAppStore } from '../stores/appStore';
6
+ import { nativeAccountStatus, nativeAuthText } from '../utils/claudeAuth';
5
7
 
6
8
  // Claude Native sign-in shares its flow lifecycle with inline recovery. POST /api/auth/claude-native/login kicks off PKCE; on a
7
9
  // machine where the local callback (port 53692) can bind, the operator's
8
10
  // browser hits it directly. When EADDRINUSE / sandbox-block lands, we
9
11
  // surface a manual-paste field so the operator can hand back the
10
12
  // redirected URL.
11
- export function ClaudeNativeAuthRow() {
12
- const [status, setStatus] = useState<(import('@arco/shared').ClaudeNativeAuthStatus & { loggedIn: boolean }) | null>(null);
13
+ export function ClaudeNativeAuthRow({ profile, connections = false }: { profile?: ProviderAccountProfile; connections?: boolean }) {
14
+ const accountRef = profile?.id;
15
+ const path = '/api/auth/claude-native';
16
+ const query = accountRef ? `?account=${encodeURIComponent(accountRef)}` : '';
17
+ const observed = useAppStore(s => nativeAccountStatus(s.authStatus?.claude, accountRef));
18
+ const [status, setStatus] = useState<ClaudeNativeAuthStatus | null>(null);
13
19
  const [busy, setBusy] = useState<'logout' | null>(null);
14
- const login = useClaudeNativeLogin('settings-native', undefined, status?.binding);
20
+ const latestStatus = observed && (!status || observed.checkedAt >= status.checkedAt) ? observed : status;
21
+ const login = useClaudeNativeLogin(`native-account:${accountRef ?? 'default'}`, undefined, latestStatus?.binding, accountRef);
15
22
  const [error, setError] = useState<string | null>(null);
16
23
 
17
24
  const request = useRef(0);
18
25
  const refresh = async () => {
19
26
  const id = ++request.current;
20
27
  try {
21
- const res = await fetch('/api/auth/claude-native', { cache: 'no-store' });
28
+ const res = await fetch(path + query, { cache: 'no-store' });
22
29
  if (!res.ok) return;
23
- const data = (await res.json()) as import('@arco/shared').ClaudeNativeAuthStatus & { loggedIn: boolean };
30
+ const data = (await res.json()) as ClaudeNativeAuthStatus;
24
31
  if (id === request.current) setStatus(data);
25
32
  } catch { /* leave stale */ }
26
33
  };
27
34
 
28
- useEffect(() => { void refresh(); return () => { request.current++; }; }, []);
35
+ useEffect(() => { void refresh(); return () => { request.current++; }; }, [accountRef]);
29
36
 
30
37
  useEffect(() => { if (login.session?.flow?.status === 'complete') void refresh(); }, [login.session?.flow?.id, login.session?.flow?.status]);
31
38
 
@@ -34,43 +41,45 @@ export function ClaudeNativeAuthRow() {
34
41
  setBusy('logout');
35
42
  setError(null);
36
43
  try {
37
- const res = await fetch('/api/auth/claude-native/logout', { method: 'POST' });
44
+ const res = await fetch(path + '/logout' + query, { method: 'POST' });
38
45
  if (!res.ok) {
39
46
  const data = (await res.json().catch(() => ({}))) as { error?: string };
40
47
  setError(data.error || `HTTP ${res.status}`);
41
48
  return;
42
49
  }
43
50
  await refresh();
51
+ void fetch('/api/auth-status', { cache: 'no-store' }).then(async response => {
52
+ if (response.ok) useAppStore.getState().setAuthStatus(await response.json() as AuthStatusByProvider);
53
+ }).catch(() => {});
44
54
  } catch (err) {
45
55
  setError(err instanceof Error ? err.message : String(err));
46
56
  } finally { setBusy(null); }
47
57
  };
48
58
 
49
- const nativeNeedsAttention = status?.state === 'needs-attention';
50
- const subline = !status ? 'Checking Native credentials...' : nativeAuthText(status);
59
+ const nativeNeedsAttention = latestStatus?.state === 'needs-attention';
60
+ const subline = !latestStatus ? 'Checking Native credentials...' : nativeAuthText(latestStatus);
51
61
 
52
62
  return (
53
63
  <div style={{ padding: '8px 10px', border: '1px solid var(--color-border-hairline)', borderRadius: '3px', display: 'flex', flexDirection: 'column', gap: '6px' }}>
54
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: '10px' }}>
64
+ <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: '10px' }}>
55
65
  <div style={{ display: 'flex', flexDirection: 'column', minWidth: 0 }}>
56
66
  <span className="display-font" style={{ fontSize: '11px', letterSpacing: '1.5px', color: 'var(--color-accent-primary)' }}>
57
- CLAUDE NATIVE (OAUTH)
67
+ {profile?.label ?? 'CLAUDE NATIVE (DEFAULT)'}
58
68
  </span>
59
- <span style={{ fontSize: '10px', color: status?.loggedIn ? 'var(--color-accent-primary-dim)' : 'var(--color-warning-dim)', fontFamily: 'var(--font-body)' }}>
69
+ <span style={{ fontSize: '10px', color: latestStatus?.credentialsPresent ? 'var(--color-accent-primary-dim)' : 'var(--color-warning-dim)', fontFamily: 'var(--font-body)' }}>
60
70
  {subline}
61
71
  </span>
62
- <span style={{ fontSize: '10px', color: 'var(--color-fg-muted)' }}>One Native credential store per Arco home. Profile names do not select separate Native credentials.</span>
63
- {status?.expiresAt && <span style={{ fontSize: '10px', color: 'var(--color-fg-muted)' }}>Local expiry metadata: {new Date(status.expiresAt).toLocaleString()}</span>}
72
+ {latestStatus?.expiresAt && <span style={{ fontSize: '10px', color: 'var(--color-fg-muted)' }}>Local expiry metadata: {new Date(latestStatus.expiresAt).toLocaleString()}</span>}
64
73
  </div>
65
74
  <div style={{ display: 'flex', gap: '6px' }}>
66
- {status?.loggedIn && (
75
+ {latestStatus?.credentialsPresent && (
67
76
  <button onClick={logout} disabled={!!busy} className="display-font" style={{ padding: '4px 10px', fontSize: '10px', letterSpacing: '1px', background: 'transparent', border: '1px solid var(--color-border-hairline)', color: 'var(--color-fg-muted)', borderRadius: '3px', cursor: busy ? 'default' : 'pointer' }}>
68
77
  {busy === 'logout' ? '...' : 'LOGOUT'}
69
78
  </button>
70
79
  )}
71
- {(!status?.loggedIn || nativeNeedsAttention) && (
72
- <button onClick={() => { void login.start(); }} disabled={!!busy || login.session?.busy} className="display-font" style={{ padding: '4px 10px', fontSize: '10px', letterSpacing: '1px', background: 'transparent', border: '1px solid var(--color-accent-primary)', color: 'var(--color-accent-primary)', borderRadius: '3px', cursor: busy ? 'default' : 'pointer' }}>
73
- {login.session?.busy ? 'STARTING...' : 'LOGIN'}
80
+ {(!latestStatus?.credentialsPresent || nativeNeedsAttention) && (
81
+ <button data-testid={connections && !profile ? 'claude-native-signin' : undefined} onClick={() => { void login.start(); }} disabled={!!busy || login.session?.busy} className="display-font" style={{ padding: '4px 10px', fontSize: '10px', letterSpacing: '1px', background: 'transparent', border: '1px solid var(--color-accent-primary)', color: 'var(--color-accent-primary)', borderRadius: '3px', cursor: busy ? 'default' : 'pointer' }}>
82
+ {login.session?.busy ? 'STARTING...' : connections && !profile ? 'SIGN IN FOR NATIVE' : 'LOGIN'}
74
83
  </button>
75
84
  )}
76
85
  </div>
@@ -84,3 +93,46 @@ export function ClaudeNativeAuthRow() {
84
93
  </div>
85
94
  );
86
95
  }
96
+
97
+ export function ClaudeNativeAccounts({ connections = false }: { connections?: boolean }) {
98
+ const settings = useAppStore(s => s.settings);
99
+ const [edit, setEdit] = useState<{ id?: string; label: string } | null>(null);
100
+ const [saving, setSaving] = useState(false);
101
+ const [error, setError] = useState('');
102
+ const profiles = settings?.providerAccounts?.claudeNative ?? [];
103
+ const save = async () => {
104
+ if (!edit || saving) return;
105
+ setSaving(true);
106
+ setError('');
107
+ try {
108
+ const res = await fetch('/api/auth/claude-native/profiles', {
109
+ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(edit),
110
+ });
111
+ const data = await res.json() as ArcoSettings & { error?: string };
112
+ if (!res.ok) throw new Error(data.error || 'Could not save Claude Native account.');
113
+ useAppStore.getState().setSettings(data);
114
+ setEdit(null);
115
+ } catch (err) {
116
+ setError(err instanceof Error ? err.message : 'Could not save Claude Native account.');
117
+ } finally { setSaving(false); }
118
+ };
119
+ return <section data-help="claude-native.accounts" aria-label="Claude Native accounts" style={{ display: 'grid', gap: 8, minWidth: 0 }}>
120
+ <ClaudeNativeAuthRow connections={connections} />
121
+ {profiles.map(profile => <div key={profile.id} aria-label={`Claude Native account ${profile.label}`} style={{ minWidth: 0, overflowWrap: 'anywhere' }}>
122
+ <ClaudeNativeAuthRow profile={profile} />
123
+ <button type="button" disabled={saving} onClick={() => { setError(''); setEdit({ id: profile.id, label: profile.label }); }}>RENAME ACCOUNT</button>
124
+ </div>)}
125
+ {edit ? <div style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'end', gap: 6 }}>
126
+ <label style={{ display: 'grid', gap: 4, minWidth: 0 }}>
127
+ Account name
128
+ <input style={{ width: '100%', minWidth: 0 }} value={edit.label} maxLength={32} disabled={saving}
129
+ onChange={event => setEdit({ ...edit, label: event.target.value })}
130
+ onKeyDown={event => { if (event.key === 'Enter') { event.preventDefault(); void save(); } }} />
131
+ </label>
132
+ <button type="button" disabled={saving || !edit.label.trim()} onClick={() => void save()}>SAVE ACCOUNT</button>
133
+ <button type="button" disabled={saving} onClick={() => { setEdit(null); setError(''); }}>CANCEL</button>
134
+ </div> : <button type="button" style={{ justifySelf: 'start' }} disabled={profiles.length >= 8}
135
+ onClick={() => setEdit({ label: '' })}>ADD NATIVE ACCOUNT</button>}
136
+ {error && <span role="alert">{error}</span>}
137
+ </section>;
138
+ }