Skip to content

fix(mobile): avoid duplicate Clerk auth back buttons - #4803

Closed
gabrielelpidio wants to merge 3 commits into
mainfrom
agent/fix-mobile-clerk-auth-back-button
Closed

gabrielelpidio wants to merge 3 commits into
mainfrom
agent/fix-mobile-clerk-auth-back-button

Conversation

@gabrielelpidio

@gabrielelpidio gabrielelpidio commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Let Clerk own the signed-out authentication navigation chrome.
  • Hide the app's native stack header while AuthView is active.
  • Restore the native header while Clerk session state loads and for the signed-in account view.
  • Route Clerk's dismiss action back through the enclosing settings navigator.
  • Add focused tests for each header-ownership state.

Why

The email-code step has its own Clerk back action, while the enclosing settings route also rendered a native back button. Both navigation layers were visible in the same sheet, producing stacked back buttons.

Keeping one navigation owner per state removes the duplicate control without changing the signed-in account screen.

User impact

The Clerk email-code flow now shows one coherent set of navigation controls. Users can still leave the auth flow through Clerk's dismiss action, and signed-in account settings retain the existing native header.

Validation

  • pnpm vp test run apps/mobile/src/features/settings/SettingsAuthRouteScreen.logic.test.ts
  • pnpm --filter @t3tools/mobile typecheck
  • pnpm vp lint apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx apps/mobile/src/features/settings/SettingsAuthRouteScreen.logic.ts apps/mobile/src/features/settings/SettingsAuthRouteScreen.logic.test.ts
  • git diff --check

UI changes

No screenshots included. The Clerk email-code flow requires configured interactive authentication and was not launched during this pass.

Generated by GPT-5 in the Codex harness.

Note

Fix duplicate back buttons in mobile Clerk auth by hiding the native header during sign-in

  • Adds resolveSettingsAuthHeaderOptions in SettingsAuthRouteScreen.logic.ts to derive header visibility from Clerk load/sign-in state; the native header is hidden when Clerk controls its own navigation chrome.
  • Updates SettingsAuthRouteScreen.tsx to use the new utility and adds an onDismiss callback that calls navigation.goBack().
  • Introduces bufferEpoch/bufferStart/bufferEnd tracking across the terminal buffer state machine in terminalSession.ts, enabling append-vs-replace decisions via the new getTerminalBufferUpdate utility.
  • Propagates epoch/position props through the React Native terminal surface stack and implements chunked async buffer feeding with generation guards in the iOS native view T3TerminalView.swift.

Macroscope summarized 699c574.


Note

Medium Risk
Terminal display logic changes on web, mobile JS, and native iOS simultaneously; incorrect append/replace could corrupt or flash terminal output. Settings auth changes are limited to header visibility and dismiss navigation.

Overview
This PR combines mobile settings auth navigation fixes with terminal buffer synchronization across client-runtime, web, and iOS native.

Settings auth (mobile): resolveSettingsAuthHeaderOptions drives stack headerShown and title from Clerk isLoaded / isSignedIn—the native header stays visible while the session restores and on the signed-in account screen, but is hidden while AuthView is shown so Clerk’s back/dismiss UI isn’t doubled. AuthView is dismissible and onDismiss calls navigation.goBack().

Terminal buffers: Session state now tracks bufferEpoch, bufferStart, and bufferEnd (absolute positions in the retained window). Snapshots/restarts/clears bump epoch; output updates end positions so rollover stays appendable. getTerminalBufferUpdate chooses append, replace, or none using epoch and position overlap instead of relying only on version or string prefix.

That metadata flows through mobile TerminalSurface / native props; replay/hidden-buffer paths bump epoch or reset start on ThreadTerminalRouteScreen. Web ThreadTerminalDrawer applies updates via getTerminalBufferUpdate. iOS T3TerminalView feeds Ghostty in 8KB chunks on the main queue, appending when epoch and positions align and resetting the surface when epoch changes or the renderer falls behind.

Reviewed by Cursor Bugbot for commit 699c574. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3206292e-7014-4c70-91ef-33272824b29c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 29, 2026
@gabrielelpidio
gabrielelpidio marked this pull request as ready for review July 29, 2026 15:15
Comment thread apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx
@macroscopeapp

macroscopeapp Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces significant terminal buffer management changes (async chunked feeding, epoch tracking, generation handling) beyond the stated auth button fix. The scope of runtime behavior modifications across native iOS and TypeScript warrants human review.

You can customize Macroscope's approvability policy. Learn more.

@skjiisa

skjiisa commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

The signed-in state has the same issue fwiw, but it seems you intentionally had it not touch the signed-in state?

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jul 30, 2026
Comment thread apps/web/src/components/ThreadTerminalDrawer.tsx

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d9a445c. Configure here.

Comment thread apps/web/src/components/ThreadTerminalDrawer.tsx
@juliusmarminge

Copy link
Copy Markdown
Member

Closing as part of the open-PR backlog sweep (wave 1).

Reason: Duplicate Clerk back-button fix; #5140 later repaired Clerk auth headers.
Related: #5140

Reopen if this is still wanted and you’re willing to rebase onto current main.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants