Skip to content

Commit

Permalink
fix #213563
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed May 27, 2024
1 parent b085f37 commit 95c2423
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,9 @@ export class InlineChatController implements IEditorContribution {
}
});
} else if (e.kind === 'removeRequest') {
// TODO@jrieken this currently is buggy when removing not the very last request/response
// if (this._session!.lastExchange?.response instanceof ReplyResponse) {
// try {
// this._session!.hunkData.ignoreTextModelNChanges = true;
// await this._strategy!.undoChanges(this._session!.lastExchange.response.modelAltVersionId);
// } finally {
// this._session!.hunkData.ignoreTextModelNChanges = false;
// }
// }
// TODO@jrieken this is buggy/weird when having code changes from multiple turns because
// logically they are all the same hunks
this._strategy?.cancel();
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { ChatVariablesService } from 'vs/workbench/contrib/chat/browser/chatVari
import { ICommandService } from 'vs/platform/commands/common/commands';
import { TestCommandService } from 'vs/editor/test/browser/editorTestServices';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
import { RerunAction } from 'vs/workbench/contrib/inlineChat/browser/inlineChatActions';

suite('InteractiveChatController', function () {

Expand Down Expand Up @@ -458,4 +459,39 @@ suite('InteractiveChatController', function () {
assert.ok(model.getValue().includes('MANUAL'));

});

test('re-run should discard pending edits', async function () {

let count = 1;

store.add(chatAgentService.registerDynamicAgent({
id: 'testEditorAgent2',
...agentData
}, {
async invoke(request, progress, history, token) {
progress({ kind: 'textEdit', uri: model.uri, edits: [{ range: new Range(1, 1, 1, 1), text: request.message + (count++) }] });
return {};
},
}));

ctrl = instaService.createInstance(TestController, editor);
const rerun = new RerunAction();

model.setValue('');

const p = ctrl.waitFor([...TestController.INIT_SEQUENCE, State.SHOW_REQUEST, State.SHOW_RESPONSE, State.WAIT_FOR_INPUT]);
const r = ctrl.run({ message: 'PROMPT_', autoSend: true });
await p;

assert.strictEqual(model.getValue(), 'PROMPT_1');

const p2 = ctrl.waitFor([State.SHOW_REQUEST, State.SHOW_RESPONSE, State.WAIT_FOR_INPUT]);
await instaService.invokeFunction(rerun.runInlineChatCommand, ctrl, editor);

await p2;

assert.strictEqual(model.getValue(), 'PROMPT_2');
ctrl.finishExistingSession();
await r;
});
});

0 comments on commit 95c2423

Please sign in to comment.