Repository navigation
feat(chat): add MessageParts to render a message's parts - #17
Closed
pratikbuilds wants to merge 1 commit into
Closed
pratikbuilds wants to merge 1 commit into
pratikbuilds wants to merge 1 commit into
Conversation
Every host mapped ConversationPart to components by hand and re-implemented the focus handoff when a decided call folds into the run before it. MessageParts groups parts with groupActivity and renders each kind as its component (Activity, ToolApproval, ToolGroup, MessageContent, Attachments tiles, GeneratedImages, Sources, ConversationNotice), with a render prop per kind to replace any of them. After a decision folds a call away, focus moves to the run's trigger, or to the next waiting call in a batch, instead of falling to the page. The full chat and activity stories and the e2e fixtures use it in place of their own mappings; the e2e specs check that focus never sits on <body> for a frame after a keyboard decision.
Owner
Author
|
Moved upstream: corbitsdev#129 |
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 #16. Part of corbitsdev#94.
Why
Every host maps
ConversationPartto components by hand, and each one re-implements the approval focus handoff. WhengroupActivityfolds a decided call into the run before it, the call's buttons unmount, and without that handoff focus drops to<body>. The oldPartsRendereronly knew the part type that #16 removed.What
MessageParts(src/ui/message-parts.tsx, in the root barrel) groups a message's parts withgroupActivityand renders each kind as its component:ActivityToolApprovalToolGroupMessageContent, usingrenderMarkdownas its render propAttachmentstilesGeneratedImages, withonOpenImageSourcesConversationNoticerenderText,renderActivity,renderStep,renderApproval,renderBatch,renderBlock,renderFiles,renderEvent,renderImages,renderSources. An override can returnundefinedto keep the default ornullto render nothing. A block'sdatabelongs to the host, so blocks render nothing withoutrenderBlock.ActivityTrigger. In a batch that still has waiting calls, it moves to the next waiting call's buttons, wrapping to the first. The handoff waits until the host has recorded the decision inparts, and it never takes focus from an element the person has moved to. A customrenderApprovalorrenderBatchgets the same behaviour through thedecidecallback it receives.streamingdefaults to the enclosingMessage's status.stories/chat/full-chat.stories.tsx(its focus code is removed),stories/chat/activity.stories.tsx, ande2e/fixtures.tsx(the tool-approval and thread scenarios, plus a newtool-batch-approvalscenario).Tests
src/ui/message-parts.test.tsx(16 tests): every part kind, overrides, streaming, image open, and focus after a decision:renderApprovalThe focus tests fail when the handoff is disabled.
Playwright:
e2e/focus.tschecksdocument.activeElementon every frame. The tool-approval, batch-approval and full-chat specs assert that focus is never on<body>for even one frame after a keyboard decision.bun run check,build,dep-guardand the fulltest:e2epass: 126 passed, including the Storybook axe sweep. The known list is unchanged.