Conversation
useDirectoryTrust still carried its own path.resolve comparison in checkTrustSync and handleConfirmTrust, so the isDirectoryTrusted docstring's claim that every trust-gated entry point shares one resolution rule was false for the TUI. Both now call isDirectoryTrusted; only the write side stays local. Behaviour is unchanged. Also asserts persistence in daemon/cli.spec.ts through isDirectoryTrusted rather than an exact array match, and corrects the --trust-directory warning to name daemon start. Closes Nano-Collective#1339.
nc-review: comments — 1 important, 1 nit@addyCooks — a few things worth a look, none blocking. Routes the interactive trust check through the shared 🟠 important · There is no ⚪ nit · The pre-change code used 🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
Adds a spec for useDirectoryTrust asserting that the hook reports trust exactly as isDirectoryTrusted does, and that handleConfirmTrust persists the normalized directory only when it is not already trusted - including when the stored entry is an un-normalized equivalent. Verified the spec fails if an inline exact-match check is reintroduced on either the read or the write side.
Closes #1339
Description
isDirectoryTrustedis documented as shared by every trust-gated entry point (the TUI'suseDirectoryTrust,--plain'srunPlainShell, and the daemon boot path) so the resolution rule can't drift between them. That was true for--plainand the daemon but not the TUI:useDirectoryTruststill had its own inlinepath.resolve/trustedDirectories.some(...)comparison incheckTrustSyncandhandleConfirmTrust. Anyone hardeningisDirectoryTrustedcase-insensitive matching on Windows, realpath comparison against symlink tricks would have left the interactive path on the old rule.Changes:
source/hooks/useDirectoryTrust.tsx:checkTrustSyncandhandleConfirmTrustnow callisDirectoryTrusted.useDirectoryTrustis the only caller that also persists trust, so only the write side stays local. The docstring is now accurate as written. Behaviour is unchanged.source/daemon/cli.spec.ts(fix(security): gate daemon start on directory-trust disclaimer #1259 nit): the two persistence assertions checkisDirectoryTrusted(root, loadPreferences())instead oftrustedDirectories.includes(root), so they keep asserting "this directory is trusted" rather than one exact stored string if the rule is ever hardened.source/cli.tsx(fix(security): gate daemon start on directory-trust disclaimer #1259 nit): the--trust-directorywarning said it "only applies to non-interactive mode (nanocoder run ...)", stale sincedaemon startaccepts it too. It now names both.Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist