fix(claude-mobile): сбрасывать режимы терминала при отсоединении - #1
Open
dudkin-2005 wants to merge 1 commit into
Open
fix(claude-mobile): сбрасывать режимы терминала при отсоединении#1dudkin-2005 wants to merge 1 commit into
dudkin-2005 wants to merge 1 commit into
Conversation
Claude Code enables mouse reporting and bracketed paste inside the PTY, and attach.js pipes PTY output to the real TTY verbatim. On Ctrl+\ the session stays alive, so nobody ever sends the matching reset sequences: the terminal keeps reporting mouse movement as escape garbage and keeps expecting bracketed paste. cleanup() now resets those modes itself. Both exits from mirroring go through die() -> cleanup(): Ctrl+\ and session exit. Alt screen (?1049l) is deliberately left alone — Claude Code draws in the normal buffer, and a blind reset would wipe the session output. Also document installing claude-mobile as a symlink to bridge/attach.js (RU + EN README); the exec bit is now set in the repo. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PiXf3gNxZZqcRMVqWkF8Y9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема
После
Ctrl+\терминал начинает печатать мусор при каждом движении мыши, а вставка из буфера ломается.Claude Code при старте включает репортинг мыши (
?1000h/?1002h/?1006h) и bracketed paste (?2004h).attach.jsпрокидывает вывод PTY в реальный TTY байт-в-байт, так что эти последовательности применяются к терминалу пользователя. При отсоединении сессия остаётся жива в хранителе — то есть тот, кто эти режимы включил, никогда не пришлёт парный сброс.cleanup()выключал только raw-режим stdin.Воспроизводится на любом терминале, я ловил на WSL2 + Windows Terminal.
Решение
cleanup()теперь сбрасывает режимы сам. Оба выхода из зеркалирования идут черезdie()→cleanup():Ctrl+\и завершение самой сессии. Ветки-l,--qr,--deviceв raw-режим не входят, им сброс безвреден.Alt screen (
?1049l) намеренно не трогаю: Claude Code рисует в обычном буфере, и слепой сброс стёр бы вывод сессии, который пользователь только что смотрел.Заодно — установка
claude-mobileREADME описывает утилиту, но не говорит, как её получить: в PATH она сама не появляется. Добавил шаг с симлинком на
bridge/attach.jsв оба README (RU/EN) и выставил бит исполнения на файле — шебанг у него уже был.Проверка
node --check bridge/attach.jsclaude-mobile→Ctrl+\→ мышь больше не печатается, вставка работает; сессия остаётся живой и видна с телефонаОтдельно, не в этом PR: правила в
.gitignoreзаписаны с комментарием на той же строке (bridge/config.json # личные пути/прокси), а gitignore такого не поддерживает — комментарий становится частью паттерна.git check-ignoreпоказывает, чтоbridge/config.json,bridge/pairings.jsonиbridge/internet.jsonсейчас не игнорируются ничем; сертификаты спасает только*.pem/*.keyниже. Учитывая, что вpairings.jsonлежат токены доверенных устройств, стоит починить — могу прислать отдельным PR, если интересно.🤖 Generated with Claude Code