Skip to content

fix(snapshot): print the value of labeled non-editable nodes - #5422

Merged
thymikee merged 2 commits into
callstack:mainfrom
pcbeingused33:fix/snapshot-labeled-value
Dec 6, 2026
Merged

thymikee merged 2 commits into
callstack:mainfrom
pcbeingused33:fix/snapshot-labeled-value

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5418

Summary

displayLabel prints a node's label and drops its value unless the role is text-field, text-view or search. For adjustable controls, such as Flutter sliders and picker wheels exposed as Other, the value holds the state, so snapshot never shows it. Settle diffs and diff snapshot key 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 text still returns the label; that is left out of scope.

Before / after

Node { type: 'Other', label: 'Brightness', value: '60%' }, then value: '96%':

snapshot        before: @e3 [other] "Brightness"
                after:  @e3 [other] "Brightness" [value:"60%"]
diff 60% -> 96% before: +0 -0
                after:  +1 -1  (- … [value:"60%"]  + … [value:"96%"])

Validation

  • Tested at 7e499c3. New snapshot-lines-value.test.ts covers 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. On main, 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.ts passes (558 tests). oxlint, oxfmt and tsc --noEmit are clean.
  • No device run. The change only affects how snapshot text is rendered and how the diff key is built.

This change was prepared with AI assistance.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

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>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) ?? '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>
Suggested change
const valuePart = valueMarker(node, role) ?? '';
const valuePart = valueMarker(node, role) ? JSON.stringify(node.value ?? '') : '';

@thymikee

thymikee commented Dec 5, 2026

Copy link
Copy Markdown
Member

Thanks for the fix.

At 7e499c3 the change leaks the value of secure fields, so it needs one more fix before merge. valueMarker skips nodes with isEditableRole(type), and that only matches the display roles text-field, text-view and search. An iOS SecureTextField becomes securetextfield, which is not in ROLE_LABELS, so it counts as non-editable. displayLabel then prints its label and drops its value, and valueMarker appends [value:"…"]. It never reads node.password, which interpretIosNode already sets for SecureTextField (ios-node-interpretation.ts:18), and the Android and WebDriver producers set it on nodes whose type may not map to a text-field role. Example: {type:'SecureTextField', label:'Password', value:'••••••••', password:true} now prints [securetextfield] "Password" [value:"••••••••"]. This is new output on the default snapshot text, the settle diff and the candidate lines. The diff key carries the value too, so every keystroke into a secure field makes a changed pair. On iOS the value is masked bullets, so the confirmed leak is the secret's length plus a diff line per keystroke. A producer that sends unmasked text for a password-flagged node would print it verbatim. The rule should be: print the value only when nothing else in the line already carries it. So skip any node with password === true or editable === true, and treat securetextfield as editable. Please make isEditableRole the one predicate for both displayLabel and valueMarker, so they cannot drift. The new tests only cover TextField, so please add a regression with a labeled SecureTextField and a password:true node under a non-field role. Both must render without [value:].

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 [checked] [value:"1"] on switches (#5422 (comment)). The switch thread needs the same skip-when-something-else-prints-it rule as above. The diff-key thread does not apply, so it can be resolved: the diff key deliberately matches what the rendered line prints, and both use the 48-character preview (#5422 (comment)).

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 snapshot run on a device, the value a real iOS SecureTextField or Android password node reports, and whether any producer sends unmasked text for a password-flagged node. The bullet case follows from XCUITest masking and the masked-text handling in platform-android/src/fill-diagnostics.ts. Also not verified here: which real node types besides sliders, pickers and switches carry a non-empty value, and how many tokens and diff lines this adds to a full snapshot. The no-leak invariant was checked by reading the code only.

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>
@pcbeingused33

Copy link
Copy Markdown
Contributor Author

Thanks. Pushed a commit on top of 7e499c3:

  • isEditableRole(node, type) is now the one predicate for displayLabel, valueMarker and the editable/placeholder metadata. It matches the three field roles, securetextfield, editable === true and password === true. valueMarker skips these nodes. It also skips any node with checked set, since the line already prints its state.
  • One addition beyond what you asked for: once a secure field counts as editable, displayLabel's value-first branch would print •••••••• in place of "Password", which is the same length leak. So for password === true it uses the label. As a result, a labeled Android password EditText now shows its label instead of its masked text.
  • Unchanged from main: a secure field with no label still falls back to its value in displayLabel, as it did before this PR. I left that alone, since showing nothing would hide whether the field is filled. Happy to change it here if you prefer.
  • New tests: a labeled SecureTextField and a password: true node under a non-field role. Each renders without its value in both modes, and a keystroke into either diffs as unchanged. Also added a labeled switch with value: "1", and a long value with quotes and backslashes whose escaped, truncated marker is checked exactly. Against 7e499c3, 3 of these fail. With the fix, all 12 in the file pass. The capture-kit/src/snapshot and command-output snapshot suites pass (562 tests). tsc --noEmit and oxlint are clean.
  • Not verified: a live device run.

Leaving the diff-key thread as you described. The new push runs Body rules again (it triggers on synchronize).

This comment was drafted with Claude Code.

@thymikee

thymikee commented Dec 6, 2026

Copy link
Copy Markdown
Member

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.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 6, 2026
@thymikee
thymikee merged commit 1d5d2e5 into callstack:main Dec 6, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text snapshot drops the value of labeled non-editable nodes, so sliders and picker wheels print without their state

2 participants