Skip to content

refactor(mobile): route screens share one route-param parser - #28782

Closed
only21mil wants to merge 3 commits into
pingdotgg:mainfrom
only21mil:fix/audit-m096
Closed

only21mil wants to merge 3 commits into
pingdotgg:mainfrom
only21mil:fix/audit-m096

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

Four mobile files each kept their own identical copy of firstRouteParam: thread, files, terminal and thread selection. App shortcuts kept a looser variant whose caller trimmed and rejected blank ids itself. Small parsers copied like this tend to drift apart, and the shortcut variant already had.

Change

firstRouteParam now lives once in apps/mobile/src/lib/routeParams.ts, and all five files import it. It is the existing body unchanged: it takes the first value, treats a blank one as missing and returns a present one untrimmed.

Every caller gets the same result as before:

  • The four route files had byte-identical copies, so nothing changes there.
  • activeThreadRef still trims the result and rejects empty ids. A blank id is now rejected inside the helper rather than by the caller. A null param, which the old variant passed through, now throws inside the helper. activeThreadRef's existing try/catch returns null for it, the same as for the other malformed values it already handles.

useOpenPullRequest has a similar inline parser, but it is left alone. It returns undefined and tolerates null during render without a try/catch, so switching it over could change behavior. The other inline first-value helpers in mobile let blank values through, so they are not copies of this one.

Scope and approval

Maintenance only, with no product behavior or route changes, so it needs no prior issue or discussion. Maintainers: please confirm you want the shared helper in apps/mobile/src/lib. It is mobile-only because the string | string[] param shape comes from mobile navigation.

No screen changes, because every call site returns the same value as before.

Verification

  • vp test run src/features/shortcuts/appShortcuts.test.ts src/dependency-graph.test.ts in apps/mobile: 2 files, 10 tests passed. The activeThreadRef malformed-params table gained a null row. A new case checks that a valid scalar or array param still gives the trimmed first value.
  • vp run check:changed 1d626d02d9: format, lint, knip, typecheck (2 packages), tests and React Compiler all passed.
  • A script compared the old helpers with the shared one over 18 inputs: missing, null, empty, whitespace, padded strings, empty and blank arrays, multi-value arrays and non-string values. It checked results at both the route-screen level and the activeThreadRef level, and found 0 differences.

Not checked: a run on an iOS or Android device, since no screen changes.

Prior PRs

None found for this change. A search for firstRouteParam across open and closed PRs returned nothing. Open PRs that touch these files do not change the parser lines.

Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly

Four mobile route files carried byte-identical copies of firstRouteParam,
and app shortcuts kept a looser variant whose caller trimmed and rejected
blank ids itself. Move the parser to lib/routeParams and import it
everywhere. Every caller returns the same result as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 1, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 47c575b

Macroscope's review found this PR approvable — This consolidates mobile route-parameter parsing while preserving existing screen and shortcut behavior. The refactor introduces no product-default changes or new operational exposure.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The mobile app adds a shared route-parameter helper. Route screens, shortcuts, and thread selection now use it instead of local implementations.

Changes: Route Parameter Sharing

Layer / File(s) Summary
Shared helper contract
apps/mobile/src/lib/routeParams.ts
Adds firstRouteParam to select the first array value or scalar, return null for missing or whitespace-only values, and preserve other strings.
Feature adoption and tests
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx, apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx, apps/mobile/src/features/threads/ThreadRouteScreen.tsx, apps/mobile/src/features/shortcuts/appShortcuts.ts, apps/mobile/src/state/use-thread-selection.ts, apps/mobile/src/features/shortcuts/appShortcuts.test.ts
These consumers replace local implementations with the shared helper. Shortcut tests cover malformed parameters and array-valued and whitespace-padded inputs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • pingdotgg/t3code#25197: Changes file-route path parameter handling for string and array values. This PR also centralizes file-route parameter normalization.

Suggested reviewers: maria-rcks, t3dotgg

Merge Risk: Minimal · up to 59c39

Supported route parameters retain their behavior; no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: sharing one route-parameter parser across mobile route screens.
Description check Passed The description covers the problem, change, scope, and verification. The scope section explains why no issue or discussion was used, but it does not link maintainer approval or explain why this refact…
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 covers the problem, change, scope, and verification. The scope section explains why no issue or discussion was used, but it does not link maintainer approval or explain why this refactor meets the template’s stated exception for an obvious bug.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 67e9d63 and 59c39a7.

Files selected for processing: 3

  • apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
  • apps/mobile/src/features/threads/ThreadRouteScreen.tsx
  • apps/mobile/src/state/use-thread-selection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Merged current main into this branch without rebasing. Resolved the ThreadRouteScreen conflict by preserving main's inspector cleanup and the shared route-param parser. The diff remains seven files, 19 additions and 28 deletions.

Blacksmith verification passed: vp run check:changed a185dd924889, including formatting, lint, both knip checks, mobile/scripts typechecks, all 8 shortcut tests, and 11 selected React Compiler checks. Two independent source reviews found no actionable issues at 67e9d635f1557924c57de99aa4fd5ff47714f98c.

Native device interaction remains unverified. This is a behavior-preserving parser refactor with no visual changes.

Main changed the imports in use-thread-selection and the fallback layout
in ThreadRouteScreen. Both keep main's code and drop only their private
firstRouteParam copy in favor of the shared helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@only21mil

Copy link
Copy Markdown
Contributor Author

Note

🤖 Opus 5.5 replying on behalf of Victor.

Merged current main into this branch to clear the conflict: merge commit 59c39a7, no rebase. Main had changed the imports in use-thread-selection.ts and the fallback layout in ThreadRouteScreen.tsx. Both files keep main's code and drop only their private firstRouteParam copy. The diff is still seven files, 19 additions and 28 deletions, and nothing was dropped.

Main still had all five private copies, and no new copy has appeared since. The 18-input comparison ran again against main's current copies and activeThreadRef, at both the route-screen and shortcut level, and found 0 differences. vp run check:changed and the affected mobile suites (9 files, 133 tests) pass. No screen changes, since every call site returns the same value as before.

@only21mil

Copy link
Copy Markdown
Contributor Author

Note

🤖 Opus 5.5 replying on behalf of Victor.

Closing this: it is not a bug fix, and this repository now takes only bug fixes from outside contributors. The branch stays on my fork if it is useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants