Skip to content

fix(mobile): keep tab ids, basenames, and hook agent text out of the cached tab strip - #19323

Closed
Jinwoo-H wants to merge 5 commits into
mainfrom
mobile/tab-strip-cache-scrub-ids
Closed

Jinwoo-H wants to merge 5 commits into
mainfrom
mobile/tab-strip-cache-scrub-ids

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​213 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​194
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​155 $\color{#cf222e}{\Huge{\mathbf{−}}}$​53 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102

Follow-up to #19281 from the post-merge adversarial review. Three privacy findings on the cached tab strip, all reproduced against main with failing-first tests.

Why

The cache's contract is that only the shape of the strip reaches plaintext AsyncStorage. Three wire-supplied fields still passed through:

  • HIGH: the tab id. The desktop builds an editor tab's id as editor:<worktreeId>:<runtimeKey>:<encodeURIComponent(filePath)> (buildOwnedEditorFileId) and publishes it unchanged when the file has no unified tab row. The cache copied it verbatim, so up to 12 workspaces × 24 tabs of worktree paths and absolute file paths persisted across launches. The same commit digested the workspace id for exactly this reason.
  • MEDIUM: file, markdown, and agent-session titles. Only terminal and browser titles were rewritten. An editor tab's title is its basename; an agent session's title is the task. Both name what the user was working on.
  • LOW: agentId. Any string was kept. Its source is the hook-reported agent type, free text on the wire and only length-normalized by the host, so ~40 characters of hook-controlled text per tab reached disk.

What

  • Every stored id is cached: + a 128-bit SHA-256 prefix of the wire id. The strip only needs the id as a React key and to mark the active row; both still work, and activeTabId is mapped through the same digest. A raw id written by an older build is digested on the way back out; an already-digested one is left alone. Live rows still replace preview rows wholesale, so there is no key continuity to lose.
  • getPersistableTabStripTitle is now an exhaustive switch over the tab type with a fixed label per type (Terminal/Agent or the agent's display name, Browser, Markdown, File). It no longer takes a title at all.
  • getPersistableTabStripAgentId keeps an agent id only when it is a key of TUI_AGENT_DISPLAY_NAMES; everything else becomes null and the title falls back to the generic label.

Tests

  • New: an editor id carrying a client path is never written and the row is titled File.
  • New: a raw id from an older build is digested on load, a digested one is stable, and the active id follows the digest.
  • New: known agent ids survive, hook text and unknown ids become null, and no title, basename, or agent-session task reaches the written blob.
  • Existing tests that asserted raw ids now assert the digest shape. All 7 new or changed cases fail against main's scrub.
  • tsc, full mobile vitest (4326), oxlint, oxfmt --check clean.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 66df80f3-bfb8-4406-9b5f-f29cf7a44906

📥 Commits

Reviewing files that changed from the base of the PR and between 736836b and cb2de35.

📒 Files selected for processing (2)
  • mobile/src/cache/session-tab-strip-cache.test.ts
  • mobile/src/cache/session-tab-strip-cache.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 61164243-3cca-40b7-b4c3-5ff70cf96ae4

📥 Commits

Reviewing files that changed from the base of the PR and between 9f057e3 and 736836b.

📒 Files selected for processing (2)
  • mobile/src/cache/session-tab-strip-cache.test.ts
  • mobile/src/cache/session-tab-strip-cache.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • mobile/src/cache/session-tab-strip-cache.ts
  • mobile/src/cache/session-tab-strip-cache.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The session tab strip now uses cached:-prefixed SHA-256 row keys. Live and preview rows share stable React keys. Cache v2 applies source-aware id and metadata redaction, migrates legacy raw ids, and removes v1 data asynchronously. Scrolling and layout tracking use row keys. Tests cover digestion, remapping, path redaction, metadata filtering, legacy cleanup, preview swaps, and route parity.

Merge Risk: ⚪ Minimal · up to 73683

Mobile tab-strip cache persistence now redacts sensitive identifiers and metadata while preserving cached-tab restoration. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the privacy issue, implementation, linked follow-up issue, and tests. However, it omits required template sections, including ELI5, Visual Proof with an explicit N/A if applic… Complete the required template sections. Add an ELI5 summary, provide before/after visual proof or state N/A with a reason, document AI use if applicable, complete the Agent skill upstream boundary and checklist items, and include the requi…
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: preventing sensitive tab IDs, basenames, and agent text from reaching the cached tab strip.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the privacy issue, implementation, linked follow-up issue, and tests. However, it omits required template sections, including ELI5, Visual Proof with an explicit N/A if applicable, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the completed Checklist.

Resolution

Complete the required template sections. Add an ELI5 summary, provide before/after visual proof or state N/A with a reason, document AI use if applicable, complete the Agent skill upstream boundary and checklist items, and include the required compatibility and review notes.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 2c78f0d4-7657-45f6-baf4-933beed17657

📥 Commits

Reviewing files that changed from the base of the PR and between 83b1558 and 2785354.

📒 Files selected for processing (3)
  • mobile/src/cache/session-tab-strip-cache.test.ts
  • mobile/src/cache/session-tab-strip-cache.ts
  • mobile/src/session/mobile-session-tab-strip-entries.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@pullfrog pullfrog 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.

ℹ️ No critical issues — the fix is sound and well-tested. One documentation inconsistency the digest introduces is worth reconciling before merge, detailed below.

Reviewed changes

A privacy hardening follow-up to #19281 that closes three plaintext leaks in the cached tab strip: tab ids (an editor id embeds the absolute file path), per-type titles (file/markdown basenames and agent-session task text), and hook-controlled agent text.

  • Tab id digestion — digestTabId stores cached: + a 128-bit SHA-256 prefix, maps activeTabId through the same digest, and re-digests raw ids written by older builds on load while leaving an already-digested id alone.
  • Exhaustive persistable titles — getPersistableTabStripTitle is now a switch over tab type returning fixed labels, dropping the title argument entirely.
  • Agent id allowlist — getPersistableTabStripAgentId keeps an id only when it is a key of TUI_AGENT_DISPLAY_NAMES.
  • Tests — new and reworked cases assert digest shape and non-leakage against the written blob, and genuinely fail against main's scrub.

ℹ️ Digesting ids reverses the key continuity the strip comments still promise

The digest deliberately breaks the id equality the strip relied on to reconcile cached rows into live rows, but two in-repo comments still assert that equality, and the PR body's own rationale ("there is no key continuity to lose") contradicts the code it leaves in place. Wrong as-is, and misleading to a future maintainer who trusts the comments.

Technical details
# Reconcile the key-continuity comments with the id digest

## Affected sites
- mobile/src/session/mobile-session-tab-strip-entries.ts:105-107 — "its ids are the live ids, so the swap reuses the same React keys" is now false: stored ids are `cached:` digests, never the live id.
- mobile/src/cache/session-tab-strip-cache.ts:1-4 — "swaps in live rows under the same keys" no longer holds for the same reason.
- mobile/src/session/MobileSessionHeader.tsx:140 — `key={entry.id}` means a preview row (digest key) and its live row (raw id) no longer reconcile in place; the reconnect preview→live swap now remounts the strip rows instead of updating them.

## Required outcome
- Update the two comments to describe the new behavior truthfully, and confirm the preview→live remount on reconnect causes no visible regression — the original same-key swap existed precisely to keep that reconnect repaint clean.

## Open questions for the human
- Is the `mobile-session-reconnect-view-state.test.ts` case "then the live tabs under the same keys" still a meaningful premise now that the live id never appears in the cached preview?

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

A single tightening on top of the previously reviewed digest work: digestTabId now recognizes only the full digest shape rather than any id that merely starts with the cached: prefix.

  • Full-shape digest check — the guard changed from tabId.startsWith('cached:') to DIGESTED_TAB_ID.test(tabId) with DIGESTED_TAB_ID = /^cached:[0-9a-f]{32}$/, closing the path where a wire-supplied id like cached:/Users/.../private-file.md was mistaken for an already-digested id and written verbatim.
  • Failing-first regression test — a new case feeds a prefix-only wire id and asserts both the digest shape and that the path text never reaches the written blob; it fails against the previous startsWith guard.

The regex is consistent with the digest it guards: digestHex slices sha256 to exactly 32 lowercase hex chars, so already-digested ids from this version match and are left stable, while the reject-path cases (cached: + non-hex, wrong length, or trailing content) fall through to digestion.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…b, always digest wire ids

- a preview row and its live successor now share a React key (the digest), so the
  reconnect swap no longer remounts every row; layouts and scroll lookups use the same key
- storage moves to orca:session-tab-strip:v2 and the v1 blob, which holds raw editor ids
  and shell-set titles from older builds, is removed on first load
- a wire id shaped like a stored key is digested anyway; only storage keeps one as-is

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 5dc46edb-5a35-47fb-8318-29a29c114d26

📥 Commits

Reviewing files that changed from the base of the PR and between e7a4aa1 and 9f057e3.

📒 Files selected for processing (9)
  • mobile/src/cache/session-tab-strip-cache.test.ts
  • mobile/src/cache/session-tab-strip-cache.ts
  • mobile/src/session/MobileSessionHeader.tsx
  • mobile/src/session/mobile-session-reconnect-view-state.test.ts
  • mobile/src/session/mobile-session-route-parity.test.ts
  • mobile/src/session/mobile-session-route-source-family.test-support.ts
  • mobile/src/session/mobile-session-tab-strip-entries.ts
  • mobile/src/session/mobile-session-tab-strip-row-key.ts
  • mobile/src/session/use-mobile-session-keyboard-state.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Since the prior Pullfrog review, this delta extracted the digest/row-key helpers, migrated the cache off the plaintext v1 blob, and restored the React key continuity the id digest had broken.

  • Extracted mobile-session-tab-strip-row-key.ts — digestHex, toMobileSessionTabStripRowKey, and isMobileSessionTabStripRowKey now live in one module; digestWorkspaceId reuses digestHex instead of inlining its own loop.
  • Source-aware id digestion — toStoredTabId(tabId, source) always digests a 'wire' id (even one the host shaped like a stored key), while a 'storage' id is only left alone when it already matches the full /^cached:[0-9a-f]{32}$/ shape, so a raw id written by an older build is digested on the way back out.
  • v1 → v2 storage key with purge — the cache now writes orca:session-tab-strip:v2 and best-effort removeItems the plaintext v1 blob on first load.
  • Restored React key continuity — getMobileSessionTabStripRows now emits a key field (the digest) for both preview and live rows, and the header/keyboard-state key layouts and scroll on that digest, so the reconnect preview→live swap reconciles in place instead of remounting. This resolves the open concern from the prior review, and the stale "same keys" comments were rewritten to match.

The activeTabId mapping through the digest ids map preserves the cap boundary (an active id past MAX_TABS_PER_WORKSPACE still resolves to null), and the new tests assert exact digest shapes and non-leakage rather than loose truthiness.

One non-blocking sequencing note: the plaintext v1 blob is purged lazily, on the first loadCachedSessionTabStrip/deleteCachedSessionTabStripForHost call rather than at app launch. A user who upgrades and never re-opens the session keeps the old blob on disk until they do. The best-effort intent is documented in readStoredFile, and the new v2 writes stop the leak going forward, so this is informational rather than a required change.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Since the prior Pullfrog review, this delta closes the one open item (the lazy plaintext purge) by making legacy-blob removal self-healing instead of fire-and-forget.

  • Retried legacy removal — a new module-level pendingLegacyRemovals set tracks keys whose removeItem has not yet succeeded this process, and removeLegacyBlobs() now runs on both readStoredFile and writeFile, so a bridge hiccup on the first launch no longer strands the plaintext v1 blob for the process's life; each key is dropped from the set (and never retried again) once a removal resolves.
  • Test-reset hygiene — resetSessionTabStripCacheForTests re-seeds pendingLegacyRemovals, and a new failing-first case asserts the retry-on-next-write then stop-once-landed behavior against a mocked one-shot removeItem rejection.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

… host deletion await it

A session that only loads (offline) never reached the retry, which lived in the memoized
file read. Forgetting a host now fails until the older build's blob is gone too.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Since the prior Pullfrog review, this delta hardened the legacy-blob purge so a failed removal is retried on every load (not just the memoized first file read), and made host deletion await the purge.

  • Retry moved out of the memoized read — removeLegacyBlobsBestEffort() now runs at the top of loadCachedSessionTabStrip, so an offline session that only ever loads still retries a removal that failed on launch; readStoredFile no longer owns the retry.
  • Host deletion awaits the purge — deleteCachedSessionTabStripForHost now awaits the promise-returning removeLegacyBlobs() after the v2 rewrite and throws on failure, so a host deletion is not reported done while the legacy plaintext blob may still hold its titles. Both callers (host-removal-lifecycle, unpaired-host-credential-deletion) .catch() and warn, so the throw is never fatal.
  • Failing-first tests — two new cases: one asserts the retry fires on a later load with no write in between, the other asserts a host deletion rejects while the legacy blob is still on disk. Both fail against the previous revision.

No prior Pullfrog threads remain open; the earlier key-continuity concern was already resolved by the row-key digest work.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H

Jinwoo-H commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Closed with #19348, which reverts the mobile pass this PR fixes bugs inside. The mobile reconnect work will be re-landed one narrow, device-verified change at a time.

@Jinwoo-H Jinwoo-H closed this Sep 7, 2026
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.

1 participant