Skip to content

fix(sidebar): dim folder and New-menu writes while the gateway is offline - #20749

Merged
chenmingwei23 merged 2 commits into
mainfrom
replace/9485
Oct 15, 2026
Merged

chenmingwei23 merged 2 commits into
mainfrom
replace/9485

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: While the gateway is offline, the sidebar's folder menus and the New-chat menu show their gateway writes as unavailable and say why, instead of looking live and then reporting a false "Folder update failed".

With the gateway offline, the folder ⋯ / right-click menus (list and board views) and the New-chat caret menu stay fully live. Rename, New subfolder, Folder settings, Hide when empty, Delete folder, Move folder to and every create row look clickable, but none of those writes can reach the gateway. A folder rename tried offline is worse than a dead click: it fires the PATCH, the cache snaps back, and the notice reads "Folder update failed — Failed to fetch" with an Ask the agent hand-off into a composer that cannot send. Session rows beside these menus are already dimmed and refuse offline, so one surface teaches two rules.

Why it matters

A user who learned that a dimmed session row means "not now" has no reason to read a full-weight Delete folder as unavailable, so the only way to find out is to click it and watch nothing happen. The false failure title is a correctness problem: it reports a server rejection that never happened, so a reader cannot tell "your change was refused" from "you are offline".

Not a goal

What changed (motivation → approach → change)

Symptom: gateway writes in the folder and create menus stay live offline, and a rename refused by the network is reported as an update failure. Root cause: those rows and their sinks never read the connection flag, and every folder write funnels its error into the one danger notice.

