Repository navigation
fix(web): open the remembered chat-list mode at the home address - #2214
Conversation
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
left a comment
There was a problem hiding this comment.
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):
- Do nothing / make the list ignore the open chat: have
RecentChatskeep the stored mode instead of following the route (useChatListFollowsRouteinhooks/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. - Fix it in the follow-route logic: have
chatListModeForRouteskip changing the mode when the page landed on/messageby 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. - Reuse the rail's logic (the PR): use
railChatHrefand its hooks for/. No new state and no data-model change. One small component. - Pull the rail's link logic into a shared
useRailChatHref()hook used by bothAppGridandHomeRedirect. 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() { |
There was a problem hiding this comment.
[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
left a comment
There was a problem hiding this comment.
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.
AppGridbuilds the Chat entry from the same three inputs and the samerailChatHref, so/and the rail can't drift apart.useChatListModeForShell(true, "concierge")inAppGridcomes to the same thing asmode === "chat" ? … : MAIN_CHAT_PATHhere, 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
chatSessionMayExistreturns true and the redirect may go to/chat/<deleted-id>. That is safe:Chat.tsxturns a 404 fromlistSessionMessagePageintoonSessionNotFound, which sends the guardian to the blank-chat page. The rail behaves the same way. - Mode tracking afterwards.
useChatListFollowsRoutethen 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="/">inAppEmbeddedPage. It now follows the tab's mode, which is what the PR intends. - e2e tests.
mock-page-rendersandtouch-targetboth 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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
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
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
/opens that chat. Fails without the fix./opens a blank chat. Fails without the fix./again, and the app landed on/chatwith 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