Skip to content

feat: add write-directories settings with native picker - #150

Merged
panghy merged 3 commits into
mainfrom
panghy/end-21-write-dirs-setting
Aug 11, 2026
Merged

feat: add write-directories settings with native picker#150
panghy merged 3 commits into
mainfrom
panghy/end-21-write-dirs-setting

Conversation

@panghy

@panghy panghy commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a "Write directories" setting to the desktop app so users can manage the relay sandbox's write_dirs allowlist from the UI, with a native folder picker.

User-visible behavior:

  • New settings section listing the directories that sandbox writeFile calls are allowed to write into.
  • "Add directory" opens the native OS folder picker (Tauri dialog); the chosen directory is added as an absolute path. Entries can be removed individually.
  • The list is persisted to the relay config's write_dirs array, so the relay picks it up as its write allowlist. An empty list means sandbox writes stay disabled (opt-in only).

Safety / UI behavior

  • Directories are always absolute paths chosen via the native picker — no free-text path entry, reducing typo/traversal risk.
  • The desktop UI only edits the allowlist; enforcement (canonical-prefix checks, per-run limits) lives in the relay.

Linear

END-21 — add writeFile so tool media can reach the filesystem.

Commits

  • feat: add write directories setting with native folder picker
  • chore: sync pnpm-lock.yaml with declared @tanstack/svelte-virtual dependency

panghy added 2 commits August 11, 2026 13:17
Adds get_write_dirs/set_write_dirs Tauri commands that manage the
[relay] write_dirs array in ~/.endara/config.toml, preserving sibling
keys and de-duplicating entries, plus a Settings 'Write directories'
section with list/remove and a native directory picker. Changes are
persisted then pushed to the running relay via reloadConfig().
Copilot AI lite review requested due to automatic review settings August 11, 2026 05:49

@panghy panghy left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with focus on config persistence, path handling, Svelte/TS quality, test coverage, and indentation. Verdict: APPROVED — no blocking issues. (Posted as a comment review because GitHub does not allow approving one's own PR; the reviewing agent shares the author's credentials.)

Verification run locally on the branch:

  • pnpm vitest run src/lib/components/Settings.test.ts → 47/47 pass
  • cargo test write_dirs_tests → 9/9 pass
  • cargo fmt --check → clean
  • pnpm check (svelte-check) → 0 errors (1 pre-existing unrelated node types warning)

What I verified:

  • Persistence: set_write_dirs preserves unrelated [desktop]/[relay]/[[endpoints]] content (covered by set_write_dirs_preserves_other_fields), creates a missing [relay] section with a machine_name so the relay's RelayConfig deserialization won't break, and the key relay.write_dirs matches the relay's Config field exactly.
  • Duplicates: deduped in both layers — frontend no-op in addWriteDir, first-seen-order dedup in set_write_dirs — with tests on both sides.
  • Absolute paths: input is picker-only (no free-text), and the relay independently validates/canonicalizes; see inline note.
  • Patterns/conventions: writeDirsUi.ts mirrors toonOutputUi.ts (Tauri read path avoids the relay-socket race; optimistic write + revert), the test module mirrors toon_output_tests (HomeGuard + #[serial]), and 2-space indentation is respected in the Svelte/TS changes (Rust stays on rustfmt formatting, gated by cargo fmt --check).
  • Lockfile commit (db632b8): only syncs the already-declared @tanstack/svelte-virtual dependency into pnpm-lock.yaml; no version changes to anything else.

Three non-blocking inline notes below.

Comment thread src/lib/writeDirsUi.ts
Comment thread src/lib/writeDirsUi.ts
Comment thread src-tauri/src/lib.rs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Write directories” setting to the desktop app, letting users manage the relay sandbox write_dirs allowlist from Settings via a native folder picker, persisted to ~/.endara/config.toml and applied to the running relay via config reload.

Changes:

  • Added UI/store helpers to fetch/persist write_dirs through Tauri commands and trigger relay config reloads.
  • Updated Settings UI to display/manage the allowlist and open the native folder picker.
  • Added/registered new Tauri commands to read/write relay.write_dirs and added Rust/UI unit tests; updated pnpm-lock.yaml.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/writeDirsUi.ts New UI helper module to fetch/persist write_dirs via Tauri + reload relay config
src/lib/stores.ts Adds writeDirs Svelte store for the allowlist
src/lib/components/Settings.test.ts Adds helper-level unit tests for write dirs UI logic
src/lib/components/Settings.svelte Adds “Write directories” section and native folder picker integration
src-tauri/src/lib.rs Adds get_write_dirs/set_write_dirs commands, config read/write helpers, and Rust tests
pnpm-lock.yaml Lockfile sync for declared dependencies
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/writeDirsUi.ts
Comment thread src-tauri/src/lib.rs
Comment thread src-tauri/src/lib.rs
Address PR review feedback: fail fast at the Tauri boundary when a
write_dirs entry is empty or relative instead of persisting a value the
relay would later reject, and de-duplicate read_write_dirs output
(first-seen order) so hand-edited duplicate entries cannot produce
duplicate keys in the UI's keyed each-list.
Copilot AI review requested due to automatic review settings August 11, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@panghy
panghy added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit 4930524 Aug 11, 2026
10 checks passed
@panghy
panghy deleted the panghy/end-21-write-dirs-setting branch August 11, 2026 06:09
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.

2 participants