Skip to content

fix(code): drop lock-key events so Caps Lock in iTerm2 doesn't type - #3855

Merged
Mason Daugherty (mdrxy) merged 12 commits into
mainfrom
mdrxy/code/caps-lock-iterm-types-letter
Jun 11, 2026
Merged

fix(code): drop lock-key events so Caps Lock in iTerm2 doesn't type#3855
Mason Daugherty (mdrxy) merged 12 commits into
mainfrom
mdrxy/code/caps-lock-iterm-types-letter

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jun 10, 2026

Copy link
Copy Markdown
Member

When deepagents-code enables the kitty keyboard protocol with associated-text reporting (the default in iTerm2, VS Code's xterm.js, and other modern terminals), pressing a lock key such as Caps Lock arrives as a key event whose character is the text the next keypress would have produced — for example key='caps_lock', character='A'. Textual's parser does not strip that associated text, so the chat input's TextArea treated it as printable and inserted a stray letter on every Caps Lock press.

ChatTextArea._on_key now swallows caps_lock, num_lock, and scroll_lock events before any insertion logic runs, so toggling those locks never mutates the input.

Made by Open SWE

Under the kitty keyboard protocol with associated-text reporting (iTerm2,
VS Code's xterm.js, etc.), pressing Caps Lock arrives as a key event whose
character is the would-be text (e.g. key='caps_lock', character='A'), so the
chat TextArea inserted a stray letter. Swallow caps_lock/num_lock/scroll_lock
events in ChatTextArea._on_key.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC labels Jun 10, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review June 10, 2026 23:48

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

Mason Daugherty (mdrxy) and others added 7 commits June 10, 2026 20:59
The first fix only caught the clean Key(key='caps_lock') event. iTerm2's
kitty encoding also sends colon sub-fields (alternate-key / event-type
reporting) that the pinned Textual 8.2.7 parser rejects, leaking the raw
'[57358...' bytes one character at a time, plus modifier-prefixed lock-key
variants (e.g. 'ctrl+caps_lock') that the exact match missed.

- Add a parser patch that strips ':' sub-fields from kitty extended-key
  sequences before Textual parses them, so they resolve to a single key
  event instead of leaking literal text.
- Match lock keys by their final '+'-delimited token so modifier-prefixed
  forms are dropped too.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
…oding

The previous fix stripped colon sub-fields, which handled some iTerm2 caps
lock encodings but still relied on the exact downstream key/character shape.
Make it encoding-agnostic: any kitty sequence whose leading key code is a
lock key (Caps Lock 57358, Scroll Lock 57359, Num Lock 57360) now collapses
to a single character-less key event in the parser patch, no matter what
modifier, associated-text, or event-type sub-fields the terminal appends.
Non-lock keys with colon sub-fields still get normalized so they don't leak.
The chat-input guard stays as defense-in-depth.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
The real bytes from iTerm2 show it reports the Caps Lock toggle as the
upper-case letter the next key would produce (e.g. 'CSI 65 u' -> 'A') with
no modifier or associated-text field, NOT the kitty functional code 57358
the earlier patches targeted. Per the kitty spec the primary code point is
always the unshifted (lower-case) value, so a bare upper-case ASCII letter
with no real modifiers and no text can only be iTerm2's Caps Lock artifact.
Collapse it to a character-less caps_lock event. Real upper-case input
(shift, or caps-on typing) carries an associated-text field and is preserved.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Jun 11, 2026
@mdrxy
Mason Daugherty (mdrxy) merged commit 110f1a7 into main Jun 11, 2026
45 of 47 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/caps-lock-iterm-types-letter branch June 11, 2026 02:48
Mason Daugherty (mdrxy) added a commit that referenced this pull request Jun 11, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Everything below this line will be the GitHub release body._

---


##
[0.1.13](deepagents-code==0.1.12...deepagents-code==0.1.13)
(2026-06-11)

### Features

* Pluggable third-party sandbox backends
([#3842](#3842))
([2b635a7](2b635a7))
* Auto-install ripgrep on first run
([#3348](#3348))
([fecf22b](fecf22b))
* `config` command and canonical config manifest
([#3763](#3763))
([79899a3](79899a3))
* Confirm modal for `/install --package`
([#3840](#3840))
([3d75026](3d75026))
* Copy focused input selection on `Ctrl+C`
([#3841](#3841))
([99f782c](99f782c))
* `[retries]` config
([#3772](#3772))
([9334d91](9334d91))
* Show connection state in the status bar
([#3710](#3710))
([3e3e8fe](3e3e8fe))
* Surface LangSmith tracing projects in `LocalContextMiddleware`
([#3836](#3836))
([676abec](676abec))

### Bug Fixes

* Add debug-log guidance for truncated startup errors
([#3849](#3849))
([cd1ef30](cd1ef30))
* Drop lock-key events so Caps Lock in iTerm2 doesn't type
([#3855](#3855))
([110f1a7](110f1a7))
* Hand pointer over splash tracing project link
([#3858](#3858))
([ea7dae5](ea7dae5))
* Keep terminal-default theme on Esc in `/theme` selector
([#3854](#3854))
([c3bc67b](c3bc67b))
* Preserve inherited `PYTHONPATH` for server subprocess
([#3833](#3833))
([4689569](4689569))
* Resolve interpreter PTC allowlist against the runtime tool registry
([#3845](#3845))
([c59a27e](c59a27e))
* Treat multi-line key-event pastes as one input
([#3856](#3856))
([6bb15d4](6bb15d4))

---

_Everything above this line will be the GitHub release body._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
…angchain-ai#3855)

When `deepagents-code` enables the kitty keyboard protocol with
associated-text reporting (the default in iTerm2, VS Code's xterm.js,
and other modern terminals), pressing a lock key such as Caps Lock
arrives as a key event whose `character` is the text the *next* keypress
would have produced — for example `key='caps_lock'`, `character='A'`.
Textual's parser does not strip that associated text, so the chat
input's `TextArea` treated it as printable and inserted a stray letter
on every Caps Lock press.

`ChatTextArea._on_key` now swallows `caps_lock`, `num_lock`, and
`scroll_lock` events before any insertion logic runs, so toggling those
locks never mutates the input.

Made by [Open SWE](https://openswe.vercel.app)

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Everything below this line will be the GitHub release body._

---


##
[0.1.13](langchain-ai/deepagents@deepagents-code==0.1.12...deepagents-code==0.1.13)
(2026-06-11)

### Features

* Pluggable third-party sandbox backends
([langchain-ai#3842](langchain-ai#3842))
([2b635a7](langchain-ai@2b635a7))
* Auto-install ripgrep on first run
([langchain-ai#3348](langchain-ai#3348))
([fecf22b](langchain-ai@fecf22b))
* `config` command and canonical config manifest
([langchain-ai#3763](langchain-ai#3763))
([79899a3](langchain-ai@79899a3))
* Confirm modal for `/install --package`
([langchain-ai#3840](langchain-ai#3840))
([3d75026](langchain-ai@3d75026))
* Copy focused input selection on `Ctrl+C`
([langchain-ai#3841](langchain-ai#3841))
([99f782c](langchain-ai@99f782c))
* `[retries]` config
([langchain-ai#3772](langchain-ai#3772))
([9334d91](langchain-ai@9334d91))
* Show connection state in the status bar
([langchain-ai#3710](langchain-ai#3710))
([3e3e8fe](langchain-ai@3e3e8fe))
* Surface LangSmith tracing projects in `LocalContextMiddleware`
([langchain-ai#3836](langchain-ai#3836))
([676abec](langchain-ai@676abec))

### Bug Fixes

* Add debug-log guidance for truncated startup errors
([langchain-ai#3849](langchain-ai#3849))
([cd1ef30](langchain-ai@cd1ef30))
* Drop lock-key events so Caps Lock in iTerm2 doesn't type
([langchain-ai#3855](langchain-ai#3855))
([110f1a7](langchain-ai@110f1a7))
* Hand pointer over splash tracing project link
([langchain-ai#3858](langchain-ai#3858))
([ea7dae5](langchain-ai@ea7dae5))
* Keep terminal-default theme on Esc in `/theme` selector
([langchain-ai#3854](langchain-ai#3854))
([c3bc67b](langchain-ai@c3bc67b))
* Preserve inherited `PYTHONPATH` for server subprocess
([langchain-ai#3833](langchain-ai#3833))
([4689569](langchain-ai@4689569))
* Resolve interpreter PTC allowlist against the runtime tool registry
([langchain-ai#3845](langchain-ai#3845))
([c59a27e](langchain-ai@c59a27e))
* Treat multi-line key-event pastes as one input
([langchain-ai#3856](langchain-ai#3856))
([6bb15d4](langchain-ai@6bb15d4))

---

_Everything above this line will be the GitHub release body._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant