MCPcopy Create free account
hub / github.com/Noumena-Network/code / enterMultilinePrompt

Function enterMultilinePrompt

src/ink/wrapperPtyInputContract.test.ts:43–93  ·  view source on GitHub ↗
(fixture: WrapperTmuxFixture)

Source from the content-addressed store, hash-verified

41}
42
43async function enterMultilinePrompt(fixture: WrapperTmuxFixture): Promise<string> {
44 let pane = ''
45 for (let attempt = 0; attempt < 3; attempt += 1) {
46 if (attempt > 0) {
47 sendKeys(fixture.session, 'C-u')
48 await Bun.sleep(100)
49 }
50
51 sendLiteral(fixture.session, 'alpha')
52 pane =
53 (await waitForPromptRows(fixture, rows =>
54 rows.some(row => row.includes('alpha')),
55 )) ?? pane
56
57 sendLiteral(fixture.session, REPL_KEY_SEQUENCES.shiftEnterKitty)
58 await Bun.sleep(150)
59 sendLiteral(fixture.session, 'beta')
60
61 const multilinePane = await waitForPromptRows(fixture, rows => {
62 const firstRow = rows[0] ?? ''
63 return (
64 firstRow.includes('❯') &&
65 firstRow.includes('alpha') &&
66 rows.slice(1).some(row => row.includes('beta'))
67 )
68 })
69 if (multilinePane) {
70 return multilinePane
71 }
72
73 // Under load, tmux may deliver the literal text before the modified
74 // Enter sequence is interpreted. Send another newline+beta rather than
75 // failing on a same-line "alphabeta" prompt.
76 sendLiteral(fixture.session, REPL_KEY_SEQUENCES.shiftEnterKitty)
77 await Bun.sleep(150)
78 sendLiteral(fixture.session, 'beta')
79 const retryPane = await waitForPromptRows(fixture, rows => {
80 const firstRow = rows[0] ?? ''
81 return (
82 firstRow.includes('❯') &&
83 firstRow.includes('alpha') &&
84 rows.slice(1).some(row => row.includes('beta'))
85 )
86 })
87 if (retryPane) {
88 return retryPane
89 }
90 }
91
92 return pane || capturePane(fixture.session, { startLine: 0 })
93}
94
95afterEach(() => {
96 while (liveFixtures.length > 0) {

Callers 1

Calls 5

sendKeysFunction · 0.85
sendLiteralFunction · 0.85
waitForPromptRowsFunction · 0.85
capturePaneFunction · 0.85
sleepMethod · 0.80

Tested by

no test coverage detected