Skip to content

feat(nix): merge the chosen T3 settings at activation - #496

Merged
furedea merged 3 commits into
mainfrom
feat/manage-t3-settings
Nov 23, 2026
Merged

furedea merged 3 commits into
mainfrom
feat/manage-t3-settings

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

概要

  • 利用者が選んだ T3 Code の設定を,home-manager の activation(t3Settings)で ~/.t3/userdata/ の JSON に merge する.選んだ key だけを書き,ほかの key はそのまま残す.ファイルは jq で作った一時ファイルを mv で置き換える(atomic).symlink にはしない(T3 が UI から書き込むため).
  • server の settings.json と desktop-settings.json は enableT3Service の host(mbp)だけ.keybindings.json と画面側の client-settings.json は mbp・mba の両方.
  • UI で管理対象の key を変えると,次の switch で下の値に戻る.管理対象でない key は UI で自由に変えてよい.
  • ADR-0046(proposed):UI が書く vendor app の JSON を merge で管理する判断.

Refs #489(plan:#489 (comment) の step 5)

管理する key

ファイル(~/.t3/userdata/) host key と値
keybindings.json(rule の配列) mbp,mba {"key":"ctrl+c","command":"thread.stop","when":"turnRunning && !terminalFocus"} をちょうど 1 つ.ほかの thread.stop rule は消し,それ以外の rule は残す
client-settings.json(desktop app の画面側) mbp,mba notificationMode: "notifications-and-sound",inAppNotificationsEnabled: true,confirmThreadUnpin・confirmThreadArchive・confirmThreadDelete: true,confirmQuit: "double-click",language: "ja",threadDetailsItems: {openIn: false, scripts: false, servers: false, automations: false, usage: true, context: true},fontFamilyCode: "JetBrains Mono",mathRenderingEnabled: true,composerRichTextEnabled: false,diffLayout: "split",browserAutoShowFloatingPreview: false
settings.json(server) mbp enableAgentBrowserAccess: false,defaultAutoPull: true,defaultModelSelection: {instanceId: "claudeAgent", model: "claude-opus-5-5", options: [{id: "effort", value: "medium"}]},fallbackModelSelection: {instanceId: "codex", model: "gpt-6.2-sol", options: [{id: "reasoningEffort", value: "medium"}]},defaultRuntimeMode: "auto",snoozeLimitedThreads: true,autoResumeLimitedThreads: true,addProjectBaseDirectory: "~/ghq",ghqCloneLayout: true,removeAgentCreditsOnMerge: true,pullRequestMergeMethod: "squash",storageCleanup: {worktreeOnMerge: true, worktreeOnDelete: true}
desktop-settings.json mbp localEnvironmentEnabled: false
  • merge は深い merge(jq の *).storageCleanup や threadDetailsItems の中の,選んでいない key(worktreeOnArchive,branch など)は残る.配列(options)は置き換える.
  • effort の field は options の {id, value}(T3 0.1.10 の ModelSelection).id は provider ごとに違い,Claude は effort,Codex は reasoningEffort.どちらの model も既定は medium で,今の settings.json には書かれていないが,既定が変わっても medium に固定するため明示した(server は既定と同じ値を次の保存で省くことがある.意味は変わらない).
  • language の値は ja(T3 の言語一覧 {en, de, es, fr, ja, ko, pt-BR, ru, zh}).
  • 既存ファイルの mode はそのまま保つ.新しく作るファイルは本人だけが読める 0600 にする.
  • ファイルがないときは管理する key だけで作る.parse できないファイル(壊れた JSON や想定外の型)は変えずに warning を出し,switch の残りは続ける.

管理しないもの

