arco-workbench 0.1.6 → 0.1.7

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 (57) hide show
  1. package/README.md +6 -1
  2. package/client/dist/assets/{PhosphorBackdrop-BR-TgB5x.js → PhosphorBackdrop-DVQdBrTw.js} +1 -1
  3. package/client/dist/assets/{ThemedBackgroundShaderImpl-DgcFj6JN.js → ThemedBackgroundShaderImpl-BfSs2tB4.js} +1 -1
  4. package/client/dist/assets/{XtermView-CflVBQgC.js → XtermView-DaMjC8Ny.js} +1 -1
  5. package/client/dist/assets/{galleryEditor-BB-emfmi.js → galleryEditor-BCQnXj7R.js} +1 -1
  6. package/client/dist/assets/{index-B_EqHDz3.js → index-COfbHCYv.js} +218 -218
  7. package/client/dist/index.html +1 -1
  8. package/client/src/buildCheck.ts +3 -1
  9. package/client/src/components/AppUpdateNotice.tsx +2 -1
  10. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +24 -12
  11. package/client/src/components/ClusterRightPanel/index.tsx +2 -1
  12. package/client/src/components/HeaderVersionBox.tsx +7 -4
  13. package/client/src/components/UpdateAction.tsx +18 -4
  14. package/client/src/components/UpdateResultNotice.tsx +3 -1
  15. package/client/src/help/content/cluster.tsx +16 -5
  16. package/client/src/help/content/header.tsx +3 -1
  17. package/client/src/help/content/rightPanel.tsx +1 -1
  18. package/client/src/help/content/settings.tsx +1 -1
  19. package/client/src/help/manualSections/clusters.tsx +17 -1
  20. package/client/src/help/manualSections/configuration.tsx +20 -4
  21. package/client/src/help/manualSections/maintenance.tsx +12 -0
  22. package/client/src/help/manualSections/plans.tsx +5 -1
  23. package/client/src/help/manualSections/workflows.tsx +7 -0
  24. package/client/src/stores/appUpdateStore.ts +29 -8
  25. package/client/src/utils/wsSession.ts +2 -1
  26. package/docs/GETTING_STARTED.md +5 -1
  27. package/docs/OPERATIONS.md +23 -0
  28. package/docs/PERSISTENCE.md +18 -1
  29. package/docs/PROTOCOL_CLUSTER.md +9 -2
  30. package/native/darwin-arm64/manifest.json +1 -1
  31. package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +3 -0
  32. package/node_modules/@arco/shared/package.json +1 -1
  33. package/package.json +2 -2
  34. package/scripts/packaging/native-repair.mjs +46 -8
  35. package/scripts/packaging/update.mjs +5 -1
  36. package/server/dist/clusterAutoTurn.d.ts +4 -0
  37. package/server/dist/clusterAutoTurn.js +29 -25
  38. package/server/dist/clusterBusyReminder.js +1 -1
  39. package/server/dist/clusterStore.d.ts +3 -0
  40. package/server/dist/clusterStore.js +22 -0
  41. package/server/dist/smartPickup.d.ts +2 -1
  42. package/server/dist/smartPickup.js +28 -1
  43. package/server/dist/smartPickupLedger.js +6 -4
  44. package/server/dist/smartPickupObserver.d.ts +1 -0
  45. package/server/dist/smartPickupObserver.js +24 -15
  46. package/server/dist/ws/clusterHandlers.d.ts +1 -0
  47. package/server/dist/ws/clusterHandlers.js +2 -1
  48. package/server/package.json +1 -1
  49. package/server/src/clusterAutoTurn.ts +26 -21
  50. package/server/src/clusterBusyReminder.ts +1 -1
  51. package/server/src/clusterStore.ts +26 -1
  52. package/server/src/smartPickup.ts +27 -3
  53. package/server/src/smartPickupLedger.ts +6 -4
  54. package/server/src/smartPickupObserver.ts +20 -11
  55. package/server/src/ws/clusterHandlers.ts +3 -2
  56. package/shared/dist/protocol/autoPickup.d.ts +3 -0
  57. package/shared/src/protocol/autoPickup.ts +5 -0
@@ -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-B_EqHDz3.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-COfbHCYv.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-DD9kFGsF.css">
14
14
  </head>
15
15
  <body>
@@ -24,6 +24,8 @@ export function startRecoveryGuard(): void {
24
24
  };
25
25
  document.addEventListener('input', mark, true);
26
26
  document.addEventListener('change', mark, true);
27
+ // A socket can reconnect before the old server stops, or its first probe can fail.
28
+ window.setInterval(() => { void checkBuild(); }, 10_000);
27
29
  }
28
30
 