Rule applied: gate the gateway write at its sink, dim its entry rows, and leave an affordance that only reaches cached state at full weight.

  • Primitive (shared by fix(library): dim artifact-table writes while the gateway is offline #10832 / fix(sidebar): dim session-menu writes while the gateway is offline #10911 next): DropdownMenuItem / ContextMenuItem gain an offline prop that dims the row (composed after className, so the red Delete folder row goes muted too). FolderMoveSubmenu gains opt-in offline / offlineTitle for its trigger. New OfflineMenuReason renders one role="status" row, appended last in each gated menu, saying the dimmed actions need a connection (a disabled row cannot open its own tooltip). New offlineMenuRow in utils/offline.ts (beside offlineProps) spreads offline, the offlineProps tooltip / accessible name, and an onSelect that preventDefaults offline, so a refused row keeps the menu open.
  • Rows gated: list and board folder menus (folderBlocks.tsx, boardLane.tsx) and the header New menu (SidebarHeader.tsx): Rename, New subfolder, the two private-chat rows, Move folder to, Folder settings, Hide when empty, Delete folder; New chat, New incognito/temporary chat, New folder and each New-chat-in-folder row. Folder-name double-click and the folder + buttons carry the offline tooltip.
  • Sinks refuse: moveFolderTo and the sibling reorderFolders (drag), createChatInFolder, renameCommit (keeps the editor and draft if the gateway drops mid-edit) and the header split button's primary segment refuse with a neutral notice. toggleCollapse flips the cached flag offline instead of sending a PATCH that would fail.
  • No false failure: the refusal goes to a new neutral folder-action-offline notice (role="status", dismissable, retired on the disconnected→connected transition). Every real folder-mutation onError clears it. The Ask the agent hand-off on "Folder update failed" is withheld while offline.
  • Localized verbs: twelve utils.offline.* verbs plus menu_reason, in en.manual.json and the 12 locale catalogues; the raw English verbs passed to offlineProps in ChatInput, busySend, SessionRow, HistoryPane and SessionTabStrip become catalogue lookups.

Ported from #9485 onto main's ChatSidebar split (#20524): the gates moved from one 5,360-line file into the chat-sidebar render owners and hooks.

Backwards compatibility

Compatible: the new props are optional and default off; online behaviour of every row and sink is unchanged.

Removes nothing: offline the dimmed rows refuse a write that already could not reach the gateway; no data, key, route or public function is removed.

Tests

  • ChatSidebar.folderSettingsOffline.test.tsx (new, 27 cases): each gated row is aria-disabled and opens no modal / issues no write; the dim is visible (opacity-40 text-muted, danger colour dropped on Delete) with a connected control that carries no dim; a refused row leaves the menu open; the offline notice claims no update failure, offers no hand-off, and retires on reconnect; collapse still works offline from cache.
  • ChatSidebar.createMenu.test.tsx: offline every create row is dimmed and refuses, the reason row renders, a folder row's accessible name becomes "Alpha disabled — gateway offline"; the primary split segment raises the neutral notice and does not call createChatSlot.
  • Existing suites that assert a write reaches the server now seed a connected gateway (the store fixture models a disconnected dashboard).

Local: tsc -p tsconfig.app.json clean; ESLint clean on touched files; 129 vitest files / 1,829 tests pass across src/test/ChatSidebar*, ChatInput, SessionTabStrip, pages/chat-sidebar, components/ui and the sidebar integration suite; i18n-check.mjs (with I18N_BASE_REF), restyle ratchet, phantom-classes, theme-colors, i18n-strings, ui-index check, bundle-size gate (908 chunks within budget) and chunk-cycle gate pass.

Manual verification

Built SPA served with stubbed /api/**; the /api/ws stub closes the socket (offline) or keeps it open (online). Offline on main, a folder rename fired 3 PATCH /api/chat/folders/f2 and showed "Folder update failed"; on this branch it fired none and showed the neutral notice.

Screenshots / video

Folder ⋯ menu, offline — before (main) / after:

Folder menu offline on main: every row full weight
Folder menu offline after: writes dimmed, Hide folder live, reason row last

Folder rename refused offline — before (false failure) / after (neutral notice):

Rename offline on main: Folder update failed
Rename offline after: Gateway offline, reconnect to rename folders

New-chat menu offline (before / after) and online controls (unchanged)

New menu offline on main
New menu offline after
Folder menu online after
New menu online after

Related Issues

Fixes #20736
Replaces #9485 — thanks @rnoack1, whose change this is; the commit keeps their authorship. #10832 follows on the offline / OfflineMenuReason / FolderMoveSubmenu primitive added here.

Pattern harvest

Rule candidate: review-prompt
Pattern: a menu row or handler that issues a gateway write without reading useConnected() (offline it must dim, refuse at the sink, and never route the refusal into a failure notice).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

before-folder-menu-online

before-new-menu-online

…line

Items in the folder and New-chat menus now dim, refuse at the sink and carry one
reason row per menu; a folder action refused offline shows a neutral notice and
no longer claims "Folder update failed".

Ported from #9485 onto main's chat-sidebar split (#20524): the gates live in
folderBlocks.tsx, boardLane.tsx and SidebarHeader.tsx, and the sink refusals in
the folders/create/drag hooks. The commit's screenshots are dropped.

Fixes #20736
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f2e3bf87c61799ab2233b8ade559bf619a5e97b1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that a folder collapsed or expanded while offline doesn't flip back without warning when the post-reconnect refetch overwrites the cached-only collapsed flag.

[DESIGN-REVIEWED] f2e3bf8

Description read

[DESCRIPTION-READ] 91cbffb18ffdfa11d20d07cc8c355b31e86fb5bd0406466ef0e0ff8fa1a6f4a2

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of f2e3bf87c61799ab2233b8ade559bf619a5e97b1 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Offline gating is added at seven call sites, but the false "Folder update failed" comes from the shared updateFolderMutation, and two of its callers are still ungated.

Not justified as shipped

  • Item 4 — symptom-level: the description names the cause itself: "every folder write funnels its error into the one danger notice". The change adds if (!connected) to toggleCollapse, moveFolderTo, reorderFolders, createChatInFolder and renameCommit instead. I grepped updateFolderMutation\.mutate: 2 callers are still ungated and will still raise the false failure offline. They are expandFolderAncestors (folders.ts:501, the reveal path) and drag-over auto-expand (dnd/useSidebarDrag.ts:447), both sending collapsed: false.
    Subtraction: put one offline check inside updateFolderMutation (folders.ts). Then delete the separate checks in toggleCollapse, moveFolderTo and renameCommit, and the ancestor-PATCH half of the createChatInFolder check.
    Clears when: the two sibling callers no longer raise "Folder update failed" offline, either through a gate at the mutation or a gate at each caller.
Inventory (9 items) — 6 justified

Intent: while the gateway is offline, folder and New-chat menu writes look unavailable and say why, instead of reporting a false update failure (#20736). FIX.

  1. Folder ⋯ menus, right-click menus and New-menu rows are dimmed, announced as offline, and keep the menu open when clicked — justified
  2. "Move folder to" trigger is dimmed and has an offline tooltip — justified
  3. A status line in each gated menu explains why the rows are dimmed — justified
  4. Rename, move, reorder and create refuse at the handler with a neutral notice — symptom-level, 2 ungated siblings
  5. Offline, collapse/expand changes only the cached state and sends no PATCH — justified
  6. The offline notice clears on reconnect, and "Ask the agent" is hidden while offline — justified
  7. Primary New button loses its press animation and refuses offline — justified
  8. Offline verbs in ChatInput, SessionRow, HistoryPane and SessionTabStrip are now localized — rides along
  9. Offline accessible name changes from "Optimize" to "Optimize prompt" — undeclared

[FIRST-PRINCIPLES-REVIEWED] f2e3bf8

Description read

[DESCRIPTION-READ] 9bb714b20a92dfb1a4a832e57e68fe9017c2a85a5875280adfd468d963e49909

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

UX-level review of f2e3bf87c61799ab2233b8ade559bf619a5e97b1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

Offline, some create paths still look live: the "New chat in folder ›" trigger and the folder + buttons stay full-weight while their sibling rows are dimmed.

Watch

  • "New chat in folder ›" trigger stays bright offline. SidebarHeader.tsx dims each folder row inside the submenu, but not the trigger that opens it. In shot-06 the reader said: "it's odd that 'New chat in folder' works when plain 'New chat' doesn't". The menu again shows two rules at once, which is the confusion this PR set out to remove. This hits every offline use of the New menu. Fix: pass offline to the trigger, the way FolderMoveSubmenu already does.
  • The folder + and "New chat in {name}" buttons only get offlineProps. offlineProps adds a tooltip and an aria state but no visual dim. Shot-04 shows the Research row's + at full weight while offline. A user only finds out it's unavailable by hovering or clicking, which is the "click and watch nothing happen" problem from the PR's own Why. These buttons are on every folder hover. Fix: add the same muted dim the menu rows use.
  • Rename refused offline still leaves the editor open. In shot-04 the reader said "I was still allowed into rename mode before being told it won't work". This only happens when the gateway drops mid-edit, so severity is low. A short inline hint at the editor, instead of only the top notice, would put the reason where the user is looking.

[UX-REVIEWED] f2e3bf8

Description read

[DESCRIPTION-READ] 6354cd67e98bf56f563f76230d1f57eae2a2bb32024b20470e9d9755c14d0322

That sha256 names everything this verdict read: the PR description, plus the 13 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed f2e3bf87c61799ab2233b8ade559bf619a5e97b1 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f2e3bf8

Verdict parsed from the review's SHA-scoped output markers for commit f2e3bf87c61799ab2233b8ade559bf619a5e97b1.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f2e3bf87c61799ab2233b8ade559bf619a5e97b1: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f2e3bf87c61799ab2233b8ade559bf619a5e97b1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f2e3bf8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f2e3bf87c61799ab2233b8ade559bf619a5e97b1: <one-sentence reason>

A new module under website/src/pages trips the feature-map gate; the helper belongs beside offlineProps anyway.

Co-authored-by: rnoack1 <rnoack@amazon.com>
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@iamwhatever
iamwhatever marked this pull request as ready for review October 15, 2026 10:12
@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 15, 2026 10:12
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 15, 2026

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

Batch approval: readiness: passed, no merge conflict, checks green.

@chenmingwei23
chenmingwei23 merged commit 534d1f0 into main Oct 15, 2026
116 of 134 checks passed
@chenmingwei23
chenmingwei23 deleted the replace/9485 branch October 15, 2026 15:43
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 15, 2026
chenmingwei23 pushed a commit that referenced this pull request Oct 16, 2026
…20989)

* fix(library): dim artifact-table writes while the gateway is offline

Star, Delete and the folder menu wrote through the gateway with no connected
check, so an offline click looked like it worked. Split from a larger sweep.

Ported onto the offline primitive #20749 landed: menu rows use offlineMenuRow
and the `offline` dim on DropdownMenuItem, the Move submenu uses
FolderMoveSubmenu's offline/offlineTitle with the pick refused at the caller,
the menu reason is OfflineMenuReason, and the table/field reason row is a named
OfflineReasonRow beside it reusing utils.offline.menu_reason.

Co-authored-by: Joe Guo <12429733+iamwhatever@users.noreply.github.com>

* test(library): run SessionDocPath connected now that the row star reads it

---------

Co-authored-by: Robert Noack <rnoack@amazon.com>
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.

Sidebar folder menus and New-chat menu stay live while the gateway is offline; rename shows a false "Folder update failed"

3 participants