fix(claude): adopt remoteControlAtStartup, fix settings.json reorder churn - #176
Merged
Conversation
Remote Control was toggled locally via Claude Code (writes settings.json directly, so the PostToolUse settings-sync hook doesn't catch it). Adopt it into the shared base so every machine starts with it enabled. Claude-Session: https://claude.ai/code/session_0147ZRxqvMYFFqS3unwTVYZs
Claude Code rewrites ~/.claude/settings.json in place and reorders keys as it does (e.g. moving a just-toggled key to the end), which made chezmoi status/diff show reorder-only noise on settings.json forever. modify_settings.json.tmpl now captures the target's current contents from stdin and, when the freshly rendered output is semantically equal (sorted-key comparison), returns the current contents verbatim instead of the rendered JSON. Real content changes still produce the rendered output — only key-order-only churn is suppressed. check-json-tmpl.sh's render_modify helper previously piped the rendered script into `sh`'s own stdin, which would have collided with the script now reading its stdin for the passthrough comparison. Fixed to execute the script from a file with a controllable stdin, and added regression tests for both the passthrough (reordered, same content) and non-passthrough (real content diff) cases. Claude-Session: https://claude.ai/code/session_0147ZRxqvMYFFqS3unwTVYZs
Pre-existing on main since 'update memo template' (ab4fa58) — the file ended with an extra blank line, which the end-of-file-fixer pre-commit hook flags on any --all-files run. Unrelated to this PR's settings.json work, but it made CI red on this branch too; fixing it here so pre-commit passes. Claude-Session: https://claude.ai/code/session_0147ZRxqvMYFFqS3unwTVYZs
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.
Summary
remoteControlAtStartup: trueをclaude-settings-base.jsonに取り込み。Remote Control をローカルで有効化した際settings.jsonへ直接書かれ、Write/Edit 経由でない書き込みなのでsettings-sync.shフックが拾えていなかった変更。modify_settings.json.tmplを stdin(現在のターゲット内容)対応にし、再レンダー結果と意味的に同一なら現在の内容をそのまま返すパススルーを追加。Claude Code が設定を書き戻すたびキー順を変える(トグルしたキーを末尾に移動)ため、これまでchezmoi status/diffが内容差ゼロでも永久にキー順ハンクを出し続けていた問題を根治。実際の内容差は引き続き検出される(sorted-key 比較)。scripts/check-json-tmpl.shのrender_modifyを修正: 従来はレンダーしたスクリプトをshの stdin にパイプして実行しており、これはスクリプト自身が stdin を読む今回の変更と衝突する。ファイル経由の実行に変更し、任意の stdin を注入できるようにした。あわせてパススルー(キー順のみ変化)/非パススルー(実内容差)の回帰テストを追加。Test plan
make lint(lint-jsonlint-tmpllint-merge-patchlint-brew-overlay)が全てグリーンchezmoi status --source <worktree> ~/.claudeが空になることを確認(従来はMM .claude/settings.json)diff <(chezmoi cat --source <worktree> ~/.claude/settings.json | jq -S .) <(jq -S . ~/.claude/settings.json)が空chezmoi catの出力キー順がライブファイルと一致する(stdin が実際に渡っていることの実証、remoteControlAtStartupが末尾に来る)scripts/check-json-tmpl.shに追加したパススルー/非パススルーのアサーションがパスhttps://claude.ai/code/session_0147ZRxqvMYFFqS3unwTVYZs