Skip to content

Commit 27b790e

Browse files
committed
fix(web/shell): #107 review — a Stop during the agent's review says that what it applied is in Keep/Undo
The bug: an agent run stopped (Stop, or agent.js's commandTimeout) while levelcode-ai's review of its file changes is going on is settled at once, and the review keeps what it had applied before the Stop. The note the model and the agent's tab got said "it may still apply some of them, and how many it applied is not known", but not where those changes are, so the model could not tell the user what to look at, and the prompt (fixed in the commit before) had told it nothing changes. The fix: the note ends "Any it applied are in the Keep/Undo review." It is said only in the review phase, which only an agent run (one with `commit`) has; the check and the writing phases are unchanged. The mutation table's anchor for this note follows it (the mutation is still caught by shell-runtime-commit). Tests: shell-runtime-commit.test.js "Stop while the agent's review is going on ends the run AT ONCE" and "the same for an agent that is killed while its review is going on, and for a worker that died after done on top of it" now require the sentence. Both fail on the unfixed note and pass now.
1 parent e37ec59 commit 27b790e

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎web/shell/src/runtime.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,8 @@ function createRuntime(deps) {
860860
if (p.phase === 'check') {
861861
notes.push(note('stopped before anything was applied: the command\'s file changes were being checked, and were NOT applied.'));
862862
} else if (p.phase === 'review') {
863-
notes.push(note('stopped while the review of its file changes was going on. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known.'));
863+
// (the review is levelcode-ai's Keep/Undo: what it applied before the Stop stays there, and the model and the visitor are told where)
864+
notes.push(note('stopped while the review of its file changes was going on. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known. Any it applied are in the Keep/Undo review.'));
864865
} else {
865866
applied = p.applied;
866867
notes.push(note('stopped while its file changes were being applied: ' + applied + ' of ' + p.total + ' were applied.'

‎web/test/helpers/mutation/mutations.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export const mutations = [
384384
{ name: 'stop: a Stop in the writing says nothing of the write that may still land', edits: [e(RT, " The change being made at that moment cannot be cancelled and may still land; nothing more was started.", " Nothing more was started.")], tests: ['shell-runtime-commit'] },
385385
{ name: 'stop: a Stop with only a read in flight claims that a write may still land', edits: [e(RT, "(landing ? ' The change being made at that moment cannot be cancelled and may still land; nothing more was started.' : ' Nothing more was started.')", "' The change being made at that moment cannot be cancelled and may still land; nothing more was started.'")], tests: ['shell-runtime-commit'] },
386386
{ name: 'stop: the gate says nothing was in flight that changes things', edits: [e(RT, "landing = landing || writes; give(stopped());", "give(stopped());")], tests: ['shell-runtime-commit'] },
387-
{ name: 'stop: a Stop in the review says that nothing was applied', edits: [e(RT, "stopped while the review of its file changes was going on. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known.", "stopped. Its file changes were NOT applied.")], tests: ['shell-runtime-commit'] },
387+
{ name: 'stop: a Stop in the review says that nothing was applied', edits: [e(RT, "stopped while the review of its file changes was going on. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known. Any it applied are in the Keep/Undo review.", "stopped. Its file changes were NOT applied.")], tests: ['shell-runtime-commit'] },
388388
{ name: 'stop: the review is not marked as the phase', edits: [e(RT, "progress.phase = 'review';", "")], tests: ['shell-runtime-commit'] },
389389
{ name: 'stop: the folders left by the review are not marked as the phase', edits: [e(RT, "progress.phase = 'rest';", "")], tests: ['shell-runtime-commit'] },
390390
{ name: 'stop: what the review applied is not carried into the progress', edits: [e(RT, "progress.applied = applied;", "")], tests: ['shell-runtime-commit'] },

‎web/test/unit/shell-runtime-commit.test.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ async function agent(rig, command, opts) {
444444
await obs.closed; // before the review has answered
445445
const close = /** @type {any} */ (obs.events.find((e) => e.type === 'close'));
446446
assert.strictEqual(close.code, 130);
447-
assert.ok(/stopped while the review of its file changes was going on\. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known\./.test(obs.stderr), obs.stderr);
447+
assert.ok(/stopped while the review of its file changes was going on\. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known\. Any it applied are in the Keep\/Undo review\./.test(obs.stderr), obs.stderr);
448448
assert.ok(!/were NOT applied/.test(obs.stderr), 'it does not say nothing was applied: it does not know');
449449
release();
450450
await flush();
@@ -1318,7 +1318,7 @@ async function agent(rig, command, opts) {
13181318
await o.closed;
13191319
assert.strictEqual(/** @type {any} */ (o.events[o.events.length - 1]).code, 130);
13201320
assert.deepStrictEqual(o.stderr.split('\n').slice(0, -1), HEAD.concat([
1321-
'[LevelCode Shell: stopped while the review of its file changes was going on. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known.]',
1321+
'[LevelCode Shell: stopped while the review of its file changes was going on. A review cannot be interrupted: it may still apply some of them, and how many it applied is not known. Any it applied are in the Keep/Undo review.]',
13221322
'[LevelCode Shell: the shell engine stopped unexpectedly: segfault, after the command had finished]',
13231323
]));
13241324
r.rt.dispose();

0 commit comments

Comments
 (0)