Skip to content

Keep freebuff session alive when browsing /history#515

Merged
jahooma merged 1 commit intomainfrom
jahooma/history-waitroom-fix
Apr 19, 2026
Merged

Keep freebuff session alive when browsing /history#515
jahooma merged 1 commit intomainfrom
jahooma/history-waitroom-fix

Conversation

@jahooma
Copy link
Copy Markdown
Contributor

@jahooma jahooma commented Apr 19, 2026

Summary

  • In freebuff, after admission from the waiting room, opening /history (and then selecting a chat or canceling) sent the user back to the waiting room.
  • Cause: rendering ChatHistoryScreen at the App level unmounted AuthedSurface, which ran useFreebuffSession cleanup (DELETE + clear session). The next render POSTed again and landed in the waiting room.
  • Fix: render ChatHistoryScreen inside AuthedSurface (after the freebuff gate) so the session stays mounted across history browsing.

Test plan

  • As a freebuff user, get admitted from the waiting room, run /history, select a previous chat — verify you land directly in the resumed chat and not back in the waiting room.
  • Same flow, but cancel out of the history screen — verify you return to the current chat with session intact.

🤖 Generated with Claude Code

Rendering ChatHistoryScreen at the App level unmounted AuthedSurface,
which triggered useFreebuffSession cleanup (DELETE + clear session) and
sent the user back to the waiting room on return. Move the history
screen inside AuthedSurface so the session stays mounted.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 19, 2026

Greptile Summary

This PR fixes a freebuff session lifecycle bug where navigating to /history (and back) would drop the user back into the waiting room. The root cause was that ChatHistoryScreen was rendered at the App level, causing AuthedSurface to unmount, which triggered the useFreebuffSession cleanup (DELETE + session clear). The fix moves ChatHistoryScreen rendering inside AuthedSurface, after the freebuff gate, so the session hook stays continuously mounted during history browsing.

  • Removes the early-return ChatHistoryScreen block from the App component.
  • Threads four new props (showChatHistory, onSelectChat, onCancelChatHistory, onNewChat) through AuthedSurface.
  • Adds the ChatHistoryScreen render inside AuthedSurface after the freebuff admission gate, with a clear comment explaining the motivation.
  • For non-freebuff users, behavior is unchanged: the freebuff gate conditions are guarded by IS_FREEBUFF, so history browsing for regular users is unaffected.

Confidence Score: 5/5

Safe to merge — targeted single-file fix with correct reasoning and no regressions for non-freebuff users.

The change is minimal and well-understood: it lifts ChatHistoryScreen inside AuthedSurface so the freebuff session hook is never unmounted during history browsing. The freebuff gate guards are correctly placed before the ChatHistoryScreen check, preserving the waiting-room experience for non-admitted users. Non-freebuff users are unaffected. No security, data-loss, or logic concerns identified.

No files require special attention.

Important Files Changed

Filename Overview
cli/src/app.tsx Moves ChatHistoryScreen render from App level into AuthedSurface so useFreebuffSession stays mounted during history browsing; clean prop threading with no logic regressions.

Sequence Diagram

sequenceDiagram
    participant User
    participant App
    participant AuthedSurface
    participant useFreebuffSession
    participant ChatHistoryScreen

    Note over App,ChatHistoryScreen: Before fix — history unmounts AuthedSurface
    User->>App: opens /history
    App-->>AuthedSurface: unmounts (early return)
    AuthedSurface-->>useFreebuffSession: cleanup → DELETE session
    App->>ChatHistoryScreen: renders at App level
    User->>ChatHistoryScreen: selects chat / cancels
    ChatHistoryScreen-->>App: callback
    App->>AuthedSurface: remounts
    AuthedSurface->>useFreebuffSession: POST → lands in waiting room

    Note over App,ChatHistoryScreen: After fix — history renders inside AuthedSurface
    User->>App: opens /history
    App->>AuthedSurface: stays mounted (showChatHistory=true passed as prop)
    AuthedSurface->>useFreebuffSession: session stays alive (no unmount)
    AuthedSurface->>ChatHistoryScreen: renders inside (after freebuff gate)
    User->>ChatHistoryScreen: selects chat / cancels
    ChatHistoryScreen-->>AuthedSurface: onSelectChat / onCancel callback
    AuthedSurface->>App: propagates action
    Note over AuthedSurface: Session intact — no waiting room
Loading

Reviews (1): Last reviewed commit: "Keep freebuff session alive when browsin..." | Re-trigger Greptile

@jahooma jahooma merged commit 7608629 into main Apr 19, 2026
31 of 34 checks passed
@jahooma jahooma deleted the jahooma/history-waitroom-fix branch April 19, 2026 22:57
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