Repository navigation
refactor(site/src/pages/AgentsPage): make UploadState a discriminated union - #29901
Closed
DanielleMaywood wants to merge 4 commits into
Closed
DanielleMaywood wants to merge 4 commits into
DanielleMaywood wants to merge 4 commits into
Conversation
DanielleMaywood
force-pushed
the
nullability/chat-input
branch
from
September 29, 2026 14:29
b008dba to
064e2a8
Compare
DanielleMaywood
force-pushed
the
nullability/upload-state-union
branch
from
September 29, 2026 14:41
5d84124 to
ebe1a6e
Compare
DanielleMaywood
force-pushed
the
nullability/chat-input
branch
from
October 6, 2026 08:07
d8a8364 to
e1401d6
Compare
… props AgentChatPage, AgentChatPageView, ChatPageContent, AgentCreateForm and AgentChatInput always pass the composer, page shell, attachment preview and skills menu props below, but the receiving components still declared them optional and defaulted or guarded them. Make them required and drop the dead defaults and guards: AgentChatPageView and its loading view props, ChatPageTimeline and ChatPageInput editor, MCP and loading props, AgentChatInput initialValue/onContentChange/plan mode/catalog loading, ChatMessageInput, SkillsTriggerMenu and AttachmentPreview callbacks and flags. ChatMessageInput always autofocuses, so its autoFocus prop is removed. Tests and stories now pass the values production sends; the story for plan mode without a toggle handler is removed.
…n the indicator (#29905)
DanielleMaywood
force-pushed
the
nullability/chat-input
branch
from
October 6, 2026 11:13
e1401d6 to
42a5dc8
Compare
DanielleMaywood
force-pushed
the
nullability/upload-state-union
branch
from
October 6, 2026 11:18
ebe1a6e to
01de81e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #29890.
Part of the AgentsPage nullability cleanup; see #29888 for the methodology.
UploadState(AttachmentPreview.tsx) was{ status; fileId?; error?; draftWarning? }, so every consumer had to recheckfileIdafter checkingstatus === "uploaded". It is now a discriminated union:uploadedrequiresfileId: string,errorrequireserror: string, andpending/processing/uploadinghave neither.draftWarning?stays optional on every variant. It is set while pending/uploading and is not cleared when the upload later fails, so it can appear onerrortoo.status === "uploaded" && state.fileIdchecks inuseFileAttachments.ts(x2),AgentCreateForm.tsxandChatPageContent.tsxare now juststatus === "uploaded". The tooltip's?? "Upload failed"fallback is removed.useChatDraftAttachments.tskeeps its mutable registry/view types. A newuploadStateFromViewhelper is the one place that converts a view into anUploadState. It keeps the old fallbacks:uploadedwith nofileIdbecomes anerrorstate (previously it showed as uploaded and was silently dropped at send), anderrorwith no message uses "Upload failed". No producer reaches either case.status === "error"before readingerror. Fixtures and stories already matched the new type.No producer creates
uploadedwithout afileId: uploads useresult.id, restored attachments skip entries with nofileId, edit mode only setsuploadedwhenfile_idis present, and restored draft records must have a stringfileId.Verified:
pnpm lint:types,pnpm check,pnpm lint:oxlint,pnpm lint:compiler,pnpm lint:knip,pnpm test src/pages/AgentsPage(1617 passed), andpnpm test:storybookonAttachmentPreview.stories.tsxandAgentChatInput.stories.tsx(77 passed).Plan excerpt
Analysed on a local, unpushed merge of all cleanup branches (
/home/coder/wt/topdown); ranking script/home/coder/nullflow/topdown.cjs. After the bottom-up PRs only 43 dead slots remain, so what's left is nullability that is real at its origin. Two read-only agents reviewed the top origins in code. Guard counts from the tool overstate the win: many "guards" are real branches (loading, no workspace, first/last row).UploadStateas a discriminated union (uploadedhasfileId,errorhaserror)status === "uploaded" && fileIdThis PR was generated by Coder Agents on behalf of @DanielleMaywood.