29
31
  export function hasUnsavedWork(): boolean {
@@ -32,7 +34,7 @@ export function hasUnsavedWork(): boolean {
32
34
  return editedFields.size > 0 || Object.values(useDraftStore.getState().drafts).some((draft) => draft.length > 0)
33
35
  || Object.values(app.attachments).some((attachments) => attachments.length > 0)
34
36
  || Object.values(app.jobs).some((job) => job.config.incognito)
35
- || Boolean(document.querySelector('[role="dialog"], [data-dialog-shell], dialog[open], [contenteditable="true"]:focus'));
37
+ || Boolean(document.querySelector('[role="dialog"]:not([data-recovery-safe]), [data-dialog-shell], dialog[open], [contenteditable="true"]:focus'));
36
38
  }
37
39
 
38
40
  export function reportRecovery(reason: RecoveryReason): void {
@@ -5,11 +5,12 @@ import { useAppUpdateStore } from '../stores/appUpdateStore';
5
5
 
6
6
  export function AppUpdateNotice() {
7
7
  const notice = useAppUpdateStore((s) => s.notice);
8
+ const versionOpen = useAppUpdateStore((s) => s.versionOpen);
8
9
  const refresh = useAppUpdateStore((s) => s.refresh);
9
10
  const settings = useAppStore((s) => s.settings);
10
11
  const [saving, setSaving] = useState(false);
11
12
  useEffect(() => { void refresh().catch(() => {}); }, [refresh]);
12
- if (!notice || !settings || settings.updateCheck === false || settings.updateCheckDismissed === notice.latest) return null;
13
+ if (versionOpen || !notice || !settings || settings.updateCheck === false || settings.updateCheckDismissed === notice.latest) return null;
13
14
  const dismiss = async () => {
14
15
  setSaving(true);
15
16
  try {
@@ -60,15 +60,16 @@ function describeDecision(state: ClusterAutoPickupState): string | null {
60
60
  return `${when}: ${what}${d.action ? ` (${d.reason.replace(/_/g, ' ')}), ${d.outcome}` : ''}`;
61
61
  }
62
62
 
63
- function useSessionRemaining(expiresAt?: number): number | null {
63
+ function useSessionRemaining(expiresAt?: number, pausedAt?: number): number | null {
64
64
  const [now, setNow] = useState(Date.now);
65
65
  useEffect(() => {
66
66
  if (expiresAt === undefined) return;
67
67
  setNow(Date.now());
68
+ if (pausedAt !== undefined) return;
68
69
  const timer = setInterval(() => setNow(Date.now()), 30_000);
69
70
  return () => clearInterval(timer);
70
- }, [expiresAt]);
71
- return expiresAt === undefined ? null : Math.max(0, Math.ceil((expiresAt - now) / 60_000));
71
+ }, [expiresAt, pausedAt]);
72
+ return expiresAt === undefined ? null : Math.max(0, Math.ceil((expiresAt - (pausedAt ?? now)) / 60_000));
72
73
  }
73
74
 
74
75
  export function AutoPickupControl({ cluster }: { cluster: ClusterStatePayload }) {
@@ -80,10 +81,11 @@ export function AutoPickupControl({ cluster }: { cluster: ClusterStatePayload })
80
81
  wsSendRaw?.({ type: 'cluster_auto_pickup_set', clusterId: cluster.clusterId, mode, ...(evaluator ? { evaluator } : {}), ...(limits ? { limits } : {}), ...(ruleLimits ? { ruleLimits } : {}), ...(remindBusy !== undefined ? { remindBusy } : {}) });
81
82
  };
82
83
  const on = state.mode !== 'off';
83
- const remaining = useSessionRemaining(state.session?.expiresAt);
84
+ const pause = () => wsSendRaw?.({ type: 'cluster_auto_pickup_set', clusterId: cluster.clusterId, mode: state.mode, paused: !state.paused });
85
+ const remaining = useSessionRemaining(state.session?.expiresAt, state.pausedAt);
84
86
  const decision = describeDecision(state);
85
87
  const modeTitle = on
86
- ? `${AUTO_PICKUP_MODE_LABELS[state.mode].label}${remaining !== null ? `, about ${remaining} min left in this session` : ''}. Click to review or change.`
88
+ ? `${AUTO_PICKUP_MODE_LABELS[state.mode].label}${state.paused ? ', paused; automatic pickup and busy reminders are stopped' : ''}${remaining !== null ? `, about ${remaining} min left in this session${state.paused ? ' (clock paused)' : ''}` : ''}. Click to review or change.`
87
89
  : 'AUTO-PICKUP is off. Click to choose a mode.';
88
90
  return (
89
91
  <>
@@ -95,7 +97,7 @@ export function AutoPickupControl({ cluster }: { cluster: ClusterStatePayload })
95
97
  onClick={() => setOpen(true)}
96
98
  data-help="cluster.auto-turn"
97
99
  aria-haspopup="dialog"
98
- aria-label={`AUTO-PICKUP: ${AUTO_PICKUP_MODE_LABELS[state.mode].label}`}
100
+ aria-label={`AUTO-PICKUP: ${AUTO_PICKUP_MODE_LABELS[state.mode].label}${state.paused ? ', paused' : ''}`}
99
101
  aria-description={decision ?? undefined}
100
102
  className="display-font"
101
103
  title={`${modeTitle}${decision ? ` ${decision}` : ''}`}
@@ -110,9 +112,13 @@ export function AutoPickupControl({ cluster }: { cluster: ClusterStatePayload })
110
112
  }}
111
113
  >
112
114
  {AUTO_PICKUP_MODE_LABELS[state.mode].chip}
115
+ {state.paused ? ' - PAUSED' : ''}
113
116
  {isSmartPickupMode(state.mode) && state.counters ? ` · ${state.counters.wakesThisSession}/${state.limits.wakesPerSession}` : ''}
114
117
  </button>
115
- {state.mode === 'rule' && state.ruleStatus?.budgetPaused && <button type="button" data-help="cluster.auto-pickup-rule-resume" disabled={!connected} onClick={() => wsSendRaw?.({ type: 'cluster_auto_pickup_set', clusterId: cluster.clusterId, mode: 'rule', resumeRule: true })}>RESUME</button>}
118
+ {state.mode === 'rule' && state.ruleStatus?.budgetPaused && <button type="button" data-help="cluster.auto-pickup-rule-resume" disabled={!connected || state.paused} title={state.paused ? 'Resume AUTO-PICKUP before resetting its wake budget.' : 'Start a fresh Rule-based wake budget; hourly member limits remain.'} onClick={() => wsSendRaw?.({ type: 'cluster_auto_pickup_set', clusterId: cluster.clusterId, mode: 'rule', resumeRule: true })}>RESET BUDGET</button>}
119
+ {on && <button type="button" onClick={pause} disabled={!connected} data-help={state.paused ? 'cluster.auto-pickup-resume' : 'cluster.auto-pickup-pause'} aria-label={state.paused ? 'Resume AUTO-PICKUP' : 'Pause AUTO-PICKUP'} title={state.paused ? 'Resume with the same session and wake counts; check idle members with waiting mail through the normal limits.' : 'Pause automatic pickup and busy reminders without changing the mode, session or wake counts.'} className="display-font" style={{ padding: '3px 6px', background: 'transparent', border: '1px solid var(--color-border-hairline)', color: 'var(--color-fg-muted)', cursor: 'pointer', fontSize: '9px', letterSpacing: '1px', whiteSpace: 'nowrap' }}>
120
+ {state.paused ? 'RESUME' : 'PAUSE'}
121
+ </button>}
116
122
  {on && (
117
123
  <button
118
124
  type="button"
@@ -126,13 +132,14 @@ export function AutoPickupControl({ cluster }: { cluster: ClusterStatePayload })
126
132
  TURN OFF
127
133
  </button>
128
134
  )}
129
- {open && <AutoPickupDialog state={state} onClose={() => setOpen(false)} onApply={(mode, evaluator, limits, ruleLimits, remindBusy) => { send(mode, evaluator, limits, ruleLimits, remindBusy); setOpen(false); }} />}
135
+ {open && <AutoPickupDialog state={state} onPause={pause} onClose={() => setOpen(false)} onApply={(mode, evaluator, limits, ruleLimits, remindBusy) => { send(mode, evaluator, limits, ruleLimits, remindBusy); setOpen(false); }} />}
130
136
  </>
131
137
  );
132
138
  }
133
139
 
134
- function AutoPickupDialog({ state, onClose, onApply }: {
140
+ function AutoPickupDialog({ state, onPause, onClose, onApply }: {
135
141
  state: ClusterAutoPickupState;
142
+ onPause: () => void;
136
143
  onClose: () => void;
137
144
  onApply: (mode: AutoPickupMode, evaluator?: SmartPickupEvaluator, limits?: Partial<SmartPickupLimits>, ruleLimits?: Partial<RulePickupLimits>, remindBusy?: boolean) => void;
138
145
  }) {
@@ -186,7 +193,7 @@ function AutoPickupDialog({ state, onClose, onApply }: {
186
193
  : null;
187
194
  const field: React.CSSProperties = { display: 'block', margin: '4px 0 10px' };
188
195
  const decision = describeDecision(state);
189
- const remaining = useSessionRemaining(state.session?.expiresAt);
196
+ const remaining = useSessionRemaining(state.session?.expiresAt, state.pausedAt);
190
197
  return (
191
198
  <div onClick={onClose} style={{ position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.6)', zIndex: 60, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
192
199
  <div
@@ -200,6 +207,11 @@ function AutoPickupDialog({ state, onClose, onApply }: {
200
207
  style={{ ...formSurfaceSize(), overflowY: 'auto', background: 'var(--color-bg-dialog)', border: '1px solid var(--color-accent-primary-dim)', borderRadius: '6px', padding: '18px 20px', fontSize: '12px', lineHeight: 1.5, color: 'var(--color-fg)' }}
201
208
  >
202
209
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}><h2 id="auto-pickup-title" className="display-font glow-text-bright" style={{ margin: '0 0 10px', fontSize: '14px', letterSpacing: '2px' }}>AUTO-PICKUP</h2><WorkSurfaceControls surface={surface} storageKey="auto-pickup" /></div>
210
+ {state.mode !== 'off' && <p>
211
+ {state.paused ? 'Paused. Waiting mail stays in the mailbox; NUDGE still works.' : 'Automatic pickup is not paused.'}{' '}
212
+ {state.session && state.paused ? 'The Smart session clock is paused. ' : ''}
213
+ <button type="button" disabled={!connected} data-help={state.paused ? 'cluster.auto-pickup-resume' : 'cluster.auto-pickup-pause'} aria-label={state.paused ? 'Resume AUTO-PICKUP' : 'Pause AUTO-PICKUP'} onClick={onPause}>{state.paused ? 'RESUME' : 'PAUSE'}</button>
214
+ </p>}
203
215
  <fieldset style={{ border: 'none', padding: 0, margin: 0 }}>
204
216
  <legend className="display-font" style={{ fontSize: '10px', letterSpacing: '1.5px', color: 'var(--color-fg-muted)' }}>MODE</legend>
205
217
  {AUTO_PICKUP_MODES.map((m, i) => (
@@ -225,7 +237,7 @@ function AutoPickupDialog({ state, onClose, onApply }: {
225
237
  <input className="arco-field" type="number" min={spec.min} max={spec.max} step={1} value={Number.isFinite(ruleLimits[k]) ? ruleLimits[k] : ''} onChange={(e) => setRuleLimits((prior) => ({ ...prior, [k]: e.target.value === '' ? Number.NaN : Number(e.target.value) }))} />
226
238
  </label>; })}
227
239
  <button type="button" data-help="cluster.auto-pickup-rule-reset" onClick={() => setRuleLimits({ ...DEFAULT_RULE_PICKUP_LIMITS })}>RESET LIMITS</button>
228
- {state.ruleStatus && <p>Automatic wakes: {state.ruleStatus.wakes} of {ruleLimits.wakesPerArming} this arming.{state.ruleStatus.ledgerUnavailable ? ' Paused: the Rule-based ledger is unavailable.' : state.ruleStatus.budgetPaused ? ' Paused: resume to start a fresh budget.' : ''}{state.ruleStatus.pausedPair ? ' Alternating pair paused.' : ''}</p>}
240
+ {state.ruleStatus && <p>Automatic wakes: {state.ruleStatus.wakes} of {ruleLimits.wakesPerArming} this arming.{state.ruleStatus.ledgerUnavailable ? ' Paused: the Rule-based ledger is unavailable.' : state.ruleStatus.budgetPaused ? ' Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP after resuming any operator pause.' : ''}{state.ruleStatus.pausedPair ? ' Alternating pair paused.' : ''}</p>}
229
241
  </section>}
230
242
  {smart && (
231
243
  <section data-help="cluster.auto-pickup-evaluator" style={{ borderTop: '1px solid var(--color-border-hairline)', marginTop: '10px', paddingTop: '10px' }}>
@@ -286,7 +298,7 @@ function AutoPickupDialog({ state, onClose, onApply }: {
286
298
 
287
299
  {(state.counters || decision) && (
288
300
  <section data-help="cluster.auto-pickup-status" aria-label="AUTO-PICKUP status" style={{ borderTop: '1px solid var(--color-border-hairline)', marginTop: '10px', paddingTop: '10px', color: 'var(--color-fg-muted)' }}>
289
- {state.session && <div>About {remaining} min remain. Session ends at {new Date(state.session.expiresAt).toLocaleTimeString()}. Change Armed session length under LIMITS before arming.</div>}
301
+ {state.session && <div>About {remaining} min remain. {state.paused ? 'Session clock paused.' : `Session ends at ${new Date(state.session.expiresAt).toLocaleTimeString()}.`} Change Armed session length under LIMITS before arming.</div>}
290
302
  {state.counters && <div>Evaluator requests: {state.counters.callsThisSession} this session, {state.counters.callsLastHour} in the last hour, {state.counters.inFlight} in progress. Automatic wakes: {state.counters.wakesThisSession} of {state.limits.wakesPerSession} this session, {state.counters.wakesLastHour} in the last hour.</div>}
291
303
  {decision && <div>Last decision: {decision}</div>}
292
304
  </section>
@@ -243,7 +243,8 @@ export function ClusterRightPanel({ cluster, compactSettings = false, tabRequest
243
243
  arming surface is wired (both come from the same parent). */}
244
244
  {compactSettings && (onToggleIdleNudger || onSetTaskBoardMode || onSetTaskBoardAttached || onSetEfficiency || onSetRemote || onSetProgress) && (() => {
245
245
  // Medium and wide layouts: one summary line; SETTINGS opens the full block.
246
- const pickup = AUTO_PICKUP_MODE_LABELS[autoPickupStateOf(cluster).mode].chip;
246
+ const pickupState = autoPickupStateOf(cluster);
247
+ const pickup = `${AUTO_PICKUP_MODE_LABELS[pickupState.mode].chip}${pickupState.paused ? ' - PAUSED' : ''}`;
247
248
  const parts = [
248
249
  onToggleIdleNudger ? `MAIL ALERTS ${cluster.idleNudgerEnabled ? 'ON' : 'OFF'}` : null,
249
250
  onToggleAutoTurn ? `AUTO-PICKUP ${pickup}` : null,
@@ -17,15 +17,17 @@ export function HeaderVersionBox() {
17
17
  const refresh = useAppUpdateStore((s) => s.refresh);
18
18
  const settings = useAppStore((s) => s.settings);
19
19
  const [open, setOpen] = useState(false);
20
+ const [autoConfirm, setAutoConfirm] = useState(false);
20
21
  const [busy, setBusy] = useState(false);
21
22
  const [error, setError] = useState('');
22
23
  const root = useRef<HTMLSpanElement>(null);
23
24
  const placeRef = useKeepInWindow();
25
+ useEffect(() => { useAppUpdateStore.getState().setVersionOpen(open); return () => useAppUpdateStore.getState().setVersionOpen(false); }, [open]);
24
26
  useEffect(() => { void refresh().catch(() => {}); }, [refresh]);
25
27
  useEffect(() => { if (notice?.latest) void refresh().catch(() => {}); }, [notice?.latest, refresh]);
26
28
  useEffect(() => {
27
29
  if (!open) return;
28
- const away = (event: MouseEvent) => { if (root.current && !root.current.contains(event.target as Node)) setOpen(false); };
30
+ const away = (event: MouseEvent) => { if (root.current && !root.current.contains(event.target as Node) && !(event.target as Element).closest('[aria-label="Confirm update"]')) setOpen(false); };
29
31
  const key = (event: KeyboardEvent) => { if (event.key === 'Escape') setOpen(false); };
30
32
  document.addEventListener('mousedown', away); document.addEventListener('keydown', key);
31
33
  return () => { document.removeEventListener('mousedown', away); document.removeEventListener('keydown', key); };
@@ -43,7 +45,7 @@ export function HeaderVersionBox() {
43
45
  : `Up to date (${current || 'version unknown'}). Last checked: ${checked}.`;
44
46
  const aria = updating ? 'Arco is updating' : available ? `Arco update available: ${plain(latest as string)}. Open update.` : `Arco version ${current || 'unknown'}. ${!checks ? 'Release checks are off.' : 'Up to date.'} Open version details.`;
45
47
  const check = async () => {
46
- setBusy(true); setError('');
48
+ setAutoConfirm(false); setBusy(true); setError('');
47
49
  try { await refresh(true); } catch { setError('Release check unavailable'); } finally { setBusy(false); }
48
50
  };
49
51
  const versions = () => { setOpen(false); useStartupStore.getState().setSettingsSection('cli-versions'); useAppStore.getState().setShowSettings(true); };
@@ -57,7 +59,7 @@ export function HeaderVersionBox() {
57
59
  aria-label={aria}
58
60
  aria-haspopup="dialog"
59
61
  aria-expanded={open}
60
- onClick={() => setOpen((value) => !value)}
62
+ onClick={() => { if (!open) setAutoConfirm(available); setOpen((value) => !value); }}
61
63
  style={{
62
64
  ...headerActionStyle,
63
65
  fontSize: '10px',
@@ -77,6 +79,7 @@ export function HeaderVersionBox() {
77
79
  </button>
78
80
  {(open || updating) && <div
79
81
  role="dialog"
82
+ data-recovery-safe
80
83
  aria-label={available ? 'Arco update' : 'Arco version'}
81
84
  data-testid="header-version-popover"
82
85
  ref={placeRef}
@@ -84,7 +87,7 @@ export function HeaderVersionBox() {
84
87
  >
85
88
  {available ? <>
86
89
  <div>Arco {plain(latest as string)} is available{current ? ` (running ${current})` : ''}.</div>
87
- <UpdateAction latest={latest} url={url} autoConfirm />
90
+ <UpdateAction latest={latest} url={url} autoConfirm={autoConfirm} />
88
91
  {url && <div><a href={url} target="_blank" rel="noopener noreferrer">Release notes</a></div>}
89
92
  </> : <>
90
93
  <div>Running: {current || 'unknown'}</div>
@@ -1,5 +1,7 @@
1
+ import { createPortal } from 'react-dom';
2
+ import { checkBuild } from '../buildCheck';
1
3
  import { confirmationSurfaceSize, WorkSurfaceControls } from './workSurface/WorkSurfaceControls';
2
- import { useEffect, useRef, useState } from 'react';
4
+ import { useEffect, useId, useRef, useState } from 'react';
3
5
  import { useAppUpdateStore } from '../stores/appUpdateStore';
4
6
 
5
7
  type State = { mode: 'service' | 'foreground' | 'docker'; platform?: string; packaged?: boolean; result: { outcome: string; message?: string; attemptId?: string } | null };
@@ -11,6 +13,16 @@ export function UpdateAction({ latest, url, autoConfirm = false }: { latest: str
11
13
  const [message, setMessage] = useState('');
12
14
  const [resultMessage, setResultMessage] = useState('');
13
15
  const [fallback, setFallback] = useState(false);
16
+ const resultSurfaceId = useId();
17
+ const ownsResult = useAppUpdateStore((s) => s.resultSurfaces[0] === resultSurfaceId);
18
+ const hasState = state !== null;
19
+ useEffect(() => {
20
+ if (!hasState) return;
21
+ // An open control owns the result instead of the global notice. Starting an
22
+ // update moves ownership to the exact control whose button was pressed.
23
+ useAppUpdateStore.getState().showResultAt(resultSurfaceId);
24
+ return () => useAppUpdateStore.getState().removeResultSurface(resultSurfaceId);
25
+ }, [hasState, resultSurfaceId]);
14
26
  // null means the start request is in flight; a string fences later polls to
15
27
  // that attempt. A new page can display any result the server still reports.
16
28
  const startedAttempt = useRef<string | null | undefined>(undefined);
@@ -40,6 +52,7 @@ export function UpdateAction({ latest, url, autoConfirm = false }: { latest: str
40
52
  if (next.result?.outcome === 'running') { setResultMessage(''); setPending(true); }
41
53
  else if (next.result?.outcome === 'updated' || next.result?.outcome === 'failed' || next.result?.outcome === 'unchanged') {
42
54
  if (startedAttempt.current === null || (startedAttempt.current && next.result.attemptId !== startedAttempt.current)) return;
55
+ if (next.result.outcome === 'updated' && startedAttempt.current) void checkBuild();
43
56
  startedAttempt.current = undefined;
44
57
  setPending(false); setMessage(''); setResultMessage(next.result.message || (next.result.outcome === 'updated' ? 'Update complete.' : next.result.outcome === 'unchanged' ? 'Already on the newest release.' : 'Update failed.'));
45
58
  } else setResultMessage('');
@@ -50,6 +63,7 @@ export function UpdateAction({ latest, url, autoConfirm = false }: { latest: str
50
63
  return () => { live = false; clearInterval(timer); };
51
64
  }, [pending]);
52
65
  const start = async () => {
66
+ useAppUpdateStore.getState().showResultAt(resultSurfaceId, true);
53
67
  startedAttempt.current = null;
54
68
  setConfirm(false); setPending(true); setFallback(false); setResultMessage(''); setMessage('Starting update. Arco will reconnect after restart.');
55
69
  try {
@@ -78,8 +92,8 @@ export function UpdateAction({ latest, url, autoConfirm = false }: { latest: str
78
92
  </>}
79
93
  {fallback && <div><code>{state.packaged ? 'arco update' : 'npm run arco:update'}</code>{' '}<button type="button" onClick={() => copy(state.packaged ? 'arco update' : 'npm run arco:update')}>COPY COMMAND</button></div>}
80
94
  {message && <div role="status">{message}</div>}
81
- {resultMessage && <div role="status">{resultMessage}</div>}
82
- {confirm && <div role="dialog" aria-modal="true" aria-label="Confirm update" style={{ position: 'fixed', inset: 0, zIndex: 10000, background: 'rgba(0,0,0,.6)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
95
+ {ownsResult && resultMessage && <div role="status">{resultMessage}</div>}
96
+ {confirm && createPortal(<div role="dialog" aria-modal="true" aria-label="Confirm update" style={{ position: 'fixed', inset: 0, zIndex: 10000, background: 'rgba(0,0,0,.6)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
83
97
  <div ref={surface} style={{ background: 'var(--color-bg-elevated)', color: 'var(--color-fg)', border: '1px solid var(--color-border)', padding: 20, ...confirmationSurfaceSize }}>
84
98
  <WorkSurfaceControls surface={surface} storageKey="update-confirm" />
85
99
  <p>Update to {latest} and restart Arco? Running turns will stop.</p>
@@ -87,6 +101,6 @@ export function UpdateAction({ latest, url, autoConfirm = false }: { latest: str
87
101
  <button type="button" onClick={() => void start()}>UPDATE AND RESTART</button>{' '}
88
102
  <button type="button" onClick={() => setConfirm(false)}>CANCEL</button>
89
103
  </div>
90
- </div>}
104
+ </div>, document.body)}
91
105
  </div>;
92
106
  }
@@ -1,7 +1,9 @@
1
1
  import { useEffect, useState } from 'react';
2
+ import { useAppUpdateStore } from '../stores/appUpdateStore';
2
3
 
3
4
  interface Result { outcome: string; message?: string; finishedAt?: number; attemptId?: string }
4
5
  export function UpdateResultNotice() {
6
+ const inlineResult = useAppUpdateStore((s) => s.resultSurfaces.length > 0);
5
7
  const [result, setResult] = useState<Result | null>(null);
6
8
  useEffect(() => {
7
9
  let alive = true; let request = 0;
@@ -22,7 +24,7 @@ export function UpdateResultNotice() {
22
24
  void check(); const timer = setInterval(() => { void check(); }, 3000);
23
25
  return () => { alive = false; clearInterval(timer); };
24
26
  }, []);
25
- if (!result) return null;
27
+ if (!result || inlineResult) return null;
26
28
  return <div role="status" data-help="settings.update-result" style={{ pointerEvents: 'auto', padding: 12, color: 'var(--color-fg)', background: 'var(--color-bg-panel)', border: '1px solid var(--color-accent-primary)' }}>
27
29
  <span>{result.message || (result.outcome === 'unchanged' ? 'Already on the newest release.' : 'Update completed.')}</span>{' '}
28
30
  <button type="button" onClick={() => { try { localStorage.setItem('arco-update-result-dismissed', result.attemptId || String(result.finishedAt)); } catch { /* storage is optional */ } setResult(null); }}>DISMISS</button>
@@ -312,7 +312,8 @@ export const clusterHelp: Record<string, HelpEntry> = {
312
312
  body: (
313
313
  <>
314
314
  <p>Chooses whether idle members start a turn on their own when mail arrives. The chip shows the current mode; click it to change it. <strong>Off</strong> is the default, and clusters armed before the modes existed are Rule-based.</p>
315
- <p><strong>Rule-based (recommended)</strong> wakes an idle member for mail that asks for something and leaves plain acknowledgements waiting. Limits stop two members waking each other back and forth and cap wakes per member and per arming. <C>RESUME</C> starts a fresh allowance.</p>
315
+ <p><strong>Rule-based (recommended)</strong> wakes an idle member for mail that asks for something and leaves plain acknowledgements waiting. Limits stop two members waking each other back and forth and cap wakes per member and per arming. <C>RESET BUDGET</C> starts a fresh allowance after the arming total is reached.</p>
316
+ <p><C>PAUSE</C> stops automatic pickup and busy reminders while keeping the mode, session and wake counts. <C>RESUME</C> checks idle members with waiting mail through the same limits, without resetting the budget. NUDGE still works while paused. The Smart session clock freezes, including across a restart; hourly rate limits keep real time.</p>
316
317
  <p><strong>Smart</strong> modes ask a model you choose whether to wake the member, wait, or ask you. <strong>Observe-only</strong> only records the answers. <strong>Automatic</strong> may start the member&apos;s normal turn, but only after Arco checks again that the member is idle, the mail is unchanged and every limit allows it. <C>STOP</C> on a member holds its current mail until new mail arrives. A Smart session ends at its time limit, or after a restart when its limit record cannot be read, and must then be armed again.</p>
317
318
  <p>In Automatic, an evaluator error or invalid answer attempts ordinary pickup once through the same guards and budget. Valid wait/ask answers and STOP or expiry never permit fallback. Observe-only never wakes. The last decision, chip hover and accessible description explain failures and fallback.</p>
318
319
  <p>Set <strong>Armed session length</strong> under <strong>AUTO-PICKUP &gt; LIMITS</strong> before arming (5 to 240 minutes, default 30). The dialog shows minutes remaining. Expiry turns Smart Off; mail waits for rearming, Rule-based or NUDGE.</p>
@@ -1303,7 +1304,7 @@ export const clusterHelp: Record<string, HelpEntry> = {
1303
1304
  },
1304
1305
  'cluster.auto-pickup-rule-limits': {
1305
1306
  title: 'Rule-based limits',
1306
- body: <p>Set the alternating wake limit, hourly wakes per member, total wakes per arming and chain depth. Acknowledgement-only mail and mail stopped by the chain-depth limit stay in the mailbox. The hourly cap rolls over; reaching the arming total pauses automatic pickup until RESUME.</p>,
1307
+ body: <p>Set the alternating wake limit, hourly wakes per member, total wakes per arming and chain depth. Acknowledgement-only mail and mail stopped by the chain-depth limit stay in the mailbox. The hourly cap rolls over; reaching the arming total stops automatic pickup until RESET BUDGET.</p>,
1307
1308
  manualSection: 'cluster-auto-pickup',
1308
1309
  },
1309
1310
  'cluster.auto-pickup-rule-reset': {
@@ -1312,13 +1313,23 @@ export const clusterHelp: Record<string, HelpEntry> = {
1312
1313
  manualSection: 'cluster-auto-pickup',
1313
1314
  },
1314
1315
  'cluster.auto-pickup-rule-resume': {
1315
- title: 'Resume Rule-based pickup',
1316
- body: <p>Start a fresh arming budget after the total wake limit pauses pickup. The rolling hourly member limit still applies.</p>,
1316
+ title: 'Reset Rule-based wake budget',
1317
+ body: <p>Start a fresh arming budget after the total wake limit stops pickup. The rolling hourly member limit still applies. This action stays disabled during an operator pause; use RESUME first, then reset the budget separately.</p>,
1318
+ manualSection: 'cluster-auto-pickup',
1319
+ },
1320
+ 'cluster.auto-pickup-pause': {
1321
+ title: 'Pause AUTO-PICKUP',
1322
+ body: <p>Stop automatic pickup, Smart evaluator requests and busy reminders without changing the mode, armed session or wake counts. Mail waits in the mailbox. A turn already running continues, and NUDGE still works. The pause survives a server restart. The Smart session clock freezes at its remaining time; hourly rate limits continue in real time.</p>,
1323
+ manualSection: 'cluster-auto-pickup',
1324
+ },
1325
+ 'cluster.auto-pickup-resume': {
1326
+ title: 'Resume AUTO-PICKUP',
1327
+ body: <p>Continue with the same mode, armed session and wake counts, without confirmation. Smart continues with the time left at PAUSE. Each idle member with waiting mail is checked once through the normal limits. Smart still evaluates the mail; Observe-only only records its answer. RESUME does not reset a spent Rule-based budget; RESET BUDGET is a separate action.</p>,
1317
1328
  manualSection: 'cluster-auto-pickup',
1318
1329
  },
1319
1330
  'cluster.auto-pickup-off': {
1320
1331
  title: 'Turn AUTO-PICKUP off',
1321
- body: <p>One click sets AUTO-PICKUP to Off. A Smart session ends at once, so an evaluator answer still in progress is discarded and starts nothing. A worker turn that already started is not cancelled; use STOP for that. The evaluator choice and limits are kept for the next arming.</p>,
1332
+ body: <p>One click sets AUTO-PICKUP to Off and clears an operator pause. A Smart session ends at once, so an evaluator answer still in progress is discarded and starts nothing. A worker turn that already started is not cancelled; use STOP for that. The evaluator choice and limits are kept for the next arming.</p>,
1322
1333
  manualSection: 'cluster-auto-pickup',
1323
1334
  },
1324
1335
  'cluster.auto-pickup-dialog': {
@@ -458,7 +458,9 @@ export const headerHelp: Record<string, HelpEntry> = {
458
458
  Otherwise it opens the running and latest known version, the last
459
459
  check time, <C>CHECK NOW</C>, a release-notes link and a link to
460
460
  Settings &gt; Advanced &gt; CLI and runtime versions. While an update
461
- runs it reads <C>UPDATING</C>. With release checks off it shows the
461
+ runs it reads <C>UPDATING</C>. A release found with <C>CHECK NOW</C>
462
+ appears here; select <C>UPDATE AND RESTART</C> to open confirmation.
463
+ With release checks off it shows the
462
464
  running version only.
463
465
  </p>
464
466
  </>
@@ -360,7 +360,7 @@ export const rightPanelHelp: Record<string, HelpEntry> = {
360
360
  },
361
361
  'rightpanel.config.auto-compaction': {
362
362
  title: 'Auto-compaction',
363
- body: <><p>For cluster members, No worker override means no policy is set on the tab. If the cluster also has no policy, Claude CLI and Codex compact themselves; Claude Native and Ollama use Arco compaction near the context limit. Set a shared policy in the cluster panel under AUTO-COMPACTION. Enabled policies use a 30-95% threshold separately for each worker. Claude Native and Codex app-server compact between turns; Ollama compacts before dispatch. Other transports are unavailable for this policy. Ollama summarizes verified completed executions before the next turn and reuses saved summaries. Legacy or partial history defers safely; raw events remain available. Auto-handoff counts these compactions. Explicit Off stops automatic compaction, and auto-handoff then shows that it needs auto-compaction. Provider uses Arco compaction near 90% for Claude Native and Ollama; Claude CLI and Codex compact themselves. Claude Native also compacts inside a long turn: when a request reaches the threshold (70% under Provider) it summarizes the earlier history, keeps the request that started the turn word for word (a request over 125 KB defers the compaction instead) and the tool call in progress, and the same turn continues; chat shows Compacting automatically and then Compacted, continuing. The size measured is the real prompt, never the summed usage of a request that ran web search, web fetch or code execution. Large summaries split into requests that reserve room for the summary so far. Fable/Mythos 5.2 summaries use low effort and extra reasoning headroom. The retained round's narration also survives a later worker rebuild once. STOP cancels later summary parts as well as the current request. Off turns this off too, and so does Claude API compaction. Fold is deterministic, while handoff starts a fresh session.</p><p>Ollama estimates image context from pixel dimensions before sending. Compression size does not change this estimate. After the request, the daemon supplies the measured prompt count.</p></>,
363
+ body: <><p>For cluster members, No worker override means no policy is set on the tab. If the cluster also has no policy, Claude CLI and Codex compact themselves; Claude Native and Ollama use Arco compaction near the context limit. Set a shared policy in the cluster panel under AUTO-COMPACTION. Enabled policies use a 30-95% threshold separately for each worker. Claude Native and Codex app-server compact between turns; Ollama compacts before dispatch. Other transports are unavailable for this policy. Ollama summarizes verified completed executions before the next turn and reuses saved summaries. Legacy or partial history defers safely; raw events remain available. Auto-handoff counts these compactions. Explicit Off stops automatic compaction, and auto-handoff then shows that it needs auto-compaction. Provider uses Arco compaction near 90% for Claude Native and Ollama; Claude CLI and Codex compact themselves. After a successful between-turn automatic compaction, the next completed turn at or above the threshold can compact again. If three automatic compactions in a row each leave the context still at or above the threshold at turn end, a notice says automatic compaction keeps running and that large turns make that expected, otherwise raise the threshold or use HANDOFF. Claude Native also compacts inside a long turn: when a request reaches the threshold (70% under Provider) it summarizes the earlier history, keeps the request that started the turn word for word (a request over 125 KB defers the compaction instead) and the tool call in progress, and the same turn continues; chat shows Compacting automatically and then Compacted, continuing. The size measured is the real prompt, never the summed usage of a request that ran web search, web fetch or code execution. Large summaries split into requests that reserve room for the summary so far. Fable/Mythos 5.2 summaries use low effort and extra reasoning headroom. The retained round's narration also survives a later worker rebuild once. STOP cancels later summary parts as well as the current request. Off turns this off too, and so does Claude API compaction. Fold is deterministic, while handoff starts a fresh session.</p><p>Ollama estimates image context from pixel dimensions before sending. Compression size does not change this estimate. After the request, the daemon supplies the measured prompt count.</p></>,
364
364
  manualSection: 'auto-handoff',
365
365
  },
366
366
  'rightpanel.config.claude-api-compaction': {
@@ -547,7 +547,7 @@ export const settingsHelp: Record<string, HelpEntry> = {
547
547
  'settings.update-result': {
548
548
  title: 'Update result',
549
549
  manualSection: 'arco-updates',
550
- body: <p>Reports the completed update or rollback after the server reconnects. DISMISS hides this result.</p>,
550
+ body: <p>Reports the completed update or failure after the server reconnects. The result appears beside an open update control, or in this separate notice when no update control is open. DISMISS hides this notice. If npm cannot be found, stop Arco and run npm install -g arco-workbench from a terminal where npm works, then start Arco again.</p>,
551
551
  },
552
552
  'settings.app-updates': {
553
553
  title: 'Arco releases',
@@ -1067,6 +1067,22 @@ export const clusters: Section[] = [
1067
1067
  open the dialog. <Code>TURN OFF</Code> sets the mode to Off at once.
1068
1068
  Default is Off.
1069
1069
  </p>
1070
+ <p>
1071
+ <Code>PAUSE</Code> beside TURN OFF stops automatic pickup, Smart evaluator
1072
+ requests and busy reminders. The chip says PAUSED. Mail stays waiting;
1073
+ NUDGE and running turns still work. The mode, armed session, wake counts
1074
+ and pause survive a server restart. The Smart session clock freezes at its
1075
+ remaining time. Hourly rate limits keep real time. TURN OFF clears the pause
1076
+ and ends the session.
1077
+ </p>
1078
+ <p>
1079
+ <Code>RESUME</Code> needs no confirmation. It checks each idle member with
1080
+ waiting mail once through the normal guards and limits. Smart still evaluates
1081
+ that mail; Observe-only only records its answer. The session and wake counts
1082
+ stay unchanged except for work admitted after resuming. Smart continues with
1083
+ the time left at PAUSE. A spent Rule-based
1084
+ budget needs the separate RESET BUDGET action after resuming.
1085
+ </p>
1070
1086
  <p><strong>Modes</strong></p>
1071
1087
  <ul>
1072
1088
  <li>
@@ -1098,7 +1114,7 @@ export const clusters: Section[] = [
1098
1114
  <p>
1099
1115
  Adjustable limits pause
1100
1116
  alternating two-member wakes (default 4), cap each member at 6 wakes
1101
- per hour and pause after 40 wakes per arming. RESUME starts a fresh
1117
+ per hour and pause after 40 wakes per arming. RESET BUDGET starts a fresh
1102
1118
  arming budget; the hourly limit remains.
1103
1119
  </p>
1104
1120
  <p>
@@ -867,6 +867,22 @@ export const configuration: Section[] = [
867
867
  compact themselves.
868
868
  </p>
869
869
  <p>
870
+ Between turns, after a successful automatic compaction, the next completed
871
+ turn at or above the threshold can compact again.
872
+ </p>
873
+ <p>
874
+ If three automatic compactions in a row each leave the context still at or
875
+ above the threshold at turn end, a notice says automatic compaction has run
876
+ after each of the last 3 turns, the context is still at or above the
877
+ threshold, and it keeps running. Large turns make that expected; otherwise
878
+ raise the threshold or use HANDOFF.
879
+ </p>
880
+ <p>
881
+ The same notice can appear again after a turn ends below the threshold or
882
+ COMPACT succeeds. A failed attempt waits for a reading more than five
883
+ percentage points below the threshold before retrying.
884
+ </p>
885
+ <p>
870
886
  Claude Native also compacts inside one long turn. When a request reaches the
871
887
  threshold (70% under Provider), Arco summarizes the earlier history before
872
888
  the next request, keeps the tool call in progress and its result, and the
@@ -893,10 +909,10 @@ export const configuration: Section[] = [
893
909
  The retained round's narration also survives a later worker rebuild, without appearing twice.
894
910
  </p>
895
911
  <p>
896
- It runs at most once per crossing: if the context stays above the threshold,
897
- one notice says so. A failed summary changes nothing and the turn continues.
898
- STOP cancels the whole multipart summary, including between requests, and
899
- leaves the prior history available.
912
+ That in-turn compaction runs at most once per crossing: if the context stays
913
+ above the threshold, one notice says so. A failed summary changes nothing and
914
+ the turn continues. STOP cancels the whole multipart summary, including
915
+ between requests, and leaves the prior history available.
900
916
  Off turns it off, and so does Claude API compaction (beta).
901
917
  </p>
902
918
  <p>
@@ -179,6 +179,10 @@ export const maintenance: Section[] = [
179
179
  notice is dismissed. Clicking it opens the update dialog, or the version
180
180
  details when Arco is up to date.
181
181
  </p>
182
+ <p>
183
+ A release found with CHECK NOW appears
184
+ in the version box; select UPDATE AND RESTART to open its confirmation.
185
+ </p>
182
186
  <Sub>Settings row and automatic checks</Sub>
183
187
  <p>
184
188
  Settings &gt; Advanced &gt; CLI and runtime versions includes an{' '}
@@ -212,6 +216,14 @@ export const maintenance: Section[] = [
212
216
  refuses to proceed if the stop cannot be verified.
213
217
  </p>
214
218
  <p>
219
+ The result stays beside the open update control. Closing that control shows
220
+ a separate result notice with <strong>DISMISS</strong>. If npm cannot be found,
221
+ the update leaves the service running and lists the locations checked. In a
222
+ terminal where <Code>npm --version</Code> works, stop Arco, run{' '}
223
+ <Code>npm install -g arco-workbench</Code>, then start Arco again. Repair the
224
+ Node.js/npm installation first if that terminal cannot run npm either.
225
+ </p>
226
+ <p>
215
227
  After a restart, Arco reloads a page automatically if its build changed or
216
228
  its session cannot recover and no unsaved work is detected. Otherwise the
217
229
  RELOAD banner stays visible. Save drafts and edits before selecting it.
@@ -491,7 +491,11 @@ export const plans: Section[] = [
491
491
  <>
492
492
  <p>
493
493
  Review and handoff write durable markdown artifacts beside the workflow, so
494
- their results outlive the session.
494
+ their results outlive the session. Files meant to stay in the project
495
+ belong in the project tree, not only under that conversation&apos;s{' '}
496
+ <Code>artifacts/</Code> folder. The project <Code>.arco/</Code> folder
497
+ is local state and is not committed, except a skill shared through
498
+ SHARE WITH REPOSITORY.
495
499
  </p>
496
500
  <ul>
497
501
  <li>
@@ -21,6 +21,13 @@ export const workflows: Section[] = [
21
21
  <li>Optional artifacts under <Code>artifacts/</Code> and <Code>handoffs/</Code> alongside.</li>
22
22
  </ul>
23
23
  <p>
24
+ Put files the operator wants kept in the project in the project tree, for
25
+ example <Code>docs/</Code>, not only under the conversation&apos;s{' '}
26
+ <Code>artifacts/</Code> folder. The project <Code>.arco/</Code> folder is
27
+ local state and is not committed, except a skill shared through SHARE WITH
28
+ REPOSITORY.
29
+ </p>
30
+ <p>
24
31
  The server reloads workflows on boot. The client rehydrates from local storage,
25
32
  and the server replays anything it missed.
26
33
  </p>
@@ -8,10 +8,18 @@ export function isUpdateStatus(value: unknown): value is UpdateCheckStatus {
8
8
  && [s.latest, s.url, s.publishedAt, s.checkedAt].every((v) => v === null || typeof v === 'string');
9
9
  }
10
10
 
11
+ let manualCheck = false;
12
+ let manualRelease: string | null = null;
13
+
11
14
  export const useAppUpdateStore = create<{
12
15
  status: UpdateCheckStatus | null;
13
16
  notice: AppUpdateAvailableMessage | null;
14
17
  updating: boolean;
18
+ resultSurfaces: string[];
19
+ showResultAt: (id: string, preferred?: boolean) => void;
20
+ removeResultSurface: (id: string) => void;
21
+ versionOpen: boolean;
22
+ setVersionOpen: (value: boolean) => void;
15
23
  setUpdating: (value: boolean) => void;
16
24
  receive: (notice: AppUpdateAvailableMessage) => void;
17
25
  refresh: (force?: boolean) => Promise<void>;
@@ -20,20 +28,33 @@ export const useAppUpdateStore = create<{
20
28
  status: null,
21
29
  notice: null,
22
30
  updating: false,
31
+ resultSurfaces: [],
32
+ showResultAt: (id, preferred = false) => set(({ resultSurfaces }) => {
33
+ const others = resultSurfaces.filter((value) => value !== id);
34
+ return { resultSurfaces: preferred ? [id, ...others] : [...others, id] };
35
+ }),
36
+ removeResultSurface: (id) => set(({ resultSurfaces }) => ({ resultSurfaces: resultSurfaces.filter((value) => value !== id) })),
37
+ versionOpen: false,
38
+ setVersionOpen: (versionOpen) => set({ versionOpen }),
23
39
  setUpdating: (updating) => set({ updating }),
24
40
  receive: (notice) => {
25
41
  if (typeof notice.latest !== 'string' || typeof notice.url !== 'string' || !/^v\d+\.\d+\.\d+/.test(notice.latest) || !notice.url.startsWith('https://github.com/ghreprimand/arco/releases/tag/')) return;
42
+ if (manualCheck || notice.latest === manualRelease) return;
26
43
  if (get().notice?.latest !== notice.latest) set({ notice });
27
44
  },
28
45
  refresh: async (force = false) => {
29
- const response = await fetch('/api/update-check', { method: force ? 'POST' : 'GET' });
30
- if (!response.ok) throw new Error('Release check unavailable');
31
- const status: unknown = await response.json();
32
- if (!isUpdateStatus(status)) throw new Error('Release check unavailable');
33
- set({ status });
34
- if (status.enabled && status.updateAvailable && status.latest && status.url && status.publishedAt) {
35
- get().receive({ type: 'app_update_available', current: status.current, latest: status.latest, url: status.url, publishedAt: status.publishedAt });
36
- } else set({ notice: null });
46
+ if (force) manualCheck = true;
47
+ try {
48
+ const response = await fetch('/api/update-check', { method: force ? 'POST' : 'GET' });
49
+ if (!response.ok) throw new Error('Release check unavailable');
50
+ const status: unknown = await response.json();
51
+ if (!isUpdateStatus(status)) throw new Error('Release check unavailable');
52
+ if (force) manualRelease = status.enabled && status.updateAvailable ? status.latest : null;
53
+ set({ status, ...(force ? { notice: null } : {}) });
54
+ if (status.enabled && status.updateAvailable && status.latest && status.url && status.publishedAt) {
55
+ get().receive({ type: 'app_update_available', current: status.current, latest: status.latest, url: status.url, publishedAt: status.publishedAt });
56
+ } else set({ notice: null });
57
+ } finally { if (force) manualCheck = false; }
37
58
  },
38
59
  clear: () => set({ notice: null }),
39
60
  }));
@@ -11,6 +11,7 @@
11
11
  import { reportRecovery } from '../buildCheck';
12
12
 
13
13
  const REFRESH_MS = 20 * 60 * 1000;
14
+ const MINT_TIMEOUT_MS = 5000;
14
15
  const nativeFetch: typeof fetch = window.fetch.bind(window);
15
16
  let inflight: Promise<void> | null = null;
16
17
 
@@ -18,7 +19,7 @@ let inflight: Promise<void> | null = null;
18
19
  // caller's normal error/reconnect path runs. Concurrent callers share one mint.
19
20
  export function ensureWsSession(): Promise<void> {
20
21
  if (!inflight) {
21
- inflight = nativeFetch('/api/session', { method: 'POST', credentials: 'same-origin', cache: 'no-store' })
22
+ inflight = nativeFetch('/api/session', { method: 'POST', credentials: 'same-origin', cache: 'no-store', signal: AbortSignal.timeout(MINT_TIMEOUT_MS) })
22
23
  .then(() => undefined, () => undefined)
23
24
  .finally(() => { inflight = null; });
24
25
  }