Skip to content

fix(terminal): correct CSI handler params for DECRQM workaround#993

Merged
arnestrickmann merged 1 commit intomainfrom
fix/terminal-csi-handler-params
Feb 20, 2026
Merged

fix(terminal): correct CSI handler params for DECRQM workaround#993
arnestrickmann merged 1 commit intomainfrom
fix/terminal-csi-handler-params

Conversation

@arnestrickmann
Copy link
Contributor

Summary

  • Fixes crash when spawning OpenCode CLI: Cannot read properties of undefined (reading '0') at TerminalSessionManager.ts:215
  • The registerCsiHandler callback receives params as (number | number[])[] directly, not as an object with a .params property — the code was accessing params.params[0] which is undefined
  • The bug existed since the DECRQM workaround was added but was never triggered until OpenCode sent mode-query escape sequences

Test plan

  • Spawn OpenCode CLI agent — should no longer crash
  • Spawn Amp agent — DECRQM workaround still functions correctly
  • Other CLI agents (Claude Code, Codex, etc.) unaffected

🤖 Generated with Claude Code

…rkaround

The registerCsiHandler callback receives params as (number | number[])[]
directly, not as an object with a .params property. This caused a crash
("Cannot read properties of undefined (reading '0')") when agents like
OpenCode sent DECRQM escape sequences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 20, 2026 5:48am

Request Review

@arnestrickmann arnestrickmann merged commit 5a87daf into main Feb 20, 2026
4 checks passed
@greptile-apps
Copy link

greptile-apps bot commented Feb 20, 2026

Greptile Summary

Fixed critical crash in terminal spawning by correcting the CSI handler callback parameter type for the DECRQM workaround.

Key changes:

  • Updated registerCsiHandler callback params from { params: number[] } to (number | number[])[] in both ANSI and DEC mode handlers
  • Changed access pattern from params.params[0] to params[0] with appropriate type assertion
  • The bug was dormant since the workaround was added but triggered when OpenCode CLI sent mode-query escape sequences

Impact:

  • Prevents Cannot read properties of undefined (reading '0') crash at TerminalSessionManager.ts:215
  • Maintains existing DECRQM workaround functionality for Amp agent
  • No behavioral changes, only corrects the type signature to match xterm.js API

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The fix corrects a clear type error where the callback parameter signature didn't match the xterm.js API. The change is minimal (4 lines), well-documented in the PR description, and only affects the type annotation and property access pattern - no logic changes. The fix directly addresses a runtime crash with a straightforward correction.
  • No files require special attention

Important Files Changed

Filename Overview
src/renderer/terminal/TerminalSessionManager.ts Fixed critical type error in CSI handler callback - corrected params type from object to array, preventing crash when OpenCode sends DECRQM sequences

Last reviewed commit: 91ab080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant