The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Ignore SGR mouse reports when tracking the swarm prompt draft
reinSPQR31d6f257e3e2
diff --git a/cli/src/teams/promptScope.spec.ts b/cli/src/teams/promptScope.spec.tsindex 9a00f0806..caf6f73b7 100644--- a/cli/src/teams/promptScope.spec.ts+++ b/cli/src/teams/promptScope.spec.ts@@ -52,6 +52,17 @@ describe('prompt swarm origin', () => {expect(scopes.current(agent)).toBe(b)})+ it('ignores SGR mouse reports from clicking into or scrolling the pane', () => {+ const scopes = new SwarmPromptScopes()+ // Recorded shape: click to focus (split press/release), a wheel burst, then ⌥⏎ lines.+ for (const chunk of ['\x1b[<0;12;34M', '\x1b[<0;12;34m', '\x1b[<65;40;20M'.repeat(19), '\x1b', '[<64;4', '0;20M', '\x1b\r', '\x1b\r', 'ok', '\r']) scopes.raw(agent, bytes(chunk), 'swarm-a')+ scopes.started(agent, '\n\nok', 'hook', 'claude')+ expect(scopes.current(agent)).toBe(a)+ scopes.raw(agent, bytes('x\x1b[<0;12M\r'), 'swarm-b') // A malformed report is not a mouse event.+ scopes.started(agent, 'x', 'hook', 'claude')+ expect(scopes.current(agent)).toBeNull()+ })+it('still fails closed on ⌥⌫ and on other CSI keys that share the ⇧⏎ prefix', () => {const scopes = new SwarmPromptScopes()scopes.raw(agent, bytes('one two\x1b\x7f\r'), 'swarm-a')diff --git a/cli/src/teams/promptScope.ts b/cli/src/teams/promptScope.tsindex 44e1fa1b4..22f6906ae 100644--- a/cli/src/teams/promptScope.ts+++ b/cli/src/teams/promptScope.ts@@ -127,6 +127,12 @@ export class SwarmPromptScopes {// Inside a paste the engine receives those bytes literally, so they fail closed there.if (state.escape === '\x1b[13;2u' && !state.paste) { state.escape = ''; insert('\n'); continue }if (state.escape === '\x1b\r' && escaped && !state.paste) { state.escape = ''; insert('\n'); metaReturn = true; continue }+ // SGR mouse reports (focus clicks, wheel) never type text. If a click did move the engine's+ // caret, the draft stops matching the accepted prompt, which still fails closed.+ if (state.escape.startsWith('\x1b[<') && !state.paste) {+ if (/^\x1b\[<[\d;]*$/.test(state.escape) && state.escape.length < 32) continue+ if (/^\x1b\[<\d+;\d+;\d+[Mm]$/.test(state.escape)) { state.escape = ''; continue }+ }if (['\x1b', '\x1b[', '\x1b[1', '\x1b[13', '\x1b[13;', '\x1b[13;2', '\x1b[2', '\x1b[20', '\x1b[200', '\x1b[201', '\x1b[3', '\x1bO'].includes(state.escape)) continueconst sequence = state.escapestate.escape = ''