Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/extension/src/demo_replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { generateRunId, appendIndex, updateLatest } from "@amicode/amico-run";
* rewrite run.toml's `run_id` to match the new directory, append the
* index, and swing `latest` to it. Reuses the β.1 run-dir primitives so the
* staged run is byte-for-byte contract-identical and the existing
* RunsRootWatcher renders it exactly like a live solve.
* RunsManager discovers it off the index and renders it like a live solve.
*
* Filesystem side effects only (pure w.r.t. its inputs). Returns the staged
* run directory.
Expand Down
26 changes: 16 additions & 10 deletions packages/extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { prepareOpencodeProject, resolveJuliaProject, buildOpencodeConfigContent
import { resolveAmicoRunBinDir, resolveRunsRoot } from "./opencode_paths";
import { resolveLabTomlPath, checkLabToml } from "./lab_config";
import { OpencodeEventClient } from "./sse_client";
import { RunsRootWatcher } from "./file_watcher";
import { RunsManager } from "./runs_manager";
import { stageDemoRun } from "./demo_replay";
import { readTomlSafe } from "./run_dir_reader";

Expand All @@ -29,7 +29,7 @@ import { readTomlSafe } from "./run_dir_reader";
let serverManager: ServerManager | undefined;
let statusBar: StatusBarManager | undefined;
let sseClient: OpencodeEventClient | undefined;
let watcher: RunsRootWatcher | undefined;
let runsManager: RunsManager | undefined;
let opencodeReadyUrl: URL | undefined;


Expand Down Expand Up @@ -90,12 +90,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
statusBar = new StatusBarManager();
ctx.subscriptions.push({ dispose: () => statusBar?.dispose() });

// 2. Start watching the runs root immediately — solves may already exist
// from prior dev-host sessions, and watchers are cheap.
// 2. Start the multi-run RunsManager immediately — it tails the append-only
// runs/index (1.2, #57), so solves from prior dev-host sessions register and
// a still-live run resumes; every concurrent run is tracked to completion.
fs.mkdirSync(runsRoot, { recursive: true });
watcher = new RunsRootWatcher({ runsRoot, channel: runsChannel, statusBar });
watcher.start();
ctx.subscriptions.push(watcher);
runsManager = new RunsManager({ runsRoot, channel: runsChannel, statusBar });
runsManager.start();
ctx.subscriptions.push(runsManager);

// Validate lab.toml on load (0.1b / S17). A malformed hardware profile would
// otherwise silently solve against the wrong hardware or fail opaquely mid-solve.
Expand Down Expand Up @@ -241,8 +242,11 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
}
}),
// On-site fallback (β.6): stage the bundled pre-baked solve into the runs
// root. The watcher already running on runsRoot follows `latest` →
// ingestRunDir replays the converged solve — no Julia, no opencode, no creds.
// root. Under the multi-run RunsManager (#57) a run that is FINISHED at
// discovery registers quietly (no auto-display), so the demo is shown by
// EXPLICIT selection: poke the index tail (same-tick registration), then
// selectRun → the display replay renders the converged solve — no Julia,
// no opencode, no creds. Promote stays suppressed (finished at discovery).
vscode.commands.registerCommand("amicode.replayDemo", async () => {
const demoDir = path.join(ctx.extensionPath, "demo", "run");
if (!fs.existsSync(path.join(demoDir, "FINISHED"))) {
Expand All @@ -251,6 +255,8 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
}
try {
const runDir = stageDemoRun(demoDir, runsRoot);
runsManager?.pokeDiscovery();
runsManager?.selectRun(path.basename(runDir));
runsChannel.appendLine(`[demo] replayed → ${runDir}`);
await vscode.commands.executeCommand("amicode.runInspector.focus");
// Save-to-catalog prompt (#47): the watcher suppresses the promote
Expand All @@ -276,7 +282,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
export function deactivate(): void {
sseClient?.dispose();
serverManager?.stop();
watcher?.dispose();
runsManager?.dispose();
statusBar?.dispose();
}

Loading
Loading