Refactor: Introduce InteractiveRun class (#10947)

This commit is contained in:
Tommaso Sciortino
2025-10-11 08:33:01 -07:00
committed by GitHub
parent 09ef33ec3a
commit 5dc7059ba3
7 changed files with 137 additions and 130 deletions
@@ -5,7 +5,7 @@
*/
import { expect, describe, it, beforeEach, afterEach } from 'vitest';
import { TestRig, type } from './test-helper.js';
import { TestRig } from './test-helper.js';
describe('Interactive Mode', () => {
let rig: TestRig;
@@ -21,20 +21,20 @@ describe('Interactive Mode', () => {
it('should trigger chat compression with /compress command', async () => {
await rig.setup('interactive-compress-test');
const ptyProcess = await rig.runInteractive();
const run = await rig.runInteractive();
const longPrompt =
'Dont do anything except returning a 1000 token long paragragh with the <name of the scientist who discovered theory of relativity> at the end to indicate end of response. This is a moderately long sentence.';
await type(ptyProcess, longPrompt);
await type(ptyProcess, '\r');
await run.type(longPrompt);
await run.type('\r');
await rig.waitForText('einstein', 25000);
await run.waitForText('einstein', 25000);
await type(ptyProcess, '/compress');
await run.type('/compress');
// A small delay to allow React to re-render the command list.
await new Promise((resolve) => setTimeout(resolve, 100));
await type(ptyProcess, '\r');
await run.type('\r');
const foundEvent = await rig.waitForTelemetryEvent(
'chat_compression',
@@ -49,12 +49,11 @@ describe('Interactive Mode', () => {
it.skip('should handle compression failure on token inflation', async () => {
await rig.setup('interactive-compress-test');
const ptyProcess = await rig.runInteractive();
const run = await rig.runInteractive();
await type(ptyProcess, '/compress');
await run.type('/compress');
await new Promise((resolve) => setTimeout(resolve, 100));
await type(ptyProcess, '\r');
await rig.waitForText('compression was not beneficial', 25000);
await run.type('\r');
await run.waitForText('compression was not beneficial', 25000);
});
});