Repository navigation
Conversation
Since Claude Code ~2.1.260 the first launch in an untrusted directory shows an unnumbered "Quick safety check" menu whose default option is "No, exit". ccbot never answered it: the SessionStart hook doesn't fire, the 5s wait times out, and the pending first message is typed into the dialog — Enter on the default option exits Claude, leaving the topic bound to a bare shell. - claude_config.ensure_trusted_directory() sets projects[<git root or dir>].hasTrustDialogAccepted = true in ~/.claude.json (honours CLAUDE_CONFIG_DIR) before creating the window. Atomic write, file mode preserved, no-op if already trusted, missing or malformed files left untouched. CCBOT_AUTO_TRUST_DIRS=false disables it. - Fallback for when the dialog still appears (e.g. the home directory, whose trust Claude Code doesn't persist): a TrustDialog UI pattern and TmuxManager.auto_answer_dialog(), which moves the ❯ cursor onto "Yes, I trust", re-captures to verify, then presses Enter. It never types a digit, since option order changed between versions. - _create_and_bind_window waits for Claude's input box (wait_for_claude_ready) before the hook wait and before forwarding the pending message; status polling answers the dialog in existing windows. Pane fixtures are real tmux captures from Claude Code 2.1.272.
Named sessions render the input box's top border as '──────── my-session ─', which the plain all-dashes check rejected, so wait_for_claude_ready timed out on otherwise-ready sessions. Fixture is a real 2.1.272 capture.
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.
Problem
Since Claude Code ~2.1.260, launching
claudein a directory that isn't trusted yet shows this first:The options have no numbers now, and "No, exit" is the default. ccbot never answers the dialog, so a new session breaks:
wait_for_session_map_entrytimes out./model,/context, …) go to zsh (zsh: no such file or directory: /model).Fix
claude_config.ensure_trusted_directory()setsprojects[<path>].hasTrustDialogAccepted = truein~/.claude.json(honoursCLAUDE_CONFIG_DIR). This is the documented way to trust a folder. The key is the git repo root when inside a repo, otherwise the directory itself, which matches how Claude Code keys trust. The write is atomic and keeps the file mode. It does nothing if the folder is already trusted, and leaves a missing or malformed file untouched. SetCCBOT_AUTO_TRUST_DIRS=falseto turn it off.TrustDialogUI pattern andTmuxManager.auto_answer_dialog()move the❯cursor onto "Yes, I trust", capture the pane again to check it landed there, then press Enter. It never types a digit, because the option order changed between versions and a blind1/Enter now exits._create_and_bind_windownow waits for Claude's input box (wait_for_claude_ready) before the hook wait and before forwarding the pending message. Status polling also answers the dialog in windows that already exist.About 170 lines of source plus tests. No behaviour change for directories that are already trusted, apart from the short ready wait.
Testing
tmux capture-panefixtures from Claude Code 2.1.272 (trust dialog, idle prompt in manual and bypass mode). They cover the ❯ cursor being told apart from the shell's❯ claudeecho, and the answer not being confirmed when the cursor didn't move.test_claude_config.pycovers the JSON edits (existing keys and file mode preserved, git-root key, missing and malformed files).claudein a fresh untrusted directory. The dialog was answered and the prompt was ready in about 3s.pytest: 274 passed;pyright: 0 errors.