Repository navigation
fix(snapshot): print the value of labeled non-editable nodes - #5422
Conversation
A labeled node prints its label and drops its value unless its role is editable, so a slider's percentage or a picker wheel's selection never reaches the text snapshot, and a value-only change diffs as +0 -0. Emit [value:"…"] when the value differs from the label, and key the diff on the same marker. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/capture-kit/src/snapshot/snapshot-diff.ts">
<violation number="1" location="packages/capture-kit/src/snapshot/snapshot-diff.ts:35">
P2: `snapshot diff` still misses value-only changes after the preview cutoff. Include the full value in the comparable key while retaining the capped marker for display.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| // The states the rendered line prints are the states the key compares, from one function, so a | ||
| // fact the diff weighs is always visible in the line it prints. | ||
| const statePart = stateMarkers(node).join(','); | ||
| const valuePart = valueMarker(node, role) ?? ''; |
There was a problem hiding this comment.
P2: snapshot diff still misses value-only changes after the preview cutoff. Include the full value in the comparable key while retaining the capped marker for display.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/capture-kit/src/snapshot/snapshot-diff.ts, line 35:
<comment>`snapshot diff` still misses value-only changes after the preview cutoff. Include the full value in the comparable key while retaining the capped marker for display.</comment>
<file context>
@@ -31,14 +32,15 @@ function snapshotNodeToComparableLine(node: SnapshotNode, depthOverride?: number
// The states the rendered line prints are the states the key compares, from one function, so a
// fact the diff weighs is always visible in the line it prints.
const statePart = stateMarkers(node).join(',');
+ const valuePart = valueMarker(node, role) ?? '';
const hittablePart = node.hittable === true ? 'hittable' : 'not-hittable';
const depthPart = String(depthOverride ?? node.depth ?? 0);
</file context>
| const valuePart = valueMarker(node, role) ?? ''; | |
| const valuePart = valueMarker(node, role) ? JSON.stringify(node.value ?? '') : ''; |
|
Thanks for the fix. At 7e499c3 the change leaks the value of secure fields, so it needs one more fix before merge. Of the other open threads, the two high-priority ones still apply: the test-strength note on long and quoted values (#5422 (comment)) and the redundant The two non-passing checks are Body rules, and both show as cancelled, not failed. The gate only reads the PR title and body, and this diff touches only capture-kit snapshot presentation, so a superseded run is the likely cause. Please re-run it to confirm. The 17 other checks are green. Not verified here: a live Once the secure-field rule and its test are in, nothing else stops this from merging. |
valueMarker skipped only the text-field, text-view and search display roles, so an iOS SecureTextField (role securetextfield) or any node the producer flags password:true printed [value:"…"], leaking the secret's masked length and a diff line per keystroke. Make isEditableRole the one predicate for displayLabel and valueMarker, and have it cover securetextfield and the editable/password facts. displayLabel prints a secure field's label instead of its value. A checkable control already prints its state, so it gets no value marker either. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks. Pushed a commit on top of 7e499c3:
Leaving the diff-key thread as you described. The new push runs Body rules again (it triggers on This comment was drafted with Claude Code. |
|
Thanks for the update. The secure-field problem from the earlier review (#5422 (comment)) is fixed at d2cba62, and the code looks good to merge. Checks show 16 of 16 passing at this commit, and there are no conflicts. Nothing else must happen before merge. Not verified here: a live device run, and which value a real iOS SecureTextField or Android password node reports. The change only renders text and builds a diff key, and the tests call the same formatSnapshotLine and buildSnapshotDiff the surfaces use. Of the open inline threads, the escaped and truncated marker test (#5422 (comment)) and the checked-node skip (#5422 (comment)) are fixed at this commit and can be resolved. The diff-key thread (#5422 (comment)) does not apply: the key uses the same 48-character marker the rendered line prints, and base missed every value change, so nothing regresses. It can be resolved too. |
Fixes #5418
Summary
displayLabelprints a node's label and drops itsvalueunless the role istext-field,text-vieworsearch. For adjustable controls, such as Flutter sliders and picker wheels exposed asOther, the value holds the state, sosnapshotnever shows it. Settle diffs anddiff snapshotkey on the same label, so moving a slider diffs as+0 -0.A labeled, non-editable node now gets a
[value:"…"]marker when its value differs from its label. The marker uses the same escaping and 48-character preview as[preview:…]. The diff key reuses the marker, so a value-only change shows as a removed/added pair. Editable and unlabeled nodes are unchanged because they already print the value as their text.get textstill returns the label; that is left out of scope.Before / after
Node
{ type: 'Other', label: 'Brightness', value: '60%' }, thenvalue: '96%':Validation
7e499c3. Newsnapshot-lines-value.test.tscovers the marker in both render modes, the cases where no marker should appear (no value, value equal to label, unlabeled, editable), and value-only diffs. Onmain, 3 of its 8 tests fail. With the fix, all 8 pass.vitest run packages/capture-kit/src/snapshot packages/command-output/src/output/snapshot.test.tspasses (558 tests). oxlint, oxfmt andtsc --noEmitare clean.This change was prepared with AI assistance.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.