対象 理由
Theme(Iris) desktop app の Local Storage(t3code:theme,~/Library/Application Support/t3code-v2/Local Storage)にあり,ファイルの merge では安全に書けない.UI で選ぶ
browser から開いた T3 の画面側の設定 browser の Local Storage(t3code:client-settings:v1)にある.desktop app だけが client-settings.json を使う
providerInstances,project,thread(statev2.sqlite),pairing,secrets/,clerk/,Tailscale Serve brief の範囲外.credential や state を含む
選んでいない設定(font size,separate fonts など) 既定のままか,UI で自由に変える

調査結果(T3 0.1.10 の source map と mbp のファイルを読んで確認)

項目 結果
画面側の設定の保存先 desktop app は Local environment の有無に関係なく <T3CODE_HOME>/userdata/client-settings.json(DesktopEnvironment.clientSettingsPath)に保存する.browser は Local Storage
mbp の client-settings.json が古い理由 mbp の desktop app は 15:36 以降動いていない(desktop.trace.ndjson と t3code-v2 の最終更新が 15:36).UI での変更は別の client(mba の desktop か browser)で行われ,その client 側に保存されたと考えられる.server 側の値は 22:27 に settings.json へ届いている
再読み込み server は settings.json と keybindings.json を監視していて,変われば読み直す.desktop app は client-settings.json と desktop-settings.json を起動時に読み,設定を変えるたびにメモリ上の全体を書き戻す
keybindings の既定 server は既定の rule を自分で補う(同じ command がすでにあれば足さない).thread.stop の既定 rule はないので,ファイルが rule 1 つだけでも既定は失われない

利用者の手順

注意: desktop app はメモリ上の設定で client-settings.json を上書きする.switch の前に desktop app を終了するか,switch のあと設定を触る前に開き直す.

  1. この PR を merge する
  2. mbp:動いている lane がないとき,T3 desktop app を終了してから sudo darwin-rebuild switch --flake "$HOME/ghq/github.com/furedea/dotfiles/#mbp"
  3. mbp:desktop app を開き,いくつか確かめる(言語が日本語,Diffs が split,Ctrl+C で実行中の turn が止まる,新しい thread の model が Opus 5.5 / Medium)
  4. Theme は UI で Iris を選ぶ(管理外)
  5. mba:git pull して,desktop app を終了してから sudo darwin-rebuild switch --flake "$HOME/ghq/github.com/furedea/dotfiles/#mba",開き直して同じく確かめる(server 側の値は mbp の server から来る)

検証

  • Red:nix build .#checks.aarch64-darwin.t3-settings-merge が attribute 't3Settings' missing で失敗(module 追加前)
  • Green:同じ check が通る.各 host の実際の activation を fixture の HOME で実行し,次を確かめる
    • mbp:他の key(providerInstances,idleCompaction,fontSizeCode,storageCleanup.worktreeOnArchive,threadDetailsItems.branch)を残し,管理する key を決めた値にする.文書全体を期待値と比べる
    • thread.stop rule がちょうど 1 つ(escape の thread.stop は消え,mod+b の rule は残る)
    • なかった desktop-settings.json を管理する key だけで作る
    • symlink だった keybindings.json は通常ファイルになり,link 先は変わらない
    • 2 回目の実行でファイルが変わらない(冪等)
    • 0600 の settings.json は 0600 のまま,新しい desktop-settings.json は 0600(review 指摘への対応.旧実装の chmod 0644 でこの検証が失敗することを確認)
    • mba:settings.json は 1 byte も変わらず,desktop-settings.json は作られない.壊れた client-settings.json は変えず,そのあとの keybindings.json は作られる
  • 変異:merge を浅い merge(+)に変えると check が失敗することを確認して戻した
  • nix flake check:all checks passed(aarch64-darwin)
  • pre-commit(shellcheck,shfmt,nixfmt,statix,deadnix,dprint ほか):通過
  • 未実施:実機の ~/.t3 への適用(brief で禁止.利用者の手順 2〜5 で確かめる).実ファイルのコピーに activation を当てる試行は権限で許可されなかった

