fix(web): keep host key prompt open after the aborted run finishes (#2)

The server publishes run.finished (exit -1) right after run.hostKeyUnknown, which closed the confirmation dialog immediately.
This commit is contained in:
Florian Schmidt
2026-11-16 00:13:24 +01:00
parent cc68fe39b3
commit 4e79af3e24
2 changed files with 26 additions and 0 deletions
+6
View File
@@ -71,6 +71,12 @@ export function eventReducer(state: Session, event: Action): Session {
updated = { ...run, status: "hostKey", hostKey: event }; updated = { ...run, status: "hostKey", hostKey: event };
break; break;
case "run.finished": { case "run.finished": {
// An attempt aborted for host key confirmation also finishes (exit -1);
// keep the prompt open until the user accepts or rejects.
if (run.status === "hostKey") {
updated = { ...run, exitCode: event.exitCode, durationMs: event.durationMs };
break;
}
updated = { updated = {
...run, ...run,
status: event.exitCode === 0 ? "success" : "failure", status: event.exitCode === 0 ? "success" : "failure",
+20
View File
@@ -25,6 +25,26 @@ describe("event reducer", () => {
expect(state.runs["1"]?.output.map((c) => c.data).join("")).toBe("ab"); expect(state.runs["1"]?.output.map((c) => c.data).join("")).toBe("ab");
expect(JSON.stringify(state)).not.toContain(started.script); expect(JSON.stringify(state)).not.toContain(started.script);
}); });
it("keeps the host key prompt when the server finishes the aborted run", () => {
// The server publishes run.hostKeyUnknown, then run.finished (exit -1) for the aborted attempt.
let state = eventReducer(emptySession, started);
state = eventReducer(state, {
type: "run.hostKeyUnknown",
runId: "1",
host: "web",
fingerprint: "SHA256:abc",
changed: false,
});
state = eventReducer(state, {
type: "run.finished",
runId: "1",
exitCode: -1,
durationMs: 5,
artifacts: [],
});
expect(state.runs["1"]?.status).toBe("hostKey");
expect(state.runs["1"]?.hostKey?.fingerprint).toBe("SHA256:abc");
});
it("captures successful values and artifact provenance by notebook", () => { it("captures successful values and artifact provenance by notebook", () => {
const state = eventReducer(eventReducer(emptySession, started), { const state = eventReducer(eventReducer(emptySession, started), {
type: "run.finished", type: "run.finished",