File tree Expand file tree Collapse file tree
apps/desktop/src/main/terminal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { sleep } from '@sim/utils/helpers'
21import { Terminal } from '@xterm/headless'
32import { describe , expect , it } from 'vitest'
43import { findSelectedRow } from '@/main/terminal/session'
@@ -7,14 +6,14 @@ const REVERSE = '\u001b[7m'
76const RESET = '\u001b[0m'
87
98/**
10- * Writes to a real headless emulator and lets it settle, so these exercise the
11- * same buffer the agent reads rather than a hand-built fake. xterm parses
12- * asynchronously, hence the flush .
9+ * Writes to a real headless emulator and waits for the queued writes to finish,
10+ * so these exercise the same buffer the agent reads. The trailing empty write's
11+ * callback fires after xterm has parsed every preceding chunk .
1312 */
1413async function screen ( write : ( term : Terminal ) => void , rows = 8 ) : Promise < Terminal > {
1514 const term = new Terminal ( { cols : 40 , rows, allowProposedApi : true } )
1615 write ( term )
17- await sleep ( 30 )
16+ await new Promise < void > ( ( resolve ) => term . write ( '' , resolve ) )
1817 return term
1918}
2019
You can’t perform that action at this time.
0 commit comments