-
Notifications
You must be signed in to change notification settings - Fork 6.6k
refactor(web): composer controls own their look instead of restyling ui components #13209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,11 @@ const formatPendingPrimaryActionLabel = (input: { | |
| return input.questionIndex > 0 ? "Submit answers" : "Submit answer"; | ||
| }; | ||
|
|
||
| // The composer's labeled primary actions (Submit, Refine, Implement) share the send button's | ||
| // message-action pill, so they are composer-owned buttons rather than restyled Buttons. | ||
| const messageActionPillClassName = | ||
| "inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-full bg-message-action font-medium text-base text-message-action-foreground shadow-xs shadow-message-action/24 outline-none hover:bg-message-action-hover focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 disabled:shadow-none sm:text-sm"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shared primitives over custom controls: this class turns several raw Suggested fix: No diff; the fix requires adding a shared Posted via Macroscope — UI Consistency |
||
|
|
||
| const preventPointerFocus: PointerEventHandler<HTMLElement> = (event) => { | ||
| event.preventDefault(); | ||
| }; | ||
|
|
@@ -112,7 +117,6 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ | |
| <Button | ||
| size="icon-sm" | ||
| variant="outline" | ||
| className="rounded-full" | ||
| {...pointerFocusProps} | ||
| onClick={onPreviousPendingQuestion} | ||
| disabled={pendingAction.isResponding} | ||
|
|
@@ -124,7 +128,6 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ | |
| <Button | ||
| size="sm" | ||
| variant="outline" | ||
| className="rounded-full" | ||
| {...pointerFocusProps} | ||
| onClick={onPreviousPendingQuestion} | ||
| disabled={pendingAction.isResponding} | ||
|
|
@@ -133,13 +136,9 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ | |
| </Button> | ||
| ) | ||
| ) : null} | ||
| <Button | ||
| <button | ||
| type="submit" | ||
| size="sm" | ||
| className={cn( | ||
| "rounded-full bg-message-action text-message-action-foreground hover:bg-message-action-hover", | ||
| compact ? "px-3" : "px-4", | ||
| )} | ||
| className={cn(messageActionPillClassName, "h-8 sm:h-7", compact ? "px-3" : "px-4")} | ||
| {...pointerFocusProps} | ||
| disabled={ | ||
| isEnvironmentUnavailable || | ||
|
|
@@ -153,47 +152,44 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({ | |
| isResponding: pendingAction.isResponding, | ||
| questionIndex: pendingAction.questionIndex, | ||
| })} | ||
| </Button> | ||
| </button> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (showPlanFollowUpPrompt) { | ||
| if (promptHasText) { | ||
| return ( | ||
| <Button | ||
| <button | ||
| type="submit" | ||
| size="sm" | ||
| className={cn( | ||
| "rounded-full bg-message-action text-message-action-foreground hover:bg-message-action-hover", | ||
| compact ? "h-9 px-3 sm:h-8" : "h-9 px-4 sm:h-8", | ||
| )} | ||
| className={cn(messageActionPillClassName, "h-9 sm:h-8", compact ? "px-3" : "px-4")} | ||
| {...pointerFocusProps} | ||
| disabled={isSendBusy || isSendDisabled || isConnecting || isEnvironmentUnavailable} | ||
| > | ||
| {isConnecting || isSendBusy ? "Sending..." : "Refine"} | ||
| </Button> | ||
| </button> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div data-chat-composer-implement-actions="true" className="flex items-center justify-end"> | ||
| <Button | ||
| <button | ||
| type="submit" | ||
| size="sm" | ||
| className="h-9 rounded-l-full rounded-r-none bg-message-action px-4 text-message-action-foreground hover:bg-message-action-hover sm:h-8" | ||
| className={cn(messageActionPillClassName, "h-9 rounded-r-none px-4 sm:h-8")} | ||
| {...pointerFocusProps} | ||
| disabled={isSendBusy || isSendDisabled || isConnecting || isEnvironmentUnavailable} | ||
| > | ||
| {isConnecting || isSendBusy ? "Sending..." : "Implement"} | ||
| </Button> | ||
| </button> | ||
| <Menu> | ||
| <MenuTrigger | ||
| render={ | ||
| <Button | ||
| size="sm" | ||
| variant="default" | ||
| className="h-9 rounded-l-none rounded-r-full border-l-message-action-foreground/20 bg-message-action px-2 text-message-action-foreground hover:bg-message-action-hover sm:h-8" | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| messageActionPillClassName, | ||
| "h-9 rounded-l-none border-l border-message-action-foreground/20 px-2 sm:h-8", | ||
| )} | ||
| aria-label="Implementation actions" | ||
| {...pointerFocusProps} | ||
| disabled={isSendBusy || isSendDisabled || isConnecting || isEnvironmentUnavailable} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared primitives over custom controls: this recreates
ui/Buttonandui/SelectTriggerstyling instead of composing those primitives. Add the composer sizes/variants to the UI primitives and haveComposerControldelegate to them.Suggested fix: No diff; the fix requires coordinated primitive variants and component changes.
Posted via Macroscope — UI Consistency