Review

  • claude-review P2:chmod 0644 で mode が広がる → 修正(5cc64b2).返信して thread を resolve
  • codex-review:指摘なし

plan との差

  • なし.Theme は plan どおり「ファイルにないので管理外」として報告する

🤖 Generated with Claude Code

furedea and others added 2 commits November 22, 2026 22:47
T3 Code rewrites its settings files from the UI, so a Home Manager
activation merges only the chosen keys into them with jq and replaces
each file atomically: keybindings and client settings on both hosts,
server settings and localEnvironmentEnabled only where the T3 server
runs. A file that does not parse stays unchanged.

Refs #489

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 22, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T13:56:10.941135Z 5cc64b2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread scripts/t3/merge_settings.sh Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Blocking findings (P0/P1): 0

The merge design looks correct to me. The deep merge with *, the single thread.stop rule, the atomic temp-file-and-mv replacement, warning-only failure on files that can't be parsed, and adding server and desktop settings only on enableT3Service hosts all work as intended. The t3-settings-merge check runs each host's real activation and covers preserving unmanaged keys, replacing the symlink, idempotence, and leaving a broken file unchanged on mba.

Findings

  • P2 scripts/t3/merge_settings.sh:50: chmod 0644 forces the rewritten files to be world-readable instead of keeping their original mode. This matters for settings.json, which keeps unmanaged providerInstances data.

No other correctness or security problems found. The race where the desktop app overwrites client-settings.json from memory is already documented in the PR's steps.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 5be5bace80

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Forcing 0644 made a file the user kept owner-only readable by others.
Keep an existing file's mode and leave new files owner-only.

Refs #489

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea

furedea commented Nov 22, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

Review summary (read-only)

I found no blocking or minor issues in this PR.

What I checked:

  • scripts/t3/merge_settings.sh:
    • The ! a | b || [[ ! -s ]] grouping is correct, and the temp file is removed whenever jq fails.
    • cp -p keeps an existing file's mode. A new file gets mktemp's 0600.
    • A symlink, or a symlink whose target is missing, becomes a regular file and the link target is never touched.
    • A file that doesn't parse, or has an unexpected shape (for example an object where the rule array should be), fails inside jq and is left unchanged.
  • nix/home/t3_settings.nix:
    • run … || echo keeps a failed merge from stopping the switch under set -e.
    • The filter and JSON are shell-escaped.
    • The server and desktop files are written only on the host with enableT3Service.
    • The step runs after writeBoundary, as other steps in this module do.
  • t3-settings-merge check: it runs the real activation for each host and covers the following:
    • deep merge that keeps unmanaged nested keys
    • dropping duplicate thread.stop rules
    • symlink replacement
    • mode preservation
    • a second run leaves the files unchanged
    • mba-only scoping
    • a broken file that doesn't stop the merges after it

Known behaviour, not a bug: the desktop app writes its in-memory settings back over the merged file. The ADR and the PR steps both document this.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5cc64b2245

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 2ad2e6b into main Nov 23, 2026
23 checks passed
@furedea
furedea deleted the feat/manage-t3-settings branch November 23, 2026 02:31
furedea-agent Bot pushed a commit that referenced this pull request Nov 23, 2026
ADR-0046 was taken by #496.

Refs #494

Co-Authored-By: Claude Opus 5.5 <[email protected]>
furedea added a commit that referenced this pull request Nov 23, 2026
T3 Code desktop app が Dock・Cmd+Tab・メニューバーで "Electron" と表示される問題を直す.macOS
は実行中バイナリを含む bundle の名前を表示するため,llm-agents の launcher が nixpkgs の
`Electron.app` 内のバイナリを exec すると Electron と表示される.dotfiles 側で T3 の bundle
を組み立て,その bundle 自身の Electron を起動する.

