arco-workbench 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -1
- package/THIRD_PARTY_NOTICES +2 -2
- package/client/dist/assets/{PhosphorBackdrop-CHXVFLGT.js → PhosphorBackdrop-CLILIwOQ.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-Bhs4I9jA.js → ThemedBackgroundShaderImpl-B87chcb5.js} +1 -1
- package/client/dist/assets/{XtermView-CdfurwFx.js → XtermView-BP_j7WSN.js} +1 -1
- package/client/dist/assets/{galleryEditor-DYjZZ4cf.js → galleryEditor-B90phoBI.js} +1 -1
- package/client/dist/assets/{index-BjDmFvqG.js → index-BfPp1Oup.js} +269 -269
- package/client/dist/index.html +1 -1
- package/client/src/App.tsx +2 -2
- package/client/src/components/AuthReloginNotice.tsx +7 -6
- package/client/src/components/ChatMessage.tsx +41 -29
- package/client/src/components/ChatPanel.tsx +17 -4
- package/client/src/components/ClaudeNativeAccountPicker.tsx +32 -0
- package/client/src/components/ClaudeNativeAuthRow.tsx +71 -19
- package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +11 -281
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +1 -1
- package/client/src/components/ClusterRightPanel/FreshMemberForm.tsx +315 -0
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +17 -7
- package/client/src/components/ClusterRightPanel/index.tsx +1 -1
- package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +6 -4
- package/client/src/components/ClusterTab.tsx +2 -2
- package/client/src/components/Connections/Connections.tsx +5 -9
- package/client/src/components/Connections/model.ts +3 -1
- package/client/src/components/FileViewerModal.tsx +54 -17
- package/client/src/components/GitHubPanel/index.tsx +9 -5
- package/client/src/components/HandoffDialog.tsx +5 -3
- package/client/src/components/MobileShell.tsx +1 -33
- package/client/src/components/OperatorQuestionNotice.tsx +5 -4
- package/client/src/components/ProvidersPopover.tsx +6 -2
- package/client/src/components/RightPanel/ActivityTab.tsx +2 -1
- package/client/src/components/RightPanel/ConfigTab.tsx +23 -5
- package/client/src/components/RightPanel/OutputsPanel.tsx +21 -9
- package/client/src/components/RightPanel/outputsReconcile.ts +31 -0
- package/client/src/components/SettingsPanel.tsx +7 -10
- package/client/src/components/SpawnDialog.tsx +14 -3
- package/client/src/components/TabBar.tsx +2 -2
- package/client/src/components/TabContextMenu.tsx +73 -133
- package/client/src/components/TerminalInput.tsx +4 -3
- package/client/src/components/TranscriptWorkerDialog.tsx +14 -4
- package/client/src/components/UsageBar.tsx +37 -18
- package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +29 -3
- package/client/src/components/WorkflowCreator/index.tsx +29 -15
- package/client/src/components/WorkflowView.tsx +1 -1
- package/client/src/components/providerIndicator.ts +7 -3
- package/client/src/components/settings/GitHubAuthRow.tsx +34 -0
- package/client/src/explorer/ArtifactsLens.tsx +17 -8
- package/client/src/explorer/ExplorerApp.tsx +3 -3
- package/client/src/explorer/types.ts +3 -1
- package/client/src/help/content/cluster.tsx +10 -4
- package/client/src/help/content/composer.tsx +3 -2
- package/client/src/help/content/header.tsx +6 -3
- package/client/src/help/content/misc.tsx +7 -5
- package/client/src/help/content/rightPanel.tsx +8 -4
- package/client/src/help/content/settings.tsx +14 -3
- package/client/src/help/content/tabbar.tsx +1 -1
- package/client/src/help/manualSections/actions.tsx +5 -1
- package/client/src/help/manualSections/clusters.tsx +20 -14
- package/client/src/help/manualSections/configuration.tsx +6 -4
- package/client/src/help/manualSections/gettingStarted.tsx +4 -2
- package/client/src/help/manualSections/maintenance.tsx +24 -0
- package/client/src/help/manualSections/powerFeatures.tsx +1 -0
- package/client/src/help/manualSections/providers.tsx +11 -4
- package/client/src/help/manualSections/workspace.tsx +3 -3
- package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
- package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
- package/client/src/hooks/useWebSocket.ts +4 -2
- package/client/src/layout/layoutRange.ts +4 -5
- package/client/src/questions/waitingQuestion.ts +2 -0
- package/client/src/stores/appStore.ts +5 -1
- package/client/src/stores/appStore.types.ts +2 -0
- package/client/src/stores/replayContext.ts +20 -0
- package/client/src/utils/chatFileLinks.ts +34 -3
- package/client/src/utils/claudeAuth.ts +9 -1
- package/client/src/ws/handleServerMessage.ts +11 -3
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/BACKUP.md +1 -1
- package/docs/CLIENT.md +10 -5
- package/docs/EXTENDING.md +1 -1
- package/docs/FEATURES.md +3 -3
- package/docs/GETTING_STARTED.md +5 -4
- package/docs/GIT_WORKBENCH.md +8 -0
- package/docs/GLOSSARY.md +2 -2
- package/docs/GOTCHAS.md +4 -4
- package/docs/HTTP_API.md +54 -23
- package/docs/OPERATIONS.md +11 -0
- package/docs/OPERATOR_ACTIONS.md +2 -2
- package/docs/OUTPUTS.md +48 -6
- package/docs/PERSISTENCE.md +1 -1
- package/docs/PRIMITIVES.md +4 -2
- package/docs/PROTOCOL_CLUSTER.md +12 -6
- package/docs/PROTOCOL_PRIMITIVES.md +1 -1
- package/docs/PROVIDERS.md +46 -9
- package/docs/RESEARCH.md +1 -1
- package/docs/SETTINGS.md +9 -4
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
- package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
- package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
- package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/services.mjs +20 -1
- package/scripts/packaging/update.mjs +37 -2
- package/server/dist/attention.d.ts +6 -0
- package/server/dist/attention.js +6 -0
- package/server/dist/auth.d.ts +5 -0
- package/server/dist/auth.js +31 -20
- package/server/dist/clusterAutoTurn.d.ts +5 -1
- package/server/dist/clusterAutoTurn.js +31 -9
- package/server/dist/clusterPresets.js +3 -3
- package/server/dist/effortValidation.d.ts +2 -2
- package/server/dist/effortValidation.js +4 -4
- package/server/dist/explorerArtifacts.d.ts +1 -0
- package/server/dist/explorerArtifacts.js +12 -1
- package/server/dist/geminiMembers.d.ts +7 -1
- package/server/dist/geminiMembers.js +28 -14
- package/server/dist/http/conversationFiles.d.ts +36 -0
- package/server/dist/http/conversationFiles.js +222 -0
- package/server/dist/http/fileBytes.d.ts +3 -0
- package/server/dist/http/fileBytes.js +33 -0
- package/server/dist/http/fileContentRoute.d.ts +2 -0
- package/server/dist/http/fileContentRoute.js +139 -0
- package/server/dist/http/fileRead.d.ts +54 -2
- package/server/dist/http/fileRead.js +31 -24
- package/server/dist/http/outputRoutes.js +14 -21
- package/server/dist/http/readConfinement.d.ts +0 -11
- package/server/dist/http/readConfinement.js +4 -30
- package/server/dist/http/router.js +40 -66
- package/server/dist/index.js +26 -12
- package/server/dist/management/initHubLink.js +1 -1
- package/server/dist/outputs.js +8 -0
- package/server/dist/primitives/exportContext.d.ts +2 -0
- package/server/dist/primitives/exportContext.js +13 -2
- package/server/dist/primitives/runCompare.d.ts +7 -1
- package/server/dist/primitives/runCompare.js +44 -20
- package/server/dist/project/taskLedger.js +46 -34
- package/server/dist/providerAccounts.d.ts +4 -0
- package/server/dist/providerAccounts.js +20 -1
- package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
- package/server/dist/providers/antigravity/artifacts.js +140 -0
- package/server/dist/providers/antigravity/index.js +85 -7
- package/server/dist/providers/antigravity/questions.d.ts +2 -0
- package/server/dist/providers/antigravity/questions.js +58 -0
- package/server/dist/providers/claude-native/auth.d.ts +9 -8
- package/server/dist/providers/claude-native/auth.js +50 -58
- package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
- package/server/dist/providers/claude-native/authStatus.js +9 -7
- package/server/dist/providers/claude-native/catalog.d.ts +6 -5
- package/server/dist/providers/claude-native/catalog.js +50 -39
- package/server/dist/providers/claude-native/oauth.d.ts +10 -9
- package/server/dist/providers/claude-native/oauth.js +120 -96
- package/server/dist/providers/claude-native/worker.d.ts +1 -0
- package/server/dist/providers/claude-native/worker.js +38 -23
- package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
- package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
- package/server/dist/server/broadcast.js +6 -0
- package/server/dist/settings.d.ts +1 -0
- package/server/dist/settings.js +39 -7
- package/server/dist/skills.js +1 -1
- package/server/dist/smartPickupAdapters.d.ts +1 -0
- package/server/dist/smartPickupAdapters.js +2 -2
- package/server/dist/smartPickupObserver.js +8 -5
- package/server/dist/thirdPartySkills.js +11 -5
- package/server/dist/usage.d.ts +1 -1
- package/server/dist/usage.js +39 -27
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/processKill.js +37 -24
- package/server/dist/workflowMeta.js +2 -2
- package/server/dist/ws/clusterHandlers.d.ts +2 -2
- package/server/dist/ws/clusterHandlers.js +127 -113
- package/server/dist/ws/clusterMembers.d.ts +1 -1
- package/server/dist/ws/clusterMembers.js +34 -4
- package/server/dist/ws/compactHandlers.js +30 -14
- package/server/dist/ws/compareHandlers.js +53 -21
- package/server/dist/ws/gateHandlers.js +2 -0
- package/server/dist/ws/genesisHandlers.js +5 -3
- package/server/dist/ws/handoffHandlers.d.ts +1 -1
- package/server/dist/ws/handoffHandlers.js +115 -39
- package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
- package/server/dist/ws/turnEngine.js +33 -18
- package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
- package/server/dist/ws/updatePrimaryConfig.js +236 -133
- package/server/dist/ws/workflowHandlers.js +21 -4
- package/server/package.json +1 -1
- package/server/src/attention.ts +7 -0
- package/server/src/auth.ts +33 -20
- package/server/src/clusterAutoTurn.ts +31 -11
- package/server/src/clusterPresets.ts +2 -2
- package/server/src/effortValidation.ts +4 -4
- package/server/src/explorerArtifacts.ts +12 -1
- package/server/src/geminiMembers.ts +26 -15
- package/server/src/http/conversationFiles.ts +231 -0
- package/server/src/http/fileBytes.ts +34 -0
- package/server/src/http/fileContentRoute.ts +123 -0
- package/server/src/http/fileRead.ts +30 -25
- package/server/src/http/outputRoutes.ts +13 -13
- package/server/src/http/readConfinement.ts +3 -30
- package/server/src/http/router.ts +38 -62
- package/server/src/index.ts +27 -18
- package/server/src/management/initHubLink.ts +1 -1
- package/server/src/outputs.ts +8 -0
- package/server/src/primitives/exportContext.ts +14 -2
- package/server/src/primitives/runCompare.ts +73 -46
- package/server/src/project/taskLedger.ts +47 -30
- package/server/src/providerAccounts.ts +20 -1
- package/server/src/providers/antigravity/artifacts.ts +121 -0
- package/server/src/providers/antigravity/index.ts +64 -6
- package/server/src/providers/antigravity/questions.ts +52 -0
- package/server/src/providers/claude-native/auth.ts +45 -60
- package/server/src/providers/claude-native/authStatus.ts +9 -8
- package/server/src/providers/claude-native/catalog.ts +52 -35
- package/server/src/providers/claude-native/oauth.ts +101 -77
- package/server/src/providers/claude-native/worker.ts +38 -22
- package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
- package/server/src/server/broadcast.ts +4 -0
- package/server/src/settings.ts +36 -8
- package/server/src/skills.ts +1 -1
- package/server/src/smartPickupAdapters.ts +3 -2
- package/server/src/smartPickupObserver.ts +8 -5
- package/server/src/thirdPartySkills.ts +11 -5
- package/server/src/usage.ts +30 -22
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/processKill.ts +37 -23
- package/server/src/workflowMeta.ts +2 -2
- package/server/src/ws/clusterHandlers.ts +107 -104
- package/server/src/ws/clusterMembers.ts +25 -6
- package/server/src/ws/compactHandlers.ts +29 -15
- package/server/src/ws/compareHandlers.ts +59 -25
- package/server/src/ws/gateHandlers.ts +2 -0
- package/server/src/ws/genesisHandlers.ts +5 -4
- package/server/src/ws/handoffHandlers.ts +105 -37
- package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
- package/server/src/ws/turnEngine.ts +32 -17
- package/server/src/ws/updatePrimaryConfig.ts +230 -132
- package/server/src/ws/workflowHandlers.ts +20 -4
- package/shared/dist/protocol/clusters.d.ts +15 -3
- package/shared/dist/protocol/clusters.js +1 -1
- package/shared/dist/protocol/models.d.ts +6 -1
- package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
- package/shared/dist/protocol/settings.d.ts +3 -0
- package/shared/dist/protocol/settings.js +5 -0
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/dist/protocol/workflows.js +0 -2
- package/shared/src/protocol/clusters.ts +23 -5
- package/shared/src/protocol/compare.ts +2 -2
- package/shared/src/protocol/models.ts +8 -4
- package/shared/src/protocol/operatorQuestions.ts +2 -1
- package/shared/src/protocol/settings.ts +8 -1
- package/shared/src/protocol/workflows.ts +1 -1
package/client/dist/index.html
CHANGED
|
@@ -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-
|
|
12
|
+
<script type="module" crossorigin src="/assets/index-BfPp1Oup.js"></script>
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-CVJVD2Vn.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/client/src/App.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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) ?
|
|
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
|
-
|
|
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) ?
|
|
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
|
|
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
|
-
<
|
|
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
|
|
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
|
|
161
|
+
addUnique(byTail, ambiguousTails, segs.slice(-i).join('/'), fp);
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
164
|
for (const o of artifactFiles) {
|
|
153
|
-
|
|
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 {
|
|
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
|
|
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
|
|
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(
|
|
28
|
+
const res = await fetch(path + query, { cache: 'no-store' });
|
|
22
29
|
if (!res.ok) return;
|
|
23
|
-
const data = (await res.json()) as
|
|
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('/
|
|
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 =
|
|
50
|
-
const subline = !
|
|
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 (
|
|
67
|
+
{profile?.label ?? 'CLAUDE NATIVE (DEFAULT)'}
|
|
58
68
|
</span>
|
|
59
|
-
<span style={{ fontSize: '10px', color:
|
|
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)' }}>
|
|
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
|
-
{
|
|
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
|
-
{(!
|
|
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
|
+
}
|