mixdog 0.9.147 → 0.9.148
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/package.json +23 -3
- package/scripts/build-voice-runtime-unix.sh +101 -0
- package/scripts/embedding-quality-probe.mjs +96 -0
- package/scripts/generate-voice-runtime-manifest.mjs +300 -0
- package/scripts/generate-voice-runtime-manifest.test.mjs +135 -0
- package/scripts/native-binary-arch.mjs +30 -13
- package/scripts/native-binary-arch.test.mjs +40 -4
- package/scripts/plan-voice-runtime-release.mjs +73 -0
- package/scripts/prepare-native-assets.mjs +50 -9
- package/scripts/prune-embedding-runtime.mjs +3 -3
- package/scripts/sync-voice-runtime-manifest.mjs +46 -0
- package/scripts/verify-release-assets.mjs +106 -6
- package/scripts/verify-voice-runtime-release.mjs +89 -0
- package/scripts/voice-runtime-config.json +52 -0
- package/src/app.mjs +42 -5
- package/src/headless-exec.mjs +58 -32
- package/src/headless-exec.test.mjs +74 -13
- package/src/rules/lead/01-general.md +2 -0
- package/src/rules/shared/10-tool-workflow.md +7 -4
- package/src/rules/shared/30-exploration.md +2 -1
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +28 -9
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +6 -1
- package/src/runtime/agent/orchestrator/config.mjs +53 -18
- package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +139 -0
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +34 -5
- package/src/runtime/agent/orchestrator/mcp/client.mjs +94 -10
- package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.mjs +98 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +90 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-leaked-toolcall.mjs +67 -16
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +4 -82
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +0 -5
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +62 -121
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.mjs +48 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +215 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +44 -48
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +54 -31
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +56 -2
- package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +34 -2
- package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +61 -1
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +6 -1
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +61 -15
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +120 -1
- package/src/runtime/agent/orchestrator/providers/lib/env-utils.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/lib/stream-outcome.mjs +0 -3
- package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +187 -84
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +36 -36
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +16 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +50 -213
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +135 -126
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +17 -11
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +20 -7
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +11 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +132 -42
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +28 -10
- package/src/runtime/agent/orchestrator/providers/registry.mjs +122 -95
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +58 -3
- package/src/runtime/agent/orchestrator/providers/tool-stream-state.mjs +4 -22
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +7 -14
- package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +128 -0
- package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +27 -48
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +19 -14
- package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +9 -43
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +5 -1
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +15 -2
- package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +325 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +599 -195
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +22 -0
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +9 -2
- package/src/runtime/agent/orchestrator/session/manager.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +26 -16
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +23 -11
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +118 -3
- package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +332 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +38 -1
- package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +27 -6
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +12 -20
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +291 -128
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +45 -8
- package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +224 -0
- package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +53 -3
- package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +255 -25
- package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +87 -0
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +132 -9
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +10 -0
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-pattern-fanout.mjs +29 -3
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +178 -29
- package/src/runtime/agent/orchestrator/tools/builtin/local-search-telemetry.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +32 -5
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +5 -2
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-runner.mjs +10 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +38 -10
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +12 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +31 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +11 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-windows.mjs +22 -4
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +6 -8
- package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +25 -24
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +152 -133
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +114 -42
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +129 -15
- package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +72 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/project-root.mjs +7 -8
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +4 -4
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +201 -19
- package/src/runtime/agent/orchestrator/tools/code-graph/span.mjs +26 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +10 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +55 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +115 -25
- package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +268 -0
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +296 -46
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +104 -0
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +136 -0
- package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +127 -38
- package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +661 -0
- package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +350 -9
- package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +418 -44
- package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +27 -3
- package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +552 -0
- package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +65 -15
- package/src/runtime/agent/orchestrator/tools/patch-manifest.json +11 -11
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +284 -109
- package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +51 -21
- package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +44 -27
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +6 -1
- package/src/runtime/agent/orchestrator/tools/spawn-manifest.json +11 -11
- package/src/runtime/attachments/store.mjs +11 -3
- package/src/runtime/channels/data/voice-runtime-manifest.json +46 -70
- package/src/runtime/channels/lib/event-queue.mjs +51 -41
- package/src/runtime/channels/lib/scheduler.mjs +23 -28
- package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +6 -17
- package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +17 -0
- package/src/runtime/channels/lib/webhook.mjs +39 -20
- package/src/runtime/channels/lib/whisper-server.mjs +46 -1
- package/src/runtime/channels/lib/worker-main.mjs +3 -1
- package/src/runtime/media/adapters/gemini-video.mjs +20 -4
- package/src/runtime/media/jobs.mjs +13 -0
- package/src/runtime/media/renditions.mjs +7 -1
- package/src/runtime/media/store.mjs +42 -22
- package/src/runtime/memory/index.mjs +4 -9
- package/src/runtime/memory/lib/agent-ipc.mjs +1 -6
- package/src/runtime/memory/lib/archive-security.test.mjs +21 -1
- package/src/runtime/memory/lib/core-memory-store.mjs +28 -50
- package/src/runtime/memory/lib/embedding-model-config.mjs +37 -1
- package/src/runtime/memory/lib/embedding-model-config.test.mjs +33 -0
- package/src/runtime/memory/lib/embedding-provider.mjs +34 -12
- package/src/runtime/memory/lib/embedding-worker.mjs +37 -5
- package/src/runtime/memory/lib/ko-morph.mjs +46 -15
- package/src/runtime/memory/lib/memory-action-handlers.mjs +18 -1
- package/src/runtime/memory/lib/memory-cycle1.mjs +1 -18
- package/src/runtime/memory/lib/memory-cycle2-gate.mjs +1 -18
- package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +98 -45
- package/src/runtime/memory/lib/memory-cycle2-shared.mjs +71 -0
- package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +78 -0
- package/src/runtime/memory/lib/memory-cycle2.mjs +37 -3
- package/src/runtime/memory/lib/memory-cycle3.mjs +1 -1
- package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +50 -0
- package/src/runtime/memory/lib/memory-recall-store.mjs +9 -24
- package/src/runtime/memory/lib/memory.mjs +50 -12
- package/src/runtime/memory/lib/pg/process.mjs +1 -10
- package/src/runtime/memory/lib/pg/supervisor.mjs +1 -9
- package/src/runtime/memory/lib/query-handlers.mjs +2 -4
- package/src/runtime/memory/lib/session-ingest-runtime.mjs +2 -2
- package/src/runtime/shared/background-tasks.mjs +15 -0
- package/src/runtime/shared/background-tasks.test.mjs +78 -0
- package/src/runtime/shared/child-guardian.mjs +2 -10
- package/src/runtime/shared/pid-liveness.mjs +27 -0
- package/src/runtime/shared/runtime-root.mjs +1 -11
- package/src/runtime/shared/service-discovery.mjs +1 -17
- package/src/runtime/shared/singleton-owner.mjs +1 -11
- package/src/runtime/shared/staged-update.mjs +2 -12
- package/src/runtime/shared/tool-status.mjs +5 -1
- package/src/runtime/shared/tool-surface.mjs +15 -7
- package/src/runtime/shared/turn-snapshot-store.mjs +168 -0
- package/src/runtime/shared/turn-snapshot.mjs +137 -13
- package/src/runtime/shared/turn-worktree-snapshot.mjs +110 -18
- package/src/runtime/shared/webhook-session-run.mjs +16 -2
- package/src/runtime/web-search/lib/http-fetch.mjs +34 -4
- package/src/runtime/web-search/lib/state.mjs +15 -15
- package/src/runtime/web-search/lib/web-tools.mjs +46 -5
- package/src/session-runtime/context-status.mjs +4 -12
- package/src/session-runtime/runtime-core.mjs +20 -1
- package/src/standalone/agent-dispatch-broker.mjs +33 -2
- package/src/standalone/agent-tool/job-task-reconcile.mjs +78 -0
- package/src/standalone/agent-tool/notify.mjs +3 -1
- package/src/standalone/agent-tool/spawn-flow.mjs +48 -66
- package/src/standalone/agent-tool/tag-registry.mjs +116 -33
- package/src/standalone/agent-tool/tool-def.mjs +2 -2
- package/src/standalone/agent-tool/worker-index.mjs +8 -11
- package/src/standalone/agent-tool/worker-rows.mjs +4 -1
- package/src/standalone/agent-tool.mjs +20 -55
- package/src/standalone/agent-watchdog-registry.mjs +28 -4
- package/src/standalone/channel-client.mjs +47 -15
- package/src/standalone/channel-transport.mjs +44 -25
- package/src/standalone/daemon.mjs +31 -2
- package/src/standalone/hook-bus/config.mjs +25 -9
- package/src/standalone/hook-bus/handlers.mjs +16 -52
- package/src/standalone/hook-bus.mjs +29 -23
- package/src/standalone/memory-runtime-proxy.mjs +1 -16
- package/src/standalone/session-client.mjs +86 -23
- package/src/standalone/session-protocol.mjs +0 -2
- package/src/standalone/session-runtime-host-health.test.mjs +5 -4
- package/src/standalone/session-runtime-host.mjs +101 -6
- package/src/standalone/session-runtime-record.mjs +1 -5
- package/src/standalone/session-runtime-worker.mjs +52 -57
- package/src/standalone/session-service.mjs +4 -1
- package/src/standalone/session-transport.mjs +56 -25
- package/src/tui/App.jsx +40 -49
- package/src/tui/app/app-view.jsx +14 -21
- package/src/tui/app/core-memory-picker.mjs +29 -16
- package/src/tui/app/create-app-pickers.mjs +15 -36
- package/src/tui/app/extension-pickers.mjs +60 -49
- package/src/tui/app/maintenance-pickers.mjs +100 -57
- package/src/tui/app/message-selector.mjs +6 -5
- package/src/tui/app/model-picker.mjs +30 -13
- package/src/tui/app/onboarding-steps.mjs +21 -12
- package/src/tui/app/panel-epoch.mjs +56 -0
- package/src/tui/app/panel-epoch.test.mjs +1009 -0
- package/src/tui/app/panel-surface.mjs +98 -0
- package/src/tui/app/project-picker.mjs +30 -29
- package/src/tui/app/prompt-submit.mjs +192 -97
- package/src/tui/app/prompt-submit.test.mjs +206 -0
- package/src/tui/app/provider-setup-picker.mjs +74 -43
- package/src/tui/app/resume-picker.mjs +11 -8
- package/src/tui/app/route-pickers.mjs +45 -28
- package/src/tui/app/settings-picker.mjs +69 -18
- package/src/tui/app/shell-layout.mjs +1 -3
- package/src/tui/app/slash-commands.mjs +0 -2
- package/src/tui/app/slash-dispatch.mjs +4 -2
- package/src/tui/app/text-entry-policy.mjs +25 -0
- package/src/tui/app/theme-effort-pickers.mjs +11 -16
- package/src/tui/app/usage-context-panels.mjs +21 -25
- package/src/tui/app/use-global-key-input.mjs +3 -2
- package/src/tui/app/use-prompt-draft-flow.mjs +6 -18
- package/src/tui/app/use-prompt-handlers.mjs +3 -2
- package/src/tui/app/use-welcome-prompt-hint.mjs +17 -3
- package/src/tui/components/Picker.jsx +1 -1
- package/src/tui/components/TextEntryPanel.jsx +7 -2
- package/src/tui/dist/index.mjs +652 -561
- package/src/tui/lib/voice-setup.mjs +1 -2
- package/src/tui/session/agent-job-feed.mjs +73 -11
- package/src/tui/session/session-api-ext.mjs +5 -6
- package/src/tui/session/session-api.mjs +1 -0
- package/src/tui/session/tool-approval.mjs +15 -5
- package/src/tui/session/tui-steering-persist.mjs +33 -19
- package/src/tui/session/tui-steering-persist.test.mjs +104 -0
- package/src/tui/session-local.mjs +0 -22
- package/scripts/.tmp-coverage-report.mjs +0 -96
- package/src/runtime/agent/orchestrator/tools/builtin/shell-monitor.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/builtin/shell-monitor.test.mjs +0 -57
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* panel-surface.mjs — the OWNING LAYER for the panel sinks.
|
|
3
|
+
*
|
|
4
|
+
* App.jsx hands the three React setters (picker / context panel / usage panel)
|
|
5
|
+
* to createPanelSurface ONCE; they never leave this module. Every panel module
|
|
6
|
+
* receives `surface` instead, and the only way to reach a sink is a CLAIM taken
|
|
7
|
+
* at the user action that is allowed to own the screen:
|
|
8
|
+
*
|
|
9
|
+
* const own = surface.claim(); // this action takes the surface
|
|
10
|
+
* own.paint(panel); // guarded write; null clears but keeps the flow
|
|
11
|
+
* own.close(); // Esc: clear and hand ownership back for good
|
|
12
|
+
* own.defer(fn); // callback that may settle much later
|
|
13
|
+
*
|
|
14
|
+
* The claim carries the panel epoch (panel-epoch.mjs) it was taken at and EVERY
|
|
15
|
+
* write re-validates it, so "paint without proving ownership" is not
|
|
16
|
+
* expressible: an alias of own.paint, a member call, a callback handed to
|
|
17
|
+
* another module, a class field, a stored or reassigned binding, a generator
|
|
18
|
+
* resuming after yield — all of them funnel through the same check, because the
|
|
19
|
+
* proof lives inside the capability, not next to the call site.
|
|
20
|
+
*
|
|
21
|
+
* Two rules make it behave like the hand-written guards it replaces:
|
|
22
|
+
* - a paint can itself BE the handover (panel identity change), so a
|
|
23
|
+
* successful write re-arms the claim on the surface it just took;
|
|
24
|
+
* - close() drops ownership permanently, which is what stops a late ack from
|
|
25
|
+
* re-opening a panel the user dismissed. Use paint(null) — not close() —
|
|
26
|
+
* when the same flow clears the picker and keeps going (Enter → prompt).
|
|
27
|
+
*/
|
|
28
|
+
import { currentPanelEpoch, isPanelEpochCurrent, supersedePanelEpoch } from './panel-epoch.mjs';
|
|
29
|
+
|
|
30
|
+
export function createPanelSurface({ setPicker, setContextPanel, setUsagePanel } = {}) {
|
|
31
|
+
// The usage dashboard is not a picker: a streaming update is not a handover,
|
|
32
|
+
// so the picker epoch cannot express its ownership. It gets its own
|
|
33
|
+
// generation, bumped by closeUsage() (Esc / a newer /usage).
|
|
34
|
+
let usageGeneration = 0;
|
|
35
|
+
|
|
36
|
+
const claim = () => {
|
|
37
|
+
let token = currentPanelEpoch();
|
|
38
|
+
let released = false;
|
|
39
|
+
const owns = () => !released && isPanelEpochCurrent(token);
|
|
40
|
+
const write = (sink, value) => {
|
|
41
|
+
if (!owns()) return false;
|
|
42
|
+
sink?.(value);
|
|
43
|
+
token = currentPanelEpoch();
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
owns,
|
|
48
|
+
paint: (panel) => write(setPicker, panel),
|
|
49
|
+
// Clearing the context panel hands the surface back exactly as closing a
|
|
50
|
+
// picker does. setPicker's caller supersedes the epoch on a close (see
|
|
51
|
+
// shouldSupersedePanelEpoch); this sink has no such step, so a context
|
|
52
|
+
// open still in flight stayed valid and repainted "Context Usage" after
|
|
53
|
+
// the user had already pressed Esc. Superseding here is what makes the
|
|
54
|
+
// dismissal final, and re-reading the token keeps THIS flow (Esc inside a
|
|
55
|
+
// settings picker, which clears context and carries on) working.
|
|
56
|
+
context: (panel) => {
|
|
57
|
+
if (!owns()) return false;
|
|
58
|
+
setContextPanel?.(panel);
|
|
59
|
+
if (panel == null) supersedePanelEpoch();
|
|
60
|
+
token = currentPanelEpoch();
|
|
61
|
+
return true;
|
|
62
|
+
},
|
|
63
|
+
close: () => {
|
|
64
|
+
if (!owns()) return false;
|
|
65
|
+
setPicker?.(null);
|
|
66
|
+
released = true;
|
|
67
|
+
return true;
|
|
68
|
+
},
|
|
69
|
+
defer: (run) => {
|
|
70
|
+
const deferredToken = token;
|
|
71
|
+
return (...args) => (
|
|
72
|
+
!released && isPanelEpochCurrent(deferredToken) ? run(...args) : undefined
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const claimUsage = () => {
|
|
79
|
+
const generation = (usageGeneration += 1);
|
|
80
|
+
const owns = () => generation === usageGeneration;
|
|
81
|
+
return {
|
|
82
|
+
owns,
|
|
83
|
+
paint: (dashboard) => {
|
|
84
|
+
if (!owns()) return false;
|
|
85
|
+
setUsagePanel?.(dashboard);
|
|
86
|
+
return true;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Closing the usage overlay invalidates every dashboard update in flight.
|
|
92
|
+
const closeUsage = () => {
|
|
93
|
+
usageGeneration += 1;
|
|
94
|
+
setUsagePanel?.(null);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return { claim, claimUsage, closeUsage };
|
|
98
|
+
}
|
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
* project-picker.mjs — the project selector / create / rename / enter cluster.
|
|
3
3
|
*
|
|
4
4
|
* Extracted from App.jsx behavior-preservingly. This cluster is ref/state
|
|
5
|
-
* coupled (it drives
|
|
6
|
-
* a dependency-injection factory rather than pure functions.
|
|
7
|
-
* and path operations are daemon calls on `store`; the TUI
|
|
8
|
-
* OS-native folder chooser.
|
|
5
|
+
* coupled (it drives the panel surface + a fan of prompt setters), so it's
|
|
6
|
+
* delivered as a dependency-injection factory rather than pure functions.
|
|
7
|
+
* Project registry and path operations are daemon calls on `store`; the TUI
|
|
8
|
+
* retains only the OS-native folder chooser.
|
|
9
9
|
*/
|
|
10
10
|
export function createProjectPicker({
|
|
11
11
|
state,
|
|
12
12
|
store,
|
|
13
|
-
|
|
13
|
+
surface,
|
|
14
14
|
setProviderPrompt,
|
|
15
|
-
setChannelPrompt,
|
|
16
|
-
setHookPrompt,
|
|
17
15
|
setSettingsPrompt,
|
|
18
|
-
setContextPanel,
|
|
19
16
|
closeUsagePanel,
|
|
20
17
|
projectNameFromPath,
|
|
21
18
|
pickFolder,
|
|
@@ -94,7 +91,8 @@ export function createProjectPicker({
|
|
|
94
91
|
}
|
|
95
92
|
},
|
|
96
93
|
onCancel: () => {
|
|
97
|
-
|
|
94
|
+
// Esc on the list: this keypress owns the surface it clears.
|
|
95
|
+
surface.claim().close();
|
|
98
96
|
},
|
|
99
97
|
};
|
|
100
98
|
};
|
|
@@ -103,11 +101,10 @@ export function createProjectPicker({
|
|
|
103
101
|
// we register it (and offer to create it if missing). Used as a
|
|
104
102
|
// fallback when no native folder dialog is available.
|
|
105
103
|
const beginNewProjectManual = () => {
|
|
106
|
-
|
|
104
|
+
const own = surface.claim();
|
|
105
|
+
own.context(null);
|
|
106
|
+
own.close();
|
|
107
107
|
setProviderPrompt(null);
|
|
108
|
-
setChannelPrompt(null);
|
|
109
|
-
setHookPrompt(null);
|
|
110
|
-
setContextPanel(null);
|
|
111
108
|
closeUsagePanel();
|
|
112
109
|
setSettingsPrompt({
|
|
113
110
|
kind: 'project-new',
|
|
@@ -123,14 +120,15 @@ export function createProjectPicker({
|
|
|
123
120
|
// folder we register; on cancel we return to the project picker;
|
|
124
121
|
// when no dialog tool exists we fall back to manual path typing.
|
|
125
122
|
const beginNewProject = () => {
|
|
123
|
+
// The folder dialog can stay open for minutes: the claim taken here is what
|
|
124
|
+
// every branch below proves ownership with.
|
|
125
|
+
const own = surface.claim();
|
|
126
126
|
setProviderPrompt(null);
|
|
127
|
-
|
|
128
|
-
setHookPrompt(null);
|
|
129
|
-
setContextPanel(null);
|
|
127
|
+
own.context(null);
|
|
130
128
|
closeUsagePanel();
|
|
131
129
|
// Keep an overlay up (kind:'project' so the banner/height stay reserved) but
|
|
132
130
|
// make it inert: no selectable items, navigation is a no-op until resolve.
|
|
133
|
-
|
|
131
|
+
own.paint({
|
|
134
132
|
kind: 'project',
|
|
135
133
|
title: 'Project',
|
|
136
134
|
description: 'Opening folder picker… choose a folder in the dialog window.',
|
|
@@ -145,6 +143,7 @@ export function createProjectPicker({
|
|
|
145
143
|
initialPath: String(state.cwd || process.cwd() || ''),
|
|
146
144
|
})
|
|
147
145
|
.then((result) => {
|
|
146
|
+
if (!own.owns()) return;
|
|
148
147
|
if (!result || result.available === false) {
|
|
149
148
|
// No native dialog on this system → manual typing.
|
|
150
149
|
beginNewProjectManual();
|
|
@@ -158,7 +157,7 @@ export function createProjectPicker({
|
|
|
158
157
|
void registerProject(result.path);
|
|
159
158
|
})
|
|
160
159
|
.catch(() => {
|
|
161
|
-
beginNewProjectManual();
|
|
160
|
+
if (own.owns()) beginNewProjectManual();
|
|
162
161
|
});
|
|
163
162
|
};
|
|
164
163
|
|
|
@@ -169,9 +168,13 @@ export function createProjectPicker({
|
|
|
169
168
|
store.pushNotice('project path is required', 'warn');
|
|
170
169
|
return false;
|
|
171
170
|
}
|
|
171
|
+
// Post-write delegation: the project list reopen must still own the surface
|
|
172
|
+
// (the add can ack long after an Esc).
|
|
173
|
+
const own = surface.claim();
|
|
172
174
|
try {
|
|
173
175
|
const project = await serviceCall('addProject', path);
|
|
174
176
|
if (project?.name) store.pushNotice(`project added: ${project.name}`, 'info');
|
|
177
|
+
if (!own.owns()) return true;
|
|
175
178
|
await openProjectPicker();
|
|
176
179
|
return true;
|
|
177
180
|
} catch (e) {
|
|
@@ -187,7 +190,7 @@ export function createProjectPicker({
|
|
|
187
190
|
store.pushNotice('project path is required', 'warn');
|
|
188
191
|
return false;
|
|
189
192
|
}
|
|
190
|
-
|
|
193
|
+
surface.claim().close();
|
|
191
194
|
try {
|
|
192
195
|
// Switch cwd first; only persist the project once the runtime accepts it,
|
|
193
196
|
// so an invalid/missing path can never be written to projects.json.
|
|
@@ -208,11 +211,10 @@ export function createProjectPicker({
|
|
|
208
211
|
// returns to the project picker. The path is never changed.
|
|
209
212
|
const beginRenameProject = (project) => {
|
|
210
213
|
if (!project?.path) return;
|
|
211
|
-
|
|
214
|
+
const own = surface.claim();
|
|
215
|
+
own.context(null);
|
|
216
|
+
own.close();
|
|
212
217
|
setProviderPrompt(null);
|
|
213
|
-
setChannelPrompt(null);
|
|
214
|
-
setHookPrompt(null);
|
|
215
|
-
setContextPanel(null);
|
|
216
218
|
closeUsagePanel();
|
|
217
219
|
setSettingsPrompt({
|
|
218
220
|
kind: 'project-rename',
|
|
@@ -228,21 +230,20 @@ export function createProjectPicker({
|
|
|
228
230
|
// lists registered projects first, then a trailing "Current Path" shortcut.
|
|
229
231
|
// Creating a new project is available via the picker-level c shortcut.
|
|
230
232
|
const openProjectPicker = async ({ initialEntry = false } = {}) => {
|
|
233
|
+
const own = surface.claim();
|
|
231
234
|
setProviderPrompt(null);
|
|
232
|
-
setChannelPrompt(null);
|
|
233
|
-
setHookPrompt(null);
|
|
234
235
|
setSettingsPrompt(null);
|
|
235
|
-
|
|
236
|
+
own.context(null);
|
|
236
237
|
closeUsagePanel();
|
|
237
238
|
const requestId = Symbol('project-picker-request');
|
|
238
|
-
|
|
239
|
+
own.paint(buildProjectPickerState({
|
|
239
240
|
initialEntry,
|
|
240
241
|
loading: true,
|
|
241
242
|
requestId,
|
|
242
243
|
}));
|
|
243
244
|
try {
|
|
244
245
|
const projects = await serviceCall('listProjects');
|
|
245
|
-
|
|
246
|
+
own.paint((current) => current?._projectRequestId === requestId
|
|
246
247
|
? buildProjectPickerState({
|
|
247
248
|
initialEntry,
|
|
248
249
|
projects: Array.isArray(projects) ? projects : [],
|
|
@@ -251,7 +252,7 @@ export function createProjectPicker({
|
|
|
251
252
|
: current);
|
|
252
253
|
return projects;
|
|
253
254
|
} catch (error) {
|
|
254
|
-
|
|
255
|
+
own.paint((current) => current?._projectRequestId === requestId
|
|
255
256
|
? buildProjectPickerState({ initialEntry, projects: [], requestId })
|
|
256
257
|
: current);
|
|
257
258
|
store.pushNotice(`project list failed: ${error?.message || error}`, 'error');
|