| 項目 | 変更前 | 変更後 |
| --- | --- | --- |
| `t3codeDesktopPackage` | llm-agents の `t3code-desktop` |
`nix/packages/t3code_desktop.nix` |
| 実行される Electron | nixpkgs の `Electron.app/Contents/MacOS/Electron` |
`T3 Code (Beta).app/Contents/MacOS/Electron`(同じ electron 44.9.3 のコピー) |
| `CFBundleName` / `CFBundleDisplayName` / アイコン | Electron / Electron /
`electron.icns`(実行時の表示) | `T3 Code (Beta)` / `T3 Code (Beta)` /
`t3code.icns` |
| `CFBundleIdentifier` | `com.github.Electron`(実行時) |
`org.nixos.t3code-desktop`(llm-agents の `org.nixos.T3 Code (Beta)`
は空白と括弧を含み Apple の規則に反するため変更) |
| 署名 | nixpkgs の Electron.app | 変更後の bundle を `codesign --force --deep
--sign -` で ad-hoc 再署名 |
| PATH と引数 | llm-agents の 2 段 wrapper | 同じ PATH(signed Codex を含む)と app
directory を 1 つの launcher に集約 |

- [x] Red:追加した check `t3-desktop-app-bundle` が既存 package
で失敗(`CFBundleDisplayName` なし)
- [x] Green:`nix build .#checks.aarch64-darwin.t3-desktop-app-bundle` が
pass
- [x] `plutil -p` で名前・identifier・アイコン・`CFBundleExecutable` を確認,`codesign
--verify --deep --strict` は valid on disk かつ Designated Requirement を満たす
- [x] launcher の PATH が llm-agents の desktop wrapper と一致し,dotfiles の
signed Codex(`codex-0.170.0`,ADR-0041)を含む
- [x] `nix flake check`:all checks passed.`nix build` で
`t3-desktop-app-bundle`,`t3-settings-merge`,`home-configuration`,`host-configuration`
も pass(#496 の merge 後の main に rebase した状態)
- [x] レビュー:claude-review の P2(identifier の文字種)を修正し,check
で文字種を検査.codex-review は指摘なし
- [ ] 起動確認:未実施.store path から起動すると稼働中の desktop app と single-instance lock
や `~/.t3` を共有する恐れがあるため,Dock 表示の確認は下の手順で利用者が行う

## 利用者の手順

1. この PR を merge する
2. mbp で lane が動いていないときに `darwin-rebuild switch` を実行する
3. T3 Code を開き直し,Dock と Cmd+Tab の名前とアイコンが T3 Code (Beta) になっていることを確認する
4. 通知の許可を求められたら再度許可する(identifier と署名が変わるため)
5. 問題なければ mba でも `darwin-rebuild switch` を実行して同じ確認をする

<details>
<summary>根拠と範囲</summary>

- 起動経路:`t3code.desktop/bin/t3code-desktop`(`--prefix
PATH`,`--inherit-argv0`)→
`t3code.unwrapped.desktop/bin/t3code-desktop`(`--add-flags
.../libexec/t3code/apps/desktop`)→
`electron-44.9.3/bin/electron`(`Electron.app/Contents/MacOS/Electron` を
exec).Darwin で設定される環境変数は PATH のみ
- Electron は llm-agents の nixpkgs input の `electron_44` を使う(dotfiles の
nixpkgs は 44.10.2 で異なる).store path が llm-agents の wrapper
のものと一致することを確認済み.check が Electron の version,PATH,app directory のずれを検出する
- helper は `Electron Helper*.app` の名前のまま残す
- `bin/t3code-desktop` は bundle 内の launcher への symlink として残す
- ADR-0047(`proposed`,#496 が 0046 を使ったため 0047):`.app` を dotfiles
で組み立てる判断.実機確認後に `accepted` にする
- 範囲外:llm-agents upstream,T3 の設定管理(#489 step 5),launchd
server(`t3codePackage` は変更なし),Moshi
-
plan:#494 (comment)
- 計画からの逸脱:なし

</details>

Refs #494

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant