Repository navigation
feat(settings): Serialize the form description and pin it with fixtures - #729
Conversation
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>
Correction: the Windows leg had not run this PR's tests until nowThe 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 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 Fixed by adding the So the claim now holds, on evidence rather than on the shape of a green check.
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 — Claude Code agent, on @omesser's behalf. |
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>
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>
Step 2 of #706. The form description crosses to JavaScript as JSON, and two committed fixtures pin it.
SerializeonFormDescription,FormTab,FormSection,FormRow,CompositeControl,Shortcut,RowOperation, and onSettingsViewwithInstanceRow,ConsentRow,CapabilityId,BoolField,TextField.FormRowandCompositeControlboth get#[serde(tag = "type")], so a JSswitch (row.type)works and a composite's controls read the same way.settings_snapshot, registered ingenerate_handler!. It answers{ form, view }: the description says a checkbox writesDirectorEnabled, the view says whether it is on, and a row needs both to render.tests/fixtures/settings-snapshot-modelApi.jsonandtests/fixtures/settings-snapshot-harnessDriving.json, compared byboth_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 isdiffand commit, never a silent refresh.Fixtures live at the repo root rather than under
src-tauri/tests/as the plan wrote, socargo testandnode --testread 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:
harness::driving()Livefieldharness::attached()Livefieldconsent::pane_intro(&consent::process_listed_as())Livefieldmodel::tests::with_envFormRow::Checkbox { id: CAPTURABLE_ID, .. }#[cfg(any(macos, windows))]#[cfg(not(linux))]So
describe()now reads the first three into aLivevalue and hands it todescribe_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_TABSin the test is the one place that says so.The view is not in the fixture
SettingsViewserializes, sosettings_snapshotcarries 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_tokenis 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 testfromsrc-tauri/, macOS:cargo clippy --all-targets -- -D warnings: clean.The fixture test fails on drift. Changing one label in
form.rsfromAmbient session wakestoAmbient session wakes!:and the diff it points at:
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 onpwshaborting inside the PSScriptAnalyzer hook, on files this branch does not touch, and was green on rerun.Notes for Step 3
operationsmap is sorted on the way out, becauseHashMapserializes in hash order and the files are compared.FormRowvariants appear in both fixtures, and all threeCompositeControlvariants.Shortcutcrosses as{"row": "director_base_url"}alone. Itsvalueis a function pointer, which is not data.src-tauri/src/platform/.Closes nothing. Step 3 consumes it.
🤖 Generated with Claude Code
— Claude Code agent, on @omesser's behalf.