Skip to content

fix(web): open the remembered chat-list mode at the home address - #2214

Merged
yunfanye merged 1 commit into
mainfrom
fix/home-keeps-chat-list-mode
Nov 15, 2026
Merged

yunfanye merged 1 commit into
mainfrom
fix/home-keeps-chat-list-mode

Conversation

@yunfanye

Copy link
Copy Markdown
Contributor

Why

A guardian who switched the chat list to Chat mode found it back in Concierge mode every time the app opened. The device stored the choice, but the home address always opened the main chat, and the list follows the open chat. The home address now opens the chat that the rail's Chat entry would.

Invariants

  • Opening the app at its home address keeps the chat-list mode the device last showed.
  • In Chat mode it opens the last ordinary chat, or a blank chat once that chat is gone. In Concierge mode, or on a device that has never shown a mode, it opens the main chat as before.

Scope

Merge danger

Two-way door: a revert restores the old landing. Blast radius: where the dashboard lands at / for a device whose stored mode is Chat.

Evidence

  • Chat mode with a last ordinary chat: / opens that chat. Fails without the fix.
  • Chat mode once that chat has been deleted: / opens a blank chat. Fails without the fix.
  • Mock dashboard: picked Chat, loaded / again, and the app landed on /chat with the list in Chat mode. Picked Concierge, loaded / again, and it landed on the main chat. Only the landing route changes, so no view looks different.

🤖 Generated with Claude Code

The home address always opened the main chat, and the chat list follows the
open chat, so every app launch put a guardian who had chosen Chat mode back in
Concierge mode. The home address now opens the chat the rail's Chat entry
would: the main chat in Concierge mode, else the last ordinary chat.

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

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

Design & Alternatives review: ✅ APPROVE

Problem: A guardian who leaves the chat list in Chat mode finds it in Concierge mode every time the app opens. The / route always redirected to MAIN_CHAT_PATH, and useChatListFollowsRoute sets the list's mode from the open chat, which overwrote the stored Chat choice.

Goals: opening / keeps the mode the device last showed. In Chat mode it opens the last ordinary chat, or a blank chat if that chat is gone. In Concierge mode, or on a device that has never shown a mode, it behaves as before. Non-goals: deep links or reloads on a specific chat, which still follow that chat's kind as #2122 set out, and any change to how modes are stored.

PR's approach: a HomeRedirect component that reads the stored mode and last ordinary chat (useStoredChatListMode, useLastOrdinaryChatId, useChatSessionMayExist) and redirects to railChatHref(...). These are the same pieces shell/AppGrid.tsx (around lines 192–197) uses to build the rail's Chat link, so / and the rail Chat link always go to the same place.

I checked the cold-load case. On a fresh load no chat list is cached yet, so useChatSessionMayExist returns true. If the last ordinary chat was deleted on another device, / first goes to /chat/<id>. The existing ChatComponent.handleSessionNotFound then sees the 404 and replaces the route with /chat. So "a blank chat once that chat is gone" holds after one extra request, even though the PR's third test seeds the cache to show it directly.

Alternatives considered (all checked against the code):

  1. Do nothing / make the list ignore the open chat: have RecentChats keep the stored mode instead of following the route (useChatListFollowsRoute in hooks/use-chat-list-mode.ts). This reverses #2122: a reload on a Concierge chat would no longer show that chat in the list. It fixes one bug by breaking another invariant.
  2. Fix it in the follow-route logic: have chatListModeForRoute skip changing the mode when the page landed on /message by a redirect from /. This would need router state passed through the redirect and an exception inside the shared mode logic. The list would then show Chat mode while the main Concierge chat is open, which is the mismatch #2122 removed.
  3. Reuse the rail's logic (the PR): use railChatHref and its hooks for /. No new state and no data-model change. One small component.
  4. Pull the rail's link logic into a shared useRailChatHref() hook used by both AppGrid and HomeRedirect. Same behaviour as (3), with the logic in one place. This is a small refactor on top of the PR, not a different design.
Approach Added complexity Correctness / completeness Blast radius Reversibility Maintenance Effort
(1) List ignores open chat Low Breaks #2122 (open chat can be missing from the list) Every chat page Two-way Brings back the old bug class Low
(2) Exception in follow-route logic Medium (state passed through the redirect, special case) List mode and open chat can disagree Every chat route Two-way Fragile special case Medium
(3) PR: / redirects via railChatHref Low Meets both invariants; deleted chat on cold load falls back through the 404 handler Only / on Chat-mode devices Two-way Duplicates three lines from the rail Low
(4) Shared useRailChatHref() hook Low Same as (3) Same as (3) Two-way Rail and home can't drift apart Low

No public API, schema or wire-format commitment is involved. The localStorage keys already exist and are unchanged, so every option can be undone.

Recommendation: the PR's approach is the best fit. It fixes the cause at the one place the bad landing comes from, keeps #2122's rule, and reuses the rail's existing routing rules. Moving the three-hook lookup into a shared hook (option 4) is optional; it would stop / and the rail Chat link from drifting apart later.

Verdict: APPROVE — The PR sends / to the same address the rail's Chat entry already opens, using that entry's own helpers. It is a small, reversible change that keeps #2122's rule that the list follows the open chat, and I found no design-level correctness problem.

1 finding(s) posted as inline comments below.

Severity Category File Title
P3 design packages/web/src/pages/free/FreePage.tsx Share one hook for the rail's Chat link and the home redirect

