Repository navigation
Trust /data/uploads so Claude stops asking at every start (2.5.9) - #91
Conversation
5f4f15b to
438728e
Compare
ESJavadex
left a comment
There was a problem hiding this comment.
Thanks, Neil, for tracking this down and testing it on an actual Home Assistant install. Scoping the trust record to the upload directory is helpful.
Could we write the updated config to a temporary file beside the original and rename it into place once the write succeeds? The current redirection can truncate the whole Claude config if the write fails partway through. Could we also preserve an explicitly stored hasTrustDialogAccepted: false? That keeps an existing trust choice meaningful. Please cover both cases in the regression tests.
#93 uses 2.5.8 for the OAuth notification fix and the scheduled build failure. This patch can take the next version after rebasing on main.
Record projects["/data/uploads"].hasTrustDialogAccepted in ~/.claude.json at start-up. The update is written to a copy beside the file and renamed into place, so a failed write can't cut the file short; an explicit false is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
438728e to
6653462
Compare
|
Thanks, Javier, both done, and rebased on main as 2.5.9.
New regression tests cover both: an explicit false is left byte for byte, and a write that fails partway (a stub that writes a cut-off file and then fails) leaves the original whole with no temporary copy behind. There's also one for the symlink case. I've also retested both on my Home Assistant; the PR description's Tested section has the details. One thing I noticed while testing: a Claude that's already running can write its own copy of |
ESJavadex
left a comment
There was a problem hiding this comment.
Thanks for the fix and for testing it on Home Assistant, Neil. I verified that the trust entry is limited to /data/uploads and that an explicit refusal is preserved. I tightened the config reader to require a single JSON object, with regression coverage for whitespace, null and multiple documents. The updated tests pass in the lab container.
Fixes #90.
Problem
From Claude Code 2.1.327, every new Claude session in the add-on stops at "Adding a new directory: /data/uploads ... Is this a directory you created or one you trust?". The add-on starts Claude with
--add-dir /data/uploads(from the first window and the session picker), and Claude now asks about each added folder that has no trust record. The answer holds only for that session, so it comes back at every start.Fix
A new start-up step,
trust_upload_dirinrun.sh(aftersetup_statusline), records the folder in~/.claude.json(/data/home/.claude.json):That's the record Claude writes when its trust prompt is accepted, and the one Claude checks before asking: the folder or one above it must have it. Claude's own error messages also suggest setting it by hand.
/data/uploads. Not/data, which would also cover/data/homeand the login.cp -pof it (so it keeps the owner and permissions), and is renamed into place only once it is written. If any step fails, the copy is removed and the original is left as it was. A new file is created with mode 600, and a symlinked file stays a symlink.hasTrustDialogAccepted: falseis kept. That is a choice made in Claude, so the step leaves it and logs that the folder stays untrusted..claudesettings folder can appear in/data/uploads.DOCS ("Giving Claude Files"), CLAUDE.md (start-up steps) and the CHANGELOG describe it. Version 2.5.9.
Tests
test-production-run.sh:~/.claude.jsonis created with the entry, mode 600;/data/uploadsis added;hasTrustDialogAccepted: falseis left exactly as it was;~/.claude.jsonstays a symlink, and the file it points to gets the entry;main()runs the step.tests/run-tests.shand shellcheck pass.Tested
On my Home Assistant (as a separate dev add-on, Claude Code 2.1.327):
After the review changes (2.5.9, Claude Code 2.1.330):
hasTrustDialogAccepted: false, a restart logs that the folder stays untrusted, the file still saysfalse, and Claude asks the trust question.🤖 Generated with Claude Code