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:
@@ -71,6 +71,12 @@ export function eventReducer(state: Session, event: Action): Session {
|
||||
updated = { ...run, status: "hostKey", hostKey: event };
|
||||
break;
|
||||
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 = {
|
||||
...run,
|
||||
status: event.exitCode === 0 ? "success" : "failure",
|
||||
|
||||
@@ -25,6 +25,26 @@ describe("event reducer", () => {
|
||||
expect(state.runs["1"]?.output.map((c) => c.data).join("")).toBe("ab");
|
||||
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", () => {
|
||||
const state = eventReducer(eventReducer(emptySession, started), {
|
||||
type: "run.finished",
|
||||
|
||||
Reference in New Issue
Block a user