Automated review by RomeOS Code Review · commit 89460ed · Full review history

* chat. The chat list follows the open chat, so opening the main chat here
* would put a guardian who left the list in Chat mode back in Concierge mode.
*/
export function HomeRedirect() {

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.

[P3] design — Share one hook for the rail's Chat link and the home redirect

HomeRedirect repeats the lookup in shell/AppGrid.tsx (around lines 192–197): the stored mode with a Concierge fallback, the last ordinary chat, whether it still exists, and the railChatHref call. The PR's own invariant is that / opens what the rail's Chat entry would, so a hook like useRailChatHref() in hooks/use-chat-list-mode.ts, used by both, would keep that true if either side changes, for example the conciergeAvailable argument that AppGrid passes to useChatListModeForShell. Optional; the behaviour today is the same.

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

Code Review: ✅ APPROVE

Goal: When the app opens at /, it should land on the chat the rail's Chat entry would open. Today it always opens the main chat, and because the chat list follows the open chat, a device whose stored mode is Chat gets switched back to Concierge every time.

Approach: The PR swaps <Navigate to={MAIN_CHAT_PATH}> for a new HomeRedirect. It reads the tab's stored mode (useStoredChatListMode), the last ordinary chat (useLastOrdinaryChatId) and whether that chat may still exist (useChatSessionMayExist). It then calls the existing railChatHref.

What I checked beyond the diff:

  • Same logic as the rail. AppGrid builds the Chat entry from the same three inputs and the same railChatHref, so / and the rail can't drift apart. useChatListModeForShell(true, "concierge") in AppGrid comes to the same thing as mode === "chat" ? … : MAIN_CHAT_PATH here, because a null stored mode falls back to Concierge in both.
  • Cold load with a deleted last chat. On a cold load no chat list is cached yet, so chatSessionMayExist returns true and the redirect may go to /chat/<deleted-id>. That is safe: Chat.tsx turns a 404 from listSessionMessagePage into onSessionNotFound, which sends the guardian to the blank-chat page. The rail behaves the same way.
  • Mode tracking afterwards. useChatListFollowsRoute then gives /chat → Chat and /chat/<id> → Chat once the chat's kind is known, so the stored mode holds.
  • Other links to /. The only in-app one is the <Link to="/"> in AppEmbeddedPage. It now follows the tab's mode, which is what the PR intends.
  • e2e tests. mock-page-renders and touch-target both visit / with empty storage, where the mode is null, so they still land on the main chat.
  • Unit tests. They cover Concierge mode, Chat mode with a last chat, and Chat mode once that chat is gone from the cached lists.

Simplicity: The PR adds no new entities or stored data. It is about 10 lines that reuse existing hooks and helpers. I have nothing to raise.

Verdict: APPROVE — I found no correctness, security or design problems. The fix is small, reuses the rail's existing railChatHref logic, and has tests for each branch.

No issues found. Code looks good!


Automated review by RomeOS Code Review · commit 89460ed · Full review history

@yunfanye yunfanye left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: ✅ APPROVE

Reviewed all changed files and traced storage, shell mode synchronization, and missing-chat fallback. No actionable issues found. Regression tests were added but could not run because dependencies are not installed.

Verdict: APPROVE — The home redirect reuses existing rail navigation logic without changing explicit chat routes.

No issues found. Code looks good!


Automated review by RomeOS Code Review · commit 89460ed · Full review history

@yunfanye
yunfanye merged commit 76b2394 into main Nov 15, 2026
12 checks passed

@yunfanye yunfanye left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design & Alternatives review: ✅ APPROVE

When a guardian opens the home address after choosing Chat mode, the list switches to Concierge because / always opens the main chat.

Goals: Restore the remembered mode at /, opening the last ordinary chat or a blank chat. Non-goals: Change explicit-chat reloads, chat classification, or preference storage.

Approach: HomeRedirect in packages/web/src/pages/free/FreePage.tsx reuses the stored-mode hooks, cache-based existence check, and railChatHref already used by packages/web/src/shell/AppGrid.tsx.

Approach Added complexity Correctness/completeness Blast radius Reversibility Maintenance Effort
PR: mode-aware home redirect Low Meets home-only goals / landing Easy Reuses existing policy Low
Do nothing None Leaves the reported bug None N/A None None
Stop route-driven mode updates in hooks/use-chat-list-mode.ts Moderate Preserves preferences but breaks explicit-chat mode alignment All chat navigation Reversible Changes established semantics Medium
Validate the remembered chat with lib/chat-api.ts#getSession before redirecting Moderate Confirms deletion earlier, but delays landing Home startup Easy Adds asynchronous redirect handling Medium

Recommendation: The PR is the best fit: it corrects the conflicting landing route rather than weakening route/list consistency. No public API, schema, or wire-format commitments are introduced. On a cold load, the cache cannot establish deletion, but existing recovery in components/chat/Chat.tsx and ChatComponent.tsx redirects a confirmed missing chat to /chat.

Verification: Read all changed files and traced shell mode updates, rail navigation, storage, and missing-session recovery. New tests cover both modes and cached deletion; existing tests cover missing-session recovery. Targeted tests could not run because dependencies are absent (rstest not found).

Verdict: APPROVE — The home-only redirect reuses existing navigation policy while preserving explicit-chat routing and missing-chat recovery.

No issues found. Code looks good!


Automated review by RomeOS Code Review · commit 89460ed · Full review history

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.

2 participants