Skip to content

feat(settings): Serialize the form description and pin it with fixtures - #729

Merged
omesser merged 1 commit into
mainfrom
feat/706-settings-snapshot
Sep 15, 2026
Merged

omesser merged 1 commit into
mainfrom
feat/706-settings-snapshot

Conversation

@omesser

@omesser omesser commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

Step 2 of #706. The form description crosses to JavaScript as JSON, and two committed fixtures pin it.

  • Serialize on FormDescription, FormTab, FormSection, FormRow, CompositeControl, Shortcut, RowOperation, and on SettingsView with InstanceRow, ConsentRow, CapabilityId, BoolField, TextField.
  • FormRow and CompositeControl both get #[serde(tag = "type")], so a JS switch (row.type) works and a composite's controls read the same way.
  • One command, settings_snapshot, registered in generate_handler!. It answers { form, view }: the description says a checkbox writes DirectorEnabled, the view says whether it is on, and a row needs both to render.
  • tests/fixtures/settings-snapshot-modelApi.json and tests/fixtures/settings-snapshot-harnessDriving.json, compared by both_ai_sources_serialize_to_the_committed_fixtures. The test compares and never writes. On a mismatch it dumps what the form produces now to the temp directory and names the file, so the fix is diff and commit, never a silent refresh.

Fixtures live at the repo root rather than under src-tauri/tests/ as the plan wrote, so cargo test and node --test read one location. Step 3 renders these same two paths.

What the plan flagged, and what was actually there

The plan said to stop and reconsider if live process state made the fixture non-deterministic. It does, and in more places than the plan named. The census:

What Kind Now
harness::driving() process global a Live field
harness::attached() process global a Live field
consent::pane_intro(&consent::process_listed_as()) the responsible parent process, so it differs per machine, not just per OS a Live field
the eight Director and Development variables env already cleared by model::tests::with_env
FormRow::Checkbox { id: CAPTURABLE_ID, .. } #[cfg(any(macos, windows))] unchanged
the two consent rows #[cfg(not(linux))] unchanged

So describe() now reads the first three into a Live value and hands it to describe_with(&Live). describe() keeps its signature and every existing caller and test is untouched. This is the test-only deterministic view the task asked to be named plainly, except that it is not test-only: it is three reads moved out of a data builder and into its caller, which is where they belonged.

The last two rows of that table are compile-time, and no parameter fixes them. Linux builds the Presence and Privacy tabs deliberately smaller: no capture-exclusion row, and no consent rows because there is nothing to grant (#250). So the committed fixtures hold the full five-tab macOS form, and the test pins all five tabs on macOS and Windows, and three on Linux — AI, Character and Development, which is where form churn lands. UNPINNED_TABS in the test is the one place that says so.

The view is not in the fixture

SettingsView serializes, so settings_snapshot carries it, but no fixture holds it. It is a home directory, the Characters this machine has installed, and the Instances running right now. Nothing can pin that. The fixtures pin the shape; the values are the machine's.

One thing worth a reviewer's eye: SettingsView::byo_token is a real token, and the snapshot hands it to the webview. That is what #599 already does through the native window's clipboard button, so it is not new, but it is the one credential-shaped field crossing this boundary. api_key_* carries a fingerprint and a bool, never the key.

Verification

cargo test from src-tauri/, macOS:

test settings::form::tests::both_ai_sources_serialize_to_the_committed_fixtures ... ok
test result: ok. 465 passed; 0 failed; 4 ignored; 0 measured; 0 filtered out; finished in 3.04s

cargo clippy --all-targets -- -D warnings: clean.

The fixture test fails on drift. Changing one label in form.rs from Ambient session wakes to Ambient session wakes!:

test settings::form::tests::both_ai_sources_serialize_to_the_committed_fixtures ... FAILED

thread '...' panicked at src-tauri/src/settings/form.rs:1644:21:
tests/fixtures/settings-snapshot-modelApi.json no longer matches form::describe_with. What the
form produces now is at /var/folders/.../T/settings-snapshot-modelApi.json; diff it, and commit
it with the change that moved it.

and the diff it points at:

191c191
<   "label": "Ambient session wakes",
---
>   "label": "Ambient session wakes!",

Reverted after.

All three CI legs ran this branch before the pull request was opened, via gh workflow run "PR Tests" --ref: https://github.com/omesser/ai-buddy/actions/runs/34997456502. Windows and Linux green first time, which is the evidence that mattered — it is the Windows leg that proves the fixture is byte-stable off this machine, and the Linux leg that proves the three-tab compromise holds. macOS failed once on pwsh aborting inside the PSScriptAnalyzer hook, on files this branch does not touch, and was green on rerun.

Notes for Step 3

  • The two fixture paths are the interface. They are pretty-printed with a trailing newline and the operations map is sorted on the way out, because HashMap serializes in hash order and the files are compared.
  • All nine FormRow variants appear in both fixtures, and all three CompositeControl variants.
  • Shortcut crosses as {"row": "director_base_url"} alone. Its value is a function pointer, which is not data.
  • Nothing here opens a window, renders anything, or touches src-tauri/src/platform/.

Closes nothing. Step 3 consumes it.

🤖 Generated with Claude Code

— Claude Code agent, on @omesser's behalf.

Step 2 of #706. The description crosses to JavaScript as JSON, and two
committed fixtures are what Step 3's page renders.

`describe` read three things from the running process that no fixture can
hold: `harness::driving`, `harness::attached`, and a consent intro naming
the responsible parent. They move into a `Live` value that `describe_with`
takes, so a test can choose them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omesser

omesser commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

Correction: the Windows leg had not run this PR's tests until now

The PR description credits the Windows CI leg with proving the fixture is byte-stable off a Mac, on all five tabs. That was not true when written, and it is worth correcting rather than quietly relabelling.

The windows job in .github/workflows/tests.yml runs clippy unconditionally but gates cargo test behind a path list: platform.rs, platform/windows/**, secrets.rs, crates/core/src/sensing.rs, the manifests, and the workflow itself. This PR touches settings/form.rs, settings.rs, main.rs and tests/fixtures/, none of which is on that list, so the gate resolved to run tests: False and the green Windows check was clippy only.

Which mattered here more than usual. Byte-stability across three platforms is the entire claim of the fixture test, and Windows is the platform where #[cfg(any(macos, windows))] makes the form differ from Linux. The Linux leg pins three tabs; the five-tab pin had been verified on exactly one machine.

Fixed by adding the windows label, which forces the gate on. The re-run is 35004453026. The Rust tests step executed and passed, alongside clippy:

7. Clippy the workspace for Windows = success
8. Rust tests                       = success

So the claim now holds, on evidence rather than on the shape of a green check.

checks (macos-latest) and checks (ubuntu-latest) were never affected. Both gate tests on a broad code == 'true', so they ran cargo test all along.

For anyone landing Steps 3 through 9. A Settings change is platform-free code that lives outside the Windows path list, so its Windows leg is lint-only by default. Add the windows label to any PR in this sequence whose correctness you want tested there. #731 has been relabelled for the same reason.

— Claude Code agent, on @omesser's behalf.

@omesser
omesser merged commit a2dab85 into main Sep 15, 2026
13 of 14 checks passed
omesser added a commit that referenced this pull request Sep 15, 2026
Generated from `describe_with`, not written by hand. The snapshot pair is
byte-identical to #729's, so that PR's file lands over this one unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
omesser added a commit that referenced this pull request Sep 15, 2026
Generated from `describe_with`, not written by hand. The snapshot pair is
byte-identical to #729's, so that PR's file lands over this one unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

windows Run the Windows compile job on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant