Skip to content

fix(ui): fix home button not working until stream ends#4145

Merged
TheodoreSpeaks merged 1 commit intostagingfrom
fix/home-flash
Apr 14, 2026
Merged

fix(ui): fix home button not working until stream ends#4145
TheodoreSpeaks merged 1 commit intostagingfrom
fix/home-flash

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

We had logic that waited until active transport finished before returning home. Removed this logic so clicking home instantly takes you back.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Validated sending new tasks and going home works instantly.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 14, 2026 1:48am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

PR Summary

Medium Risk
Changes home-navigation behavior to reset chat state without waiting for active streaming/transport to settle, which could affect in-flight stream UI/state handling. Scope is limited to the useChat home reset effect.

Overview
Fixes the Home button behavior by removing the “wait for transport to finish” gating logic in useChat and always calling resetHomeChatState() when the user is on /home with an active chatId (and not in workflow mode).

This deletes the wasHomePage/pendingHomeReset bookkeeping and the checks for active sending/reconnecting/stream readers, so returning home clears chat state immediately instead of deferring until the stream ends.

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 14, 2026

Greptile Summary

This PR fixes a UX bug where clicking the home button while a Mothership stream was active would block navigation until the stream finished. The fix removes a sendingRef.current guard in the useEffect at line 1219 of use-chat.ts, allowing resetHomeChatState() to be called immediately on navigation, while the server-side stream continues via the existing "detach without cancel" pattern (stream generation is incremented to mark processing as stale, but the network connection is intentionally left open for potential reconnection).

Confidence Score: 5/5

Safe to merge — targeted one-line removal of a blocking guard with no correctness risk.

The fix removes a guard that blocked resetHomeChatState() while streaming. The detach-without-cancel design is consistent with the rest of the hook: streamGenRef.current++ correctly marks all in-flight processing as stale, the server continues streaming and persists the response, and reconnect logic handles re-entry. No data loss, no broken state.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts Removed the sendingRef.current guard in the isHomePage effect (line 1219) so resetHomeChatState() fires immediately; stream is detached via streamGenRef.current++ while network connection is intentionally left open for server-side completion and future reconnection.

Sequence Diagram

sequenceDiagram
    participant User
    participant HomeEffect as useEffect (isHomePage, line 1219)
    participant Reset as resetHomeChatState()
    participant Stream as processSSEStream read loop
    participant Server as Mothership Server

    User->>HomeEffect: Click home button (isHomePage = true)
    Note over HomeEffect: Before fix: if (sendingRef.current) return — blocked navigation
    HomeEffect->>Reset: resetHomeChatState() [now called immediately]
    Reset->>Reset: streamGenRef.current++ (marks stream stale)
    Reset->>Reset: abortControllerRef.current = null (detach, not abort)
    Reset->>Reset: setTransportIdle() / clear UI state
    Note over Stream: isStale() === true — discards incoming chunks
    Stream-->>Stream: Continues reading until stream ends (no-op)
    Server-->>Server: Continues generating and persisting response
    Note over User: UI immediately resets to home state
Loading

Reviews (1): Last reviewed commit: "fix(ui): fix home button not working unt..." | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit c75d7b9 into staging Apr 14, 2026
14 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/home-flash branch April 14, 2026 01:56
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