Skip to content

fix(hooks): enforce socket-based Kitty remote control in v3.0 tab-setter#675

Merged
kaimagnus merged 1 commit intodanielmiessler:mainfrom
Mutdogus:fix/kitty-socket-remote-control
Feb 17, 2026
Merged

fix(hooks): enforce socket-based Kitty remote control in v3.0 tab-setter#675
kaimagnus merged 1 commit intodanielmiessler:mainfrom
Mutdogus:fix/kitty-socket-remote-control

Conversation

@Mutdogus
Copy link
Contributor

Summary

Resolves the escape sequence leak issue originally reported in #493, rebased against the v3.0 hook architecture.

Problem: When kitty @ / kitten @ commands run without the --to <socket> flag in subprocess contexts (hooks), Kitty responds via escape sequences that leak into terminal output as visible garbage text like P@kitty-cmd{"ok": false, "error": "Remote control is disabled"}.

Root cause: In v3.0's lib/tab-setter.ts, getKittyEnv() resolves the socket from env vars and per-session files, but when neither is available, kitten commands fall through to escape-sequence-based IPC — the exact bug #493 fixed for v2.x.

Fix (single file — Releases/v3.0/.claude/hooks/lib/tab-setter.ts):

  • Add default socket fallback (/tmp/kitty-$USER) to getKittyEnv() for socket-only configs
  • Require socket for ALL kitten @ commands — skip gracefully if unavailable instead of falling back to escape-sequence IPC
  • Fix cleanupStaleStateFiles() to also use socket-based IPC
  • Remove conditional --to flag pattern (now always required when executing)

User Configuration Required

# kitty.conf
allow_remote_control socket-only
listen_on unix:/tmp/kitty-{user}

Context

This is a rebase of #493 against the v3.0 architecture. The original PR targeted the v2.x Packs/pai-hook-system/src/hooks/ paths which no longer exist. In v3.0, all kitty interaction is centralized in lib/tab-setter.ts, making this a cleaner single-file fix.

Closes #493

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Resolves the escape sequence leak issue from danielmiessler#493 for the v3.0 hook
architecture. When kitty @ commands run without --to flag in subprocess
contexts, Kitty responds via escape sequences that leak into terminal
output as visible garbage (e.g. "P@kitty-cmd{...}").

Changes to lib/tab-setter.ts (centralized in v3.0):
- Add default socket fallback (/tmp/kitty-$USER) to getKittyEnv()
- Require socket for all kitten @ commands (skip gracefully if unavailable)
- Fix cleanupStaleStateFiles() to also use socket-based IPC
- Remove conditional --to flag (now always required when executing)

User configuration required in kitty.conf:
  allow_remote_control socket-only
  listen_on unix:/tmp/kitty-{user}

Closes danielmiessler#493

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kaimagnus kaimagnus merged commit db32eb6 into danielmiessler:main Feb 17, 2026
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.

2 participants