Repository navigation
fix(library): dim artifact-table writes while the gateway is offline - #20989
Conversation
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>
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check the new-folder inputs and the gallery rename card: [DESIGN-REVIEWED] 65b3ed2 Description read[DESCRIPTION-READ] efb42204ae3006387dc5491661bbcf6a2e135bba472fdad59c67a3036c528283 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 |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Dragging an artifact onto a folder is still an ungated write offline, while the new table reason row tells the user that writes need a connection. Not justified as shipped
What this change shipsInventory (8 items) — 6 justifiedIntent: let a user see, while the gateway is offline, which library-table writes are unavailable and why, instead of hitting "Failed to fetch". FIX.
[FIRST-PRINCIPLES-REVIEWED] 65b3ed2 Description read[DESCRIPTION-READ] 9e52fbc684265648dfc6d6d698149292e88b1774da0fa8d72615d8d639e2a38b That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS Offline, an unstarred row's star looks exactly as it does online, so the most common write this PR gates still looks live. Watch
Suggestions
[UX-REVIEWED] 65b3ed2 Description read[DESCRIPTION-READ] 537e58e0239abc06a2ef10005c0a2b8a12798c675ea269bc11bce04551c7596b 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
chenmingwei23
left a comment
There was a problem hiding this comment.
Approving: readiness: passed, all lanes green, no outstanding change requests.
Problem / Motivation
Goal: While the gateway is offline, the artifacts library table shows its writes (row star, row Delete, folder Rename / Move / Color / Delete) as unavailable and says why, instead of looking live and then failing.
With the gateway offline, every write control in the library table stays at full weight. Clicking a row's star fires
PATCH /api/artifacts/<slug>/pin, the request cannot land, and the page shows a red "Failed to fetch" banner. The folder ⋯ menu's Rename, Move to folder, Color swatches and Delete look equally clickable. The chat sidebar beside it already dims these writes and shows a reason row (#20749), so one dashboard teaches two rules.Why it matters
A user who learned that a dimmed sidebar row means "not now" has no reason to read a full-weight star or Delete as unavailable, so the only way to find out is to click it and meet an error that reads like a server failure. A folder rename typed while the gateway drops is committed into a write that cannot land, and the typed name is lost with the closed field.
Not a goal
FolderMoveSubmenuorDropdownMenuItem; this PR only uses the offline API fix(sidebar): dim folder and New-menu writes while the gateway is offline #20749 added.What changed (motivation → approach → change)
Symptom: library writes stay live offline and fail with "Failed to fetch". Root cause:
LibraryTable.tsxnever reads the connection flag. Rule applied (same as #20749): gate the write at its sink, dim its entry control, and give the reason a visible channel.FolderMenu): Rename and Delete useofflineMenuRow(dim, offline tooltip and accessible name, refusedonSelectkeeps the menu open); Move to folder passesFolderMoveSubmenu'soffline/offlineTitleand the pick is refused at this caller; the colour swatch strip dims once and its buttons aredisabled;OfflineMenuReasonrenders last.ArtifactRow's star and Delete andSessionDocStardim, carryofflineProps, and return before the write. The click still stops propagation so a refused click does not open the artifact.LibraryTableandLibraryTreerender a sticky reason row after the table (a coarse pointer opens no tooltip). It isOfflineReasonRow, a named export besideOfflineMenuReasonincomponents/OfflineMenuReason.tsx, reusingutils.offline.menu_reason.FolderNameInputrefuses its blur commit offline, so the editor and its draft stay mounted, and shows a note (linked byaria-describedby) that closing the field discards the name.utils.offlinekeys (star_artifacts,delete_artifacts,save_folder_names,name_not_saved_keep_field_open) inen.manual.jsonand the 12 locale catalogues. ja/ru style tests guard the{{action}}grammar of these verbs.Ported from #10832 onto main after #20749: the fork's own
dimmedprop,OfflineReasonRow.tsxandofflineVerb(cannot-expand) submenu are dropped in favour of the primitive main now carries.Backwards compatibility
Compatible: all changes are optional props or offline-only branches; online behaviour of every control is unchanged.
Removes nothing: offline the dimmed controls refuse a write that already could not reach the gateway; no data, key, route or public function is removed.
Tests
LibraryTable.folderMenuOffline.test.tsx(new): folder-menu rows arearia-disabled, dimmed (Delete drops its red), fire no write and keep the menu open; the Move trigger is dimmed with its tooltip and a pick from it writes nothing; swatches dim once and fire no write; row star / Delete and the session-doc star refuse with one dim layer and a tooltip; the table and tree render the reason row last;FolderNameInputholds an offline draft, abandons an empty one, and lets Escape out. Each case has a connected control asserting the write still happens.ArtifactsPage.test.tsx,ArtifactsPageCoverage.test.tsx: suites that assert a write reaches the server now seed a connected gateway.jaStyle.test.ts,ruStyle.test.ts:utils.offlineaction verbs must fit the{{action}}frame (ja: no の-nominalisation without を; ru: infinitive).Local:
tsc -p tsconfig.app.jsonclean; ESLint clean on touched files; 125 vitest files / 1,905 tests pass acrosssrc/components,src/test/ArtifactsPage*,src/test/FolderMoveSubmenu*and the sidebar offline suites;i18n-check.mjs,check-i18n-keys,check-i18n-strings, restyle ratchet, phantom-classes, theme-colors, ui-index check and the feature-map gate pass.Manual verification
Built SPA (main and this branch) served with stubbed
/api/**; the/api/wsstub closes the socket (offline) or keeps it open (online). Offline on main, clicking an unstarred row's star sentPATCH /api/artifacts/cr-queue/pinand showed "Failed to fetch"; on this branch it sent nothing. Online on this branch the same click sent the PATCH. A folder rename committed after the socket dropped sentPATCH /api/artifact-folders/faon main and closed the field; on this branch it sent nothing and kept the draft.Screenshots / video
Table, offline, after clicking a row star — before (main) / after:
Folder ⋯ menu, offline — before (main) / after:
Folder rename while the gateway drops mid-edit (opened online, typed "Quarterly reports", gateway dropped, Enter) — before (main) / after:
Session document ("From your chats") star, offline — before (main) / after:
Online after (unchanged controls)
Related Issues
Fixes #20988
Replaces #10832 — thanks @rnoack1, whose change this is; the commit keeps their authorship. Builds on the offline primitive from #20749.
Pattern harvest
Rule candidate: review-prompt
Pattern: a dashboard control that writes to the gateway (api.* mutation in an onClick/onSelect) with no
useConnectedgate at the sink or offline dim on the control.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.