| ... | ... | @@ -31,6 +31,7 @@ import { |
| 31 | 31 | } from "@t3tools/shared/model"; |
| 32 | 32 | import { |
| 33 | 33 | memo, |
| 34 | startTransition, |
| 34 | 35 | useCallback, |
| 35 | 36 | useEffect, |
| 36 | 37 | useLayoutEffect, |
| ... | ... | @@ -89,6 +90,7 @@ import { |
| 89 | 90 | } from "../pendingUserInput"; |
| 90 | 91 | import { useStore } from "../store"; |
| 91 | 92 | import { |
| 93 | buildCollapsedProposedPlanPreviewMarkdown, |
| 92 | 94 | buildPlanImplementationThreadTitle, |
| 93 | 95 | buildPlanImplementationPrompt, |
| 94 | 96 | buildProposedPlanMarkdownFilename, |
| ... | ... | @@ -96,6 +98,7 @@ import { |
| 96 | 98 | normalizePlanMarkdownForExport, |
| 97 | 99 | proposedPlanTitle, |
| 98 | 100 | resolvePlanFollowUpSubmission, |
| 101 | stripDisplayedPlanMarkdown, |
| 99 | 102 | } from "../proposedPlan"; |
| 100 | 103 | import { truncateTitle } from "../truncateTitle"; |
| 101 | 104 | import { |
| ... | ... | @@ -201,11 +204,7 @@ import { Toggle } from "./ui/toggle"; |
| 201 | 204 | import { SidebarTrigger } from "./ui/sidebar"; |
| 202 | 205 | import { newCommandId, newMessageId, newThreadId } from "~/lib/utils"; |
| 203 | 206 | import { readNativeApi } from "~/nativeApi"; |
| 204 | | import { |
| 205 | | getAppModelOptions, |
| 206 | | resolveAppModelSelection, |
| 207 | | useAppSettings, |
| 208 | | } from "../appSettings"; |
| 207 | import { getAppModelOptions, resolveAppModelSelection, useAppSettings } from "../appSettings"; |
| 209 | 208 | import { |
| 210 | 209 | type ComposerImageAttachment, |
| 211 | 210 | type DraftThreadEnvMode, |
| ... | ... | @@ -292,8 +291,6 @@ function workToneClass(tone: "thinking" | "tool" | "info" | "error"): string { |
| 292 | 291 | return "text-muted-foreground/40"; |
| 293 | 292 | } |
| 294 | 293 | |
| 295 | | |
| 296 | | |
| 297 | 294 | interface ExpandedImageItem { |
| 298 | 295 | src: string; |
| 299 | 296 | name: string; |
| ... | ... | @@ -1963,8 +1960,6 @@ export default function ChatView({ threadId }: ChatViewProps) { |
| 1963 | 1960 | planSidebarDismissedForTurnRef.current = null; |
| 1964 | 1961 | }, [activeThread?.id]); |
| 1965 | 1962 | |
| 1966 | | |
| 1967 | | |
| 1968 | 1963 | useEffect(() => { |
| 1969 | 1964 | if (!composerMenuOpen) { |
| 1970 | 1965 | setComposerHighlightedItemId(null); |
| ... | ... | @@ -2688,9 +2683,7 @@ export default function ChatView({ threadId }: ChatViewProps) { |
| 2688 | 2683 | ...(selectedModelOptionsForDispatch |
| 2689 | 2684 | ? { modelOptions: selectedModelOptionsForDispatch } |
| 2690 | 2685 | : {}), |
| 2691 | | ...(providerOptionsForDispatch |
| 2692 | | ? { providerOptions: providerOptionsForDispatch } |
| 2693 | | : {}), |
| 2686 | ...(providerOptionsForDispatch ? { providerOptions: providerOptionsForDispatch } : {}), |
| 2694 | 2687 | provider: selectedProvider, |
| 2695 | 2688 | assistantDeliveryMode: settings.enableAssistantStreaming ? "streaming" : "buffered", |
| 2696 | 2689 | runtimeMode, |
| ... | ... | @@ -2968,9 +2961,7 @@ export default function ChatView({ threadId }: ChatViewProps) { |
| 2968 | 2961 | ...(selectedModelOptionsForDispatch |
| 2969 | 2962 | ? { modelOptions: selectedModelOptionsForDispatch } |
| 2970 | 2963 | : {}), |
| 2971 | | ...(providerOptionsForDispatch |
| 2972 | | ? { providerOptions: providerOptionsForDispatch } |
| 2973 | | : {}), |
| 2964 | ...(providerOptionsForDispatch ? { providerOptions: providerOptionsForDispatch } : {}), |
| 2974 | 2965 | assistantDeliveryMode: settings.enableAssistantStreaming ? "streaming" : "buffered", |
| 2975 | 2966 | runtimeMode, |
| 2976 | 2967 | interactionMode: nextInteractionMode, |
| ... | ... | @@ -3079,9 +3070,7 @@ export default function ChatView({ threadId }: ChatViewProps) { |
| 3079 | 3070 | ...(selectedModelOptionsForDispatch |
| 3080 | 3071 | ? { modelOptions: selectedModelOptionsForDispatch } |
| 3081 | 3072 | : {}), |
| 3082 | | ...(providerOptionsForDispatch |
| 3083 | | ? { providerOptions: providerOptionsForDispatch } |
| 3084 | | : {}), |
| 3073 | ...(providerOptionsForDispatch ? { providerOptions: providerOptionsForDispatch } : {}), |
| 3085 | 3074 | assistantDeliveryMode: settings.enableAssistantStreaming ? "streaming" : "buffered", |
| 3086 | 3075 | runtimeMode, |
| 3087 | 3076 | interactionMode: "default", |
| ... | ... | @@ -3503,513 +3492,537 @@ export default function ChatView({ threadId }: ChatViewProps) { |
| 3503 | 3492 | <div className="flex min-h-0 min-w-0 flex-1"> |
| 3504 | 3493 | {/* Chat column */} |
| 3505 | 3494 | <div className="flex min-h-0 min-w-0 flex-1 flex-col"> |
| 3506 | | |
| 3507 | | {/* Messages */} |
| 3508 | | <div |
| 3509 | | ref={setMessagesScrollContainerRef} |
| 3510 | | className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain px-3 py-3 sm:px-5 sm:py-4" |
| 3511 | | onScroll={onMessagesScroll} |
| 3512 | | onClickCapture={onMessagesClickCapture} |
| 3513 | | onWheel={onMessagesWheel} |
| 3514 | | onPointerDown={onMessagesPointerDown} |
| 3515 | | onPointerUp={onMessagesPointerUp} |
| 3516 | | onPointerCancel={onMessagesPointerCancel} |
| 3517 | | onTouchStart={onMessagesTouchStart} |
| 3518 | | onTouchMove={onMessagesTouchMove} |
| 3519 | | onTouchEnd={onMessagesTouchEnd} |
| 3520 | | onTouchCancel={onMessagesTouchEnd} |
| 3521 | | > |
| 3522 | | <MessagesTimeline |
| 3523 | | key={activeThread.id} |
| 3524 | | hasMessages={timelineEntries.length > 0} |
| 3525 | | isWorking={isWorking} |
| 3526 | | activeTurnInProgress={isWorking || !latestTurnSettled} |
| 3527 | | activeTurnStartedAt={activeWorkStartedAt} |
| 3528 | | scrollContainer={messagesScrollElement} |
| 3529 | | timelineEntries={timelineEntries} |
| 3530 | | completionDividerBeforeEntryId={completionDividerBeforeEntryId} |
| 3531 | | completionSummary={completionSummary} |
| 3532 | | turnDiffSummaryByAssistantMessageId={turnDiffSummaryByAssistantMessageId} |
| 3533 | | nowIso={nowIso} |
| 3534 | | expandedWorkGroups={expandedWorkGroups} |
| 3535 | | onToggleWorkGroup={onToggleWorkGroup} |
| 3536 | | onOpenTurnDiff={onOpenTurnDiff} |
| 3537 | | revertTurnCountByUserMessageId={revertTurnCountByUserMessageId} |
| 3538 | | onRevertUserMessage={onRevertUserMessage} |
| 3539 | | isRevertingCheckpoint={isRevertingCheckpoint} |
| 3540 | | onImageExpand={onExpandTimelineImage} |
| 3541 | | markdownCwd={gitCwd ?? undefined} |
| 3542 | | resolvedTheme={resolvedTheme} |
| 3543 | | workspaceRoot={activeProject?.cwd ?? undefined} |
| 3544 | | /> |
| 3545 | | </div> |
| 3546 | | |
| 3547 | | {/* Input bar */} |
| 3548 | | <div className={cn("px-3 pt-1.5 sm:px-5 sm:pt-2", isGitRepo ? "pb-1" : "pb-3 sm:pb-4")}> |
| 3549 | | <form |
| 3550 | | ref={composerFormRef} |
| 3551 | | onSubmit={onSend} |
| 3552 | | className="mx-auto w-full min-w-0 max-w-3xl" |
| 3553 | | data-chat-composer-form="true" |
| 3554 | | > |
| 3495 | {/* Messages */} |
| 3555 | 3496 | <div |
| 3556 | | className={`group rounded-[20px] border bg-card transition-colors duration-200 focus-within:border-ring/45 ${ |
| 3557 | | isDragOverComposer ? "border-primary/70 bg-accent/30" : "border-border" |
| 3558 | | }`} |
| 3559 | | onDragEnter={onComposerDragEnter} |
| 3560 | | onDragOver={onComposerDragOver} |
| 3561 | | onDragLeave={onComposerDragLeave} |
| 3562 | | onDrop={onComposerDrop} |
| 3497 | ref={setMessagesScrollContainerRef} |
| 3498 | className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain px-3 py-3 sm:px-5 sm:py-4" |
| 3499 | onScroll={onMessagesScroll} |
| 3500 | onClickCapture={onMessagesClickCapture} |
| 3501 | onWheel={onMessagesWheel} |
| 3502 | onPointerDown={onMessagesPointerDown} |
| 3503 | onPointerUp={onMessagesPointerUp} |
| 3504 | onPointerCancel={onMessagesPointerCancel} |
| 3505 | onTouchStart={onMessagesTouchStart} |
| 3506 | onTouchMove={onMessagesTouchMove} |
| 3507 | onTouchEnd={onMessagesTouchEnd} |
| 3508 | onTouchCancel={onMessagesTouchEnd} |
| 3563 | 3509 | > |
| 3564 | | {activePendingApproval ? ( |
| 3565 | | <div className="rounded-t-[19px] border-b border-border/65 bg-muted/20"> |
| 3566 | | <ComposerPendingApprovalPanel |
| 3567 | | approval={activePendingApproval} |
| 3568 | | pendingCount={pendingApprovals.length} |
| 3569 | | /> |
| 3570 | | </div> |
| 3571 | | ) : pendingUserInputs.length > 0 ? ( |
| 3572 | | <div className="rounded-t-[19px] border-b border-border/65 bg-muted/20"> |
| 3573 | | <ComposerPendingUserInputPanel |
| 3574 | | pendingUserInputs={pendingUserInputs} |
| 3575 | | respondingRequestIds={respondingUserInputRequestIds} |
| 3576 | | answers={activePendingDraftAnswers} |
| 3577 | | questionIndex={activePendingQuestionIndex} |
| 3578 | | onSelectOption={onSelectActivePendingUserInputOption} |
| 3579 | | onAdvance={onAdvanceActivePendingUserInput} |
| 3580 | | /> |
| 3581 | | </div> |
| 3582 | | ) : showPlanFollowUpPrompt && activeProposedPlan ? ( |
| 3583 | | <div className="rounded-t-[19px] border-b border-border/65 bg-muted/20"> |
| 3584 | | <ComposerPlanFollowUpBanner |
| 3585 | | key={activeProposedPlan.id} |
| 3586 | | planTitle={proposedPlanTitle(activeProposedPlan.planMarkdown) ?? null} |
| 3587 | | /> |
| 3588 | | </div> |
| 3589 | | ) : null} |
| 3510 | <MessagesTimeline |
| 3511 | key={activeThread.id} |
| 3512 | hasMessages={timelineEntries.length > 0} |
| 3513 | isWorking={isWorking} |
| 3514 | activeTurnInProgress={isWorking || !latestTurnSettled} |
| 3515 | activeTurnStartedAt={activeWorkStartedAt} |
| 3516 | scrollContainer={messagesScrollElement} |
| 3517 | timelineEntries={timelineEntries} |
| 3518 | completionDividerBeforeEntryId={completionDividerBeforeEntryId} |
| 3519 | completionSummary={completionSummary} |
| 3520 | turnDiffSummaryByAssistantMessageId={turnDiffSummaryByAssistantMessageId} |
| 3521 | nowIso={nowIso} |
| 3522 | expandedWorkGroups={expandedWorkGroups} |
| 3523 | onToggleWorkGroup={onToggleWorkGroup} |
| 3524 | onOpenTurnDiff={onOpenTurnDiff} |
| 3525 | revertTurnCountByUserMessageId={revertTurnCountByUserMessageId} |
| 3526 | onRevertUserMessage={onRevertUserMessage} |
| 3527 | isRevertingCheckpoint={isRevertingCheckpoint} |
| 3528 | onImageExpand={onExpandTimelineImage} |
| 3529 | markdownCwd={gitCwd ?? undefined} |
| 3530 | resolvedTheme={resolvedTheme} |
| 3531 | workspaceRoot={activeProject?.cwd ?? undefined} |
| 3532 | /> |
| 3533 | </div> |
| 3590 | 3534 | |
| 3591 | | {/* Textarea area */} |
| 3592 | | <div |
| 3593 | | className={cn( |
| 3594 | | "relative px-3 pb-2 sm:px-4", |
| 3595 | | hasComposerHeader ? "pt-2.5 sm:pt-3" : "pt-3.5 sm:pt-4", |
| 3596 | | )} |
| 3535 | {/* Input bar */} |
| 3536 | <div className={cn("px-3 pt-1.5 sm:px-5 sm:pt-2", isGitRepo ? "pb-1" : "pb-3 sm:pb-4")}> |
| 3537 | <form |
| 3538 | ref={composerFormRef} |
| 3539 | onSubmit={onSend} |
| 3540 | className="mx-auto w-full min-w-0 max-w-3xl" |
| 3541 | data-chat-composer-form="true" |
| 3597 | 3542 | > |
| 3598 | | {composerMenuOpen && !isComposerApprovalState && ( |
| 3599 | | <div className="absolute inset-x-0 bottom-full z-20 mb-2 px-1"> |
| 3600 | | <ComposerCommandMenu |
| 3601 | | items={composerMenuItems} |
| 3602 | | resolvedTheme={resolvedTheme} |
| 3603 | | isLoading={isComposerMenuLoading} |
| 3604 | | triggerKind={composerTriggerKind} |
| 3605 | | activeItemId={activeComposerMenuItem?.id ?? null} |
| 3606 | | onHighlightedItemChange={onComposerMenuItemHighlighted} |
| 3607 | | onSelect={onSelectComposerItem} |
| 3608 | | /> |
| 3609 | | </div> |
| 3610 | | )} |
| 3611 | | |
| 3612 | | {!isComposerApprovalState && pendingUserInputs.length === 0 && composerImages.length > 0 && ( |
| 3613 | | <div className="mb-3 flex flex-wrap gap-2"> |
| 3614 | | {composerImages.map((image) => ( |
| 3615 | | <div |
| 3616 | | key={image.id} |
| 3617 | | className="relative h-16 w-16 overflow-hidden rounded-lg border border-border/80 bg-background" |
| 3618 | | > |
| 3619 | | {image.previewUrl ? ( |
| 3620 | | <button |
| 3621 | | type="button" |
| 3622 | | className="h-full w-full cursor-zoom-in" |
| 3623 | | aria-label={`Preview ${image.name}`} |
| 3624 | | onClick={() => { |
| 3625 | | const preview = buildExpandedImagePreview(composerImages, image.id); |
| 3626 | | if (!preview) return; |
| 3627 | | setExpandedImage(preview); |
| 3628 | | }} |
| 3629 | | > |
| 3630 | | <img |
| 3631 | | src={image.previewUrl} |
| 3632 | | alt={image.name} |
| 3633 | | className="h-full w-full object-cover" |
| 3634 | | /> |
| 3635 | | </button> |
| 3636 | | ) : ( |
| 3637 | | <div className="flex h-full w-full items-center justify-center px-1 text-center text-[10px] text-muted-foreground/70"> |
| 3638 | | {image.name} |
| 3639 | | </div> |
| 3640 | | )} |
| 3641 | | {nonPersistedComposerImageIdSet.has(image.id) && ( |
| 3642 | | <Tooltip> |
| 3643 | | <TooltipTrigger |
| 3644 | | render={ |
| 3645 | | <span |
| 3646 | | role="img" |
| 3647 | | aria-label="Draft attachment may not persist" |
| 3648 | | className="absolute left-1 top-1 inline-flex items-center justify-center rounded bg-background/85 p-0.5 text-amber-600" |
| 3649 | | > |
| 3650 | | <CircleAlertIcon className="size-3" /> |
| 3651 | | </span> |
| 3652 | | } |
| 3653 | | /> |
| 3654 | | <TooltipPopup |
| 3655 | | side="top" |
| 3656 | | className="max-w-64 whitespace-normal leading-tight" |
| 3657 | | > |
| 3658 | | Draft attachment could not be saved locally and may be lost on |
| 3659 | | navigation. |
| 3660 | | </TooltipPopup> |
| 3661 | | </Tooltip> |
| 3662 | | )} |
| 3663 | | <Button |
| 3664 | | variant="ghost" |
| 3665 | | size="icon-xs" |
| 3666 | | className="absolute right-1 top-1 bg-background/80 hover:bg-background/90" |
| 3667 | | onClick={() => removeComposerImage(image.id)} |
| 3668 | | aria-label={`Remove ${image.name}`} |
| 3669 | | > |
| 3670 | | <XIcon /> |
| 3671 | | </Button> |
| 3672 | | </div> |
| 3673 | | ))} |
| 3674 | | </div> |
| 3675 | | )} |
| 3676 | | <ComposerPromptEditor |
| 3677 | | ref={composerEditorRef} |
| 3678 | | value={ |
| 3679 | | isComposerApprovalState |
| 3680 | | ? "" |
| 3681 | | : activePendingProgress |
| 3682 | | ? activePendingProgress.customAnswer |
| 3683 | | : prompt |
| 3684 | | } |
| 3685 | | cursor={composerCursor} |
| 3686 | | onChange={onPromptChange} |
| 3687 | | onCommandKeyDown={onComposerCommandKey} |
| 3688 | | onPaste={onComposerPaste} |
| 3689 | | placeholder={ |
| 3690 | | isComposerApprovalState |
| 3691 | | ? (activePendingApproval?.detail ?? "Resolve this approval request to continue") |
| 3692 | | : activePendingProgress |
| 3693 | | ? "Type your own answer, or leave this blank to use the selected option" |
| 3694 | | : showPlanFollowUpPrompt && activeProposedPlan |
| 3695 | | ? "Add feedback to refine the plan, or leave this blank to implement it" |
| 3696 | | : phase === "disconnected" |
| 3697 | | ? "Ask for follow-up changes or attach images" |
| 3698 | | : "Ask anything, @tag files/folders, or use /model" |
| 3699 | | } |
| 3700 | | disabled={isConnecting || isComposerApprovalState} |
| 3701 | | /> |
| 3702 | | </div> |
| 3703 | | |
| 3704 | | {/* Bottom toolbar */} |
| 3705 | | {activePendingApproval ? ( |
| 3706 | | <div className="flex items-center justify-end gap-2 px-2.5 pb-2.5 sm:px-3 sm:pb-3"> |
| 3707 | | <ComposerPendingApprovalActions |
| 3708 | | requestId={activePendingApproval.requestId} |
| 3709 | | isResponding={respondingRequestIds.includes(activePendingApproval.requestId)} |
| 3710 | | onRespondToApproval={onRespondToApproval} |
| 3711 | | /> |
| 3712 | | </div> |
| 3713 | | ) : ( |
| 3714 | 3543 | <div |
| 3715 | | data-chat-composer-footer="true" |
| 3716 | | className={cn( |
| 3717 | | "flex items-center justify-between px-2.5 pb-2.5 sm:px-3 sm:pb-3", |
| 3718 | | isComposerFooterCompact ? "gap-1.5" : "flex-wrap gap-2 sm:flex-nowrap sm:gap-0", |
| 3719 | | )} |
| 3544 | className={`group rounded-[20px] border bg-card transition-colors duration-200 focus-within:border-ring/45 ${ |
| 3545 | isDragOverComposer ? "border-primary/70 bg-accent/30" : "border-border" |
| 3546 | }`} |
| 3547 | onDragEnter={onComposerDragEnter} |
| 3548 | onDragOver={onComposerDragOver} |
| 3549 | onDragLeave={onComposerDragLeave} |
| 3550 | onDrop={onComposerDrop} |
| 3720 | 3551 | > |
| 3552 | {activePendingApproval ? ( |
| 3553 | <div className="rounded-t-[19px] border-b border-border/65 bg-muted/20"> |
| 3554 | <ComposerPendingApprovalPanel |
| 3555 | approval={activePendingApproval} |
| 3556 | pendingCount={pendingApprovals.length} |
| 3557 | /> |
| 3558 | </div> |
| 3559 | ) : pendingUserInputs.length > 0 ? ( |
| 3560 | <div className="rounded-t-[19px] border-b border-border/65 bg-muted/20"> |
| 3561 | <ComposerPendingUserInputPanel |
| 3562 | pendingUserInputs={pendingUserInputs} |
| 3563 | respondingRequestIds={respondingUserInputRequestIds} |
| 3564 | answers={activePendingDraftAnswers} |
| 3565 | questionIndex={activePendingQuestionIndex} |
| 3566 | onSelectOption={onSelectActivePendingUserInputOption} |
| 3567 | onAdvance={onAdvanceActivePendingUserInput} |
| 3568 | /> |
| 3569 | </div> |
| 3570 | ) : showPlanFollowUpPrompt && activeProposedPlan ? ( |
| 3571 | <div className="rounded-t-[19px] border-b border-border/65 bg-muted/20"> |
| 3572 | <ComposerPlanFollowUpBanner |
| 3573 | key={activeProposedPlan.id} |
| 3574 | planTitle={proposedPlanTitle(activeProposedPlan.planMarkdown) ?? null} |
| 3575 | /> |
| 3576 | </div> |
| 3577 | ) : null} |
| 3578 | |
| 3579 | {/* Textarea area */} |
| 3721 | 3580 | <div |
| 3722 | 3581 | className={cn( |
| 3723 | | "flex min-w-0 flex-1 items-center", |
| 3724 | | isComposerFooterCompact |
| 3725 | | ? "gap-1 overflow-hidden" |
| 3726 | | : "gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden sm:min-w-max sm:overflow-visible", |
| 3582 | "relative px-3 pb-2 sm:px-4", |
| 3583 | hasComposerHeader ? "pt-2.5 sm:pt-3" : "pt-3.5 sm:pt-4", |
| 3727 | 3584 | )} |
| 3728 | 3585 | > |
| 3729 | | {/* Provider/model picker */} |
| 3730 | | <ProviderModelPicker |
| 3731 | | compact={isComposerFooterCompact} |
| 3732 | | provider={selectedProvider} |
| 3733 | | model={selectedModelForPickerWithCustomFallback} |
| 3734 | | lockedProvider={lockedProvider} |
| 3735 | | modelOptionsByProvider={modelOptionsByProvider} |
| 3736 | | onProviderModelChange={onProviderModelSelect} |
| 3586 | {composerMenuOpen && !isComposerApprovalState && ( |
| 3587 | <div className="absolute inset-x-0 bottom-full z-20 mb-2 px-1"> |
| 3588 | <ComposerCommandMenu |
| 3589 | items={composerMenuItems} |
| 3590 | resolvedTheme={resolvedTheme} |
| 3591 | isLoading={isComposerMenuLoading} |
| 3592 | triggerKind={composerTriggerKind} |
| 3593 | activeItemId={activeComposerMenuItem?.id ?? null} |
| 3594 | onHighlightedItemChange={onComposerMenuItemHighlighted} |
| 3595 | onSelect={onSelectComposerItem} |
| 3596 | /> |
| 3597 | </div> |
| 3598 | )} |
| 3599 | |
| 3600 | {!isComposerApprovalState && |
| 3601 | pendingUserInputs.length === 0 && |
| 3602 | composerImages.length > 0 && ( |
| 3603 | <div className="mb-3 flex flex-wrap gap-2"> |
| 3604 | {composerImages.map((image) => ( |
| 3605 | <div |
| 3606 | key={image.id} |
| 3607 | className="relative h-16 w-16 overflow-hidden rounded-lg border border-border/80 bg-background" |
| 3608 | > |
| 3609 | {image.previewUrl ? ( |
| 3610 | <button |
| 3611 | type="button" |
| 3612 | className="h-full w-full cursor-zoom-in" |
| 3613 | aria-label={`Preview ${image.name}`} |
| 3614 | onClick={() => { |
| 3615 | const preview = buildExpandedImagePreview( |
| 3616 | composerImages, |
| 3617 | image.id, |
| 3618 | ); |
| 3619 | if (!preview) return; |
| 3620 | setExpandedImage(preview); |
| 3621 | }} |
| 3622 | > |
| 3623 | <img |
| 3624 | src={image.previewUrl} |
| 3625 | alt={image.name} |
| 3626 | className="h-full w-full object-cover" |
| 3627 | /> |
| 3628 | </button> |
| 3629 | ) : ( |
| 3630 | <div className="flex h-full w-full items-center justify-center px-1 text-center text-[10px] text-muted-foreground/70"> |
| 3631 | {image.name} |
| 3632 | </div> |
| 3633 | )} |
| 3634 | {nonPersistedComposerImageIdSet.has(image.id) && ( |
| 3635 | <Tooltip> |
| 3636 | <TooltipTrigger |
| 3637 | render={ |
| 3638 | <span |
| 3639 | role="img" |
| 3640 | aria-label="Draft attachment may not persist" |
| 3641 | className="absolute left-1 top-1 inline-flex items-center justify-center rounded bg-background/85 p-0.5 text-amber-600" |
| 3642 | > |
| 3643 | <CircleAlertIcon className="size-3" /> |
| 3644 | </span> |
| 3645 | } |
| 3646 | /> |
| 3647 | <TooltipPopup |
| 3648 | side="top" |
| 3649 | className="max-w-64 whitespace-normal leading-tight" |
| 3650 | > |
| 3651 | Draft attachment could not be saved locally and may be lost on |
| 3652 | navigation. |
| 3653 | </TooltipPopup> |
| 3654 | </Tooltip> |
| 3655 | )} |
| 3656 | <Button |
| 3657 | variant="ghost" |
| 3658 | size="icon-xs" |
| 3659 | className="absolute right-1 top-1 bg-background/80 hover:bg-background/90" |
| 3660 | onClick={() => removeComposerImage(image.id)} |
| 3661 | aria-label={`Remove ${image.name}`} |
| 3662 | > |
| 3663 | <XIcon /> |
| 3664 | </Button> |
| 3665 | </div> |
| 3666 | ))} |
| 3667 | </div> |
| 3668 | )} |
| 3669 | <ComposerPromptEditor |
| 3670 | ref={composerEditorRef} |
| 3671 | value={ |
| 3672 | isComposerApprovalState |
| 3673 | ? "" |
| 3674 | : activePendingProgress |
| 3675 | ? activePendingProgress.customAnswer |
| 3676 | : prompt |
| 3677 | } |
| 3678 | cursor={composerCursor} |
| 3679 | onChange={onPromptChange} |
| 3680 | onCommandKeyDown={onComposerCommandKey} |
| 3681 | onPaste={onComposerPaste} |
| 3682 | placeholder={ |
| 3683 | isComposerApprovalState |
| 3684 | ? (activePendingApproval?.detail ?? |
| 3685 | "Resolve this approval request to continue") |
| 3686 | : activePendingProgress |
| 3687 | ? "Type your own answer, or leave this blank to use the selected option" |
| 3688 | : showPlanFollowUpPrompt && activeProposedPlan |
| 3689 | ? "Add feedback to refine the plan, or leave this blank to implement it" |
| 3690 | : phase === "disconnected" |
| 3691 | ? "Ask for follow-up changes or attach images" |
| 3692 | : "Ask anything, @tag files/folders, or use /model" |
| 3693 | } |
| 3694 | disabled={isConnecting || isComposerApprovalState} |
| 3737 | 3695 | /> |
| 3696 | </div> |
| 3738 | 3697 | |
| 3739 | | {isComposerFooterCompact ? ( |
| 3740 | | <CompactComposerControlsMenu |
| 3741 | | activePlan={Boolean(activePlan || activeProposedPlan || planSidebarOpen)} |
| 3742 | | interactionMode={interactionMode} |
| 3743 | | planSidebarOpen={planSidebarOpen} |
| 3744 | | runtimeMode={runtimeMode} |
| 3745 | | selectedEffort={selectedEffort} |
| 3746 | | selectedProvider={selectedProvider} |
| 3747 | | selectedCodexFastModeEnabled={selectedCodexFastModeEnabled} |
| 3748 | | reasoningOptions={reasoningOptions} |
| 3749 | | onEffortSelect={onEffortSelect} |
| 3750 | | onCodexFastModeChange={onCodexFastModeChange} |
| 3751 | | onToggleInteractionMode={toggleInteractionMode} |
| 3752 | | onTogglePlanSidebar={togglePlanSidebar} |
| 3753 | | onToggleRuntimeMode={toggleRuntimeMode} |
| 3698 | {/* Bottom toolbar */} |
| 3699 | {activePendingApproval ? ( |
| 3700 | <div className="flex items-center justify-end gap-2 px-2.5 pb-2.5 sm:px-3 sm:pb-3"> |
| 3701 | <ComposerPendingApprovalActions |
| 3702 | requestId={activePendingApproval.requestId} |
| 3703 | isResponding={respondingRequestIds.includes(activePendingApproval.requestId)} |
| 3704 | onRespondToApproval={onRespondToApproval} |
| 3754 | 3705 | /> |
| 3755 | | ) : ( |
| 3756 | | <> |
| 3757 | | {selectedProvider === "codex" && selectedEffort != null ? ( |
| 3758 | | <> |
| 3759 | | <Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" /> |
| 3760 | | <CodexTraitsPicker |
| 3761 | | effort={selectedEffort} |
| 3762 | | fastModeEnabled={selectedCodexFastModeEnabled} |
| 3763 | | options={reasoningOptions} |
| 3764 | | onEffortChange={onEffortSelect} |
| 3765 | | onFastModeChange={onCodexFastModeChange} |
| 3766 | | /> |
| 3767 | | </> |
| 3768 | | ) : null} |
| 3706 | </div> |
| 3707 | ) : ( |
| 3708 | <div |
| 3709 | data-chat-composer-footer="true" |
| 3710 | className={cn( |
| 3711 | "flex items-center justify-between px-2.5 pb-2.5 sm:px-3 sm:pb-3", |
| 3712 | isComposerFooterCompact |
| 3713 | ? "gap-1.5" |
| 3714 | : "flex-wrap gap-2 sm:flex-nowrap sm:gap-0", |
| 3715 | )} |
| 3716 | > |
| 3717 | <div |
| 3718 | className={cn( |
| 3719 | "flex min-w-0 flex-1 items-center", |
| 3720 | isComposerFooterCompact |
| 3721 | ? "gap-1 overflow-hidden" |
| 3722 | : "gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden sm:min-w-max sm:overflow-visible", |
| 3723 | )} |
| 3724 | > |
| 3725 | {/* Provider/model picker */} |
| 3726 | <ProviderModelPicker |
| 3727 | compact={isComposerFooterCompact} |
| 3728 | provider={selectedProvider} |
| 3729 | model={selectedModelForPickerWithCustomFallback} |
| 3730 | lockedProvider={lockedProvider} |
| 3731 | modelOptionsByProvider={modelOptionsByProvider} |
| 3732 | onProviderModelChange={onProviderModelSelect} |
| 3733 | /> |
| 3769 | 3734 | |
| 3770 | | <Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" /> |
| 3735 | {isComposerFooterCompact ? ( |
| 3736 | <CompactComposerControlsMenu |
| 3737 | activePlan={Boolean(activePlan || activeProposedPlan || planSidebarOpen)} |
| 3738 | interactionMode={interactionMode} |
| 3739 | planSidebarOpen={planSidebarOpen} |
| 3740 | runtimeMode={runtimeMode} |
| 3741 | selectedEffort={selectedEffort} |
| 3742 | selectedProvider={selectedProvider} |
| 3743 | selectedCodexFastModeEnabled={selectedCodexFastModeEnabled} |
| 3744 | reasoningOptions={reasoningOptions} |
| 3745 | onEffortSelect={onEffortSelect} |
| 3746 | onCodexFastModeChange={onCodexFastModeChange} |
| 3747 | onToggleInteractionMode={toggleInteractionMode} |
| 3748 | onTogglePlanSidebar={togglePlanSidebar} |
| 3749 | onToggleRuntimeMode={toggleRuntimeMode} |
| 3750 | /> |
| 3751 | ) : ( |
| 3752 | <> |
| 3753 | {selectedProvider === "codex" && selectedEffort != null ? ( |
| 3754 | <> |
| 3755 | <Separator |
| 3756 | orientation="vertical" |
| 3757 | className="mx-0.5 hidden h-4 sm:block" |
| 3758 | /> |
| 3759 | <CodexTraitsPicker |
| 3760 | effort={selectedEffort} |
| 3761 | fastModeEnabled={selectedCodexFastModeEnabled} |
| 3762 | options={reasoningOptions} |
| 3763 | onEffortChange={onEffortSelect} |
| 3764 | onFastModeChange={onCodexFastModeChange} |
| 3765 | /> |
| 3766 | </> |
| 3767 | ) : null} |
| 3771 | 3768 | |
| 3772 | | <Button |
| 3773 | | variant="ghost" |
| 3774 | | className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3" |
| 3775 | | size="sm" |
| 3776 | | type="button" |
| 3777 | | onClick={toggleInteractionMode} |
| 3778 | | title={ |
| 3779 | | interactionMode === "plan" |
| 3780 | | ? "Plan mode — click to return to normal chat mode" |
| 3781 | | : "Default mode — click to enter plan mode" |
| 3782 | | } |
| 3783 | | > |
| 3784 | | <BotIcon /> |
| 3785 | | <span className="sr-only sm:not-sr-only"> |
| 3786 | | {interactionMode === "plan" ? "Plan" : "Chat"} |
| 3787 | | </span> |
| 3788 | | </Button> |
| 3769 | <Separator |
| 3770 | orientation="vertical" |
| 3771 | className="mx-0.5 hidden h-4 sm:block" |
| 3772 | /> |
| 3789 | 3773 | |
| 3790 | | <Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" /> |
| 3774 | <Button |
| 3775 | variant="ghost" |
| 3776 | className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3" |
| 3777 | size="sm" |
| 3778 | type="button" |
| 3779 | onClick={toggleInteractionMode} |
| 3780 | title={ |
| 3781 | interactionMode === "plan" |
| 3782 | ? "Plan mode — click to return to normal chat mode" |
| 3783 | : "Default mode — click to enter plan mode" |
| 3784 | } |
| 3785 | > |
| 3786 | <BotIcon /> |
| 3787 | <span className="sr-only sm:not-sr-only"> |
| 3788 | {interactionMode === "plan" ? "Plan" : "Chat"} |
| 3789 | </span> |
| 3790 | </Button> |
| 3791 | 3791 | |
| 3792 | | <Button |
| 3793 | | variant="ghost" |
| 3794 | | className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3" |
| 3795 | | size="sm" |
| 3796 | | type="button" |
| 3797 | | onClick={() => |
| 3798 | | void handleRuntimeModeChange( |
| 3799 | | runtimeMode === "full-access" ? "approval-required" : "full-access", |
| 3800 | | ) |
| 3801 | | } |
| 3802 | | title={ |
| 3803 | | runtimeMode === "full-access" |
| 3804 | | ? "Full access — click to require approvals" |
| 3805 | | : "Approval required — click for full access" |
| 3806 | | } |
| 3807 | | > |
| 3808 | | {runtimeMode === "full-access" ? <LockOpenIcon /> : <LockIcon />} |
| 3809 | | <span className="sr-only sm:not-sr-only"> |
| 3810 | | {runtimeMode === "full-access" ? "Full access" : "Supervised"} |
| 3811 | | </span> |
| 3812 | | </Button> |
| 3792 | <Separator |
| 3793 | orientation="vertical" |
| 3794 | className="mx-0.5 hidden h-4 sm:block" |
| 3795 | /> |
| 3813 | 3796 | |
| 3814 | | {(activePlan || activeProposedPlan || planSidebarOpen) ? ( |
| 3815 | | <> |
| 3816 | | <Separator orientation="vertical" className="mx-0.5 hidden h-4 sm:block" /> |
| 3817 | 3797 | <Button |
| 3818 | 3798 | variant="ghost" |
| 3819 | | className={cn( |
| 3820 | | "shrink-0 whitespace-nowrap px-2 sm:px-3", |
| 3821 | | planSidebarOpen |
| 3822 | | ? "text-blue-400 hover:text-blue-300" |
| 3823 | | : "text-muted-foreground/70 hover:text-foreground/80", |
| 3824 | | )} |
| 3799 | className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3" |
| 3825 | 3800 | size="sm" |
| 3826 | 3801 | type="button" |
| 3827 | | onClick={togglePlanSidebar} |
| 3828 | | title={planSidebarOpen ? "Hide plan sidebar" : "Show plan sidebar"} |
| 3802 | onClick={() => |
| 3803 | void handleRuntimeModeChange( |
| 3804 | runtimeMode === "full-access" ? "approval-required" : "full-access", |
| 3805 | ) |
| 3806 | } |
| 3807 | title={ |
| 3808 | runtimeMode === "full-access" |
| 3809 | ? "Full access — click to require approvals" |
| 3810 | : "Approval required — click for full access" |
| 3811 | } |
| 3829 | 3812 | > |
| 3830 | | <ListTodoIcon /> |
| 3831 | | <span className="sr-only sm:not-sr-only">Plan</span> |
| 3813 | {runtimeMode === "full-access" ? <LockOpenIcon /> : <LockIcon />} |
| 3814 | <span className="sr-only sm:not-sr-only"> |
| 3815 | {runtimeMode === "full-access" ? "Full access" : "Supervised"} |
| 3816 | </span> |
| 3832 | 3817 | </Button> |
| 3833 | | </> |
| 3834 | | ) : null} |
| 3835 | | </> |
| 3836 | | )} |
| 3837 | | </div> |
| 3838 | 3818 | |
| 3839 | | {/* Right side: send / stop button */} |
| 3840 | | <div data-chat-composer-actions="right" className="flex shrink-0 items-center gap-2"> |
| 3841 | | {isPreparingWorktree ? ( |
| 3842 | | <span className="text-muted-foreground/70 text-xs">Preparing worktree...</span> |
| 3843 | | ) : null} |
| 3844 | | {activePendingProgress ? ( |
| 3845 | | <div className="flex items-center gap-2"> |
| 3846 | | {activePendingProgress.questionIndex > 0 ? ( |
| 3847 | | <Button |
| 3848 | | size="sm" |
| 3849 | | variant="outline" |
| 3850 | | className="rounded-full" |
| 3851 | | onClick={onPreviousActivePendingUserInputQuestion} |
| 3852 | | disabled={activePendingIsResponding} |
| 3853 | | > |
| 3854 | | Previous |
| 3855 | | </Button> |
| 3856 | | ) : null} |
| 3857 | | <Button |
| 3858 | | type="submit" |
| 3859 | | size="sm" |
| 3860 | | className="rounded-full px-4" |
| 3861 | | disabled={ |
| 3862 | | activePendingIsResponding || |
| 3863 | | (activePendingProgress.isLastQuestion |
| 3864 | | ? !activePendingResolvedAnswers |
| 3865 | | : !activePendingProgress.canAdvance) |
| 3866 | | } |
| 3867 | | > |
| 3868 | | {activePendingIsResponding |
| 3869 | | ? "Submitting..." |
| 3870 | | : activePendingProgress.isLastQuestion |
| 3871 | | ? "Submit answers" |
| 3872 | | : "Next question"} |
| 3873 | | </Button> |
| 3819 | {activePlan || activeProposedPlan || planSidebarOpen ? ( |
| 3820 | <> |
| 3821 | <Separator |
| 3822 | orientation="vertical" |
| 3823 | className="mx-0.5 hidden h-4 sm:block" |
| 3824 | /> |
| 3825 | <Button |
| 3826 | variant="ghost" |
| 3827 | className={cn( |
| 3828 | "shrink-0 whitespace-nowrap px-2 sm:px-3", |
| 3829 | planSidebarOpen |
| 3830 | ? "text-blue-400 hover:text-blue-300" |
| 3831 | : "text-muted-foreground/70 hover:text-foreground/80", |
| 3832 | )} |
| 3833 | size="sm" |
| 3834 | type="button" |
| 3835 | onClick={togglePlanSidebar} |
| 3836 | title={planSidebarOpen ? "Hide plan sidebar" : "Show plan sidebar"} |
| 3837 | > |
| 3838 | <ListTodoIcon /> |
| 3839 | <span className="sr-only sm:not-sr-only">Plan</span> |
| 3840 | </Button> |
| 3841 | </> |
| 3842 | ) : null} |
| 3843 | </> |
| 3844 | )} |
| 3874 | 3845 | </div> |
| 3875 | | ) : phase === "running" ? ( |
| 3876 | | <button |
| 3877 | | type="button" |
| 3878 | | className="flex size-8 items-center justify-center rounded-full bg-rose-500/90 text-white transition-all duration-150 hover:bg-rose-500 hover:scale-105 sm:h-8 sm:w-8" |
| 3879 | | onClick={() => void onInterrupt()} |
| 3880 | | aria-label="Stop generation" |
| 3846 | |
| 3847 | {/* Right side: send / stop button */} |
| 3848 | <div |
| 3849 | data-chat-composer-actions="right" |
| 3850 | className="flex shrink-0 items-center gap-2" |
| 3881 | 3851 | > |
| 3882 | | <svg |
| 3883 | | width="12" |
| 3884 | | height="12" |
| 3885 | | viewBox="0 0 12 12" |
| 3886 | | fill="currentColor" |
| 3887 | | aria-hidden="true" |
| 3888 | | > |
| 3889 | | <rect x="2" y="2" width="8" height="8" rx="1.5" /> |
| 3890 | | </svg> |
| 3891 | | </button> |
| 3892 | | ) : pendingUserInputs.length === 0 ? ( |
| 3893 | | showPlanFollowUpPrompt ? ( |
| 3894 | | prompt.trim().length > 0 ? ( |
| 3895 | | <Button |
| 3896 | | type="submit" |
| 3897 | | size="sm" |
| 3898 | | className="h-9 rounded-full px-4 sm:h-8" |
| 3899 | | disabled={isSendBusy || isConnecting} |
| 3900 | | > |
| 3901 | | {isConnecting || isSendBusy ? "Sending..." : "Refine"} |
| 3902 | | </Button> |
| 3903 | | ) : ( |
| 3904 | | <div className="flex items-center"> |
| 3852 | {isPreparingWorktree ? ( |
| 3853 | <span className="text-muted-foreground/70 text-xs"> |
| 3854 | Preparing worktree... |
| 3855 | </span> |
| 3856 | ) : null} |
| 3857 | {activePendingProgress ? ( |
| 3858 | <div className="flex items-center gap-2"> |
| 3859 | {activePendingProgress.questionIndex > 0 ? ( |
| 3860 | <Button |
| 3861 | size="sm" |
| 3862 | variant="outline" |
| 3863 | className="rounded-full" |
| 3864 | onClick={onPreviousActivePendingUserInputQuestion} |
| 3865 | disabled={activePendingIsResponding} |
| 3866 | > |
| 3867 | Previous |
| 3868 | </Button> |
| 3869 | ) : null} |
| 3905 | 3870 | <Button |
| 3906 | 3871 | type="submit" |
| 3907 | 3872 | size="sm" |
| 3908 | | className="h-9 rounded-l-full rounded-r-none px-4 sm:h-8" |
| 3909 | | disabled={isSendBusy || isConnecting} |
| 3873 | className="rounded-full px-4" |
| 3874 | disabled={ |
| 3875 | activePendingIsResponding || |
| 3876 | (activePendingProgress.isLastQuestion |
| 3877 | ? !activePendingResolvedAnswers |
| 3878 | : !activePendingProgress.canAdvance) |
| 3879 | } |
| 3910 | 3880 | > |
| 3911 | | {isConnecting || isSendBusy ? "Sending..." : "Implement"} |
| 3881 | {activePendingIsResponding |
| 3882 | ? "Submitting..." |
| 3883 | : activePendingProgress.isLastQuestion |
| 3884 | ? "Submit answers" |
| 3885 | : "Next question"} |
| 3912 | 3886 | </Button> |
| 3913 | | <Menu> |
| 3914 | | <MenuTrigger |
| 3915 | | render={ |
| 3916 | | <Button |
| 3917 | | size="sm" |
| 3918 | | variant="default" |
| 3919 | | className="h-9 rounded-l-none rounded-r-full border-l-white/12 px-2 sm:h-8" |
| 3920 | | aria-label="Implementation actions" |
| 3921 | | disabled={isSendBusy || isConnecting} |
| 3922 | | /> |
| 3923 | | } |
| 3924 | | > |
| 3925 | | <ChevronDownIcon className="size-3.5" /> |
| 3926 | | </MenuTrigger> |
| 3927 | | <MenuPopup align="end" side="top"> |
| 3928 | | <MenuItem |
| 3929 | | disabled={isSendBusy || isConnecting} |
| 3930 | | onClick={() => void onImplementPlanInNewThread()} |
| 3931 | | > |
| 3932 | | Implement in new thread |
| 3933 | | </MenuItem> |
| 3934 | | </MenuPopup> |
| 3935 | | </Menu> |
| 3936 | 3887 | </div> |
| 3937 | | ) |
| 3938 | | ) : ( |
| 3939 | | <button |
| 3940 | | type="submit" |
| 3941 | | className="flex h-9 w-9 items-center justify-center rounded-full bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary hover:scale-105 disabled:opacity-30 disabled:hover:scale-100 sm:h-8 sm:w-8" |
| 3942 | | disabled={ |
| 3943 | | isSendBusy || |
| 3944 | | isConnecting || |
| 3945 | | (!prompt.trim() && composerImages.length === 0) |
| 3946 | | } |
| 3947 | | aria-label={ |
| 3948 | | isConnecting |
| 3949 | | ? "Connecting" |
| 3950 | | : isPreparingWorktree |
| 3951 | | ? "Preparing worktree" |
| 3952 | | : isSendBusy |
| 3953 | | ? "Sending" |
| 3954 | | : "Send message" |
| 3955 | | } |
| 3956 | | > |
| 3957 | | {isConnecting || isSendBusy ? ( |
| 3888 | ) : phase === "running" ? ( |
| 3889 | <button |
| 3890 | type="button" |
| 3891 | className="flex size-8 items-center justify-center rounded-full bg-rose-500/90 text-white transition-all duration-150 hover:bg-rose-500 hover:scale-105 sm:h-8 sm:w-8" |
| 3892 | onClick={() => void onInterrupt()} |
| 3893 | aria-label="Stop generation" |
| 3894 | > |
| 3958 | 3895 | <svg |
| 3959 | | width="14" |
| 3960 | | height="14" |
| 3961 | | viewBox="0 0 14 14" |
| 3962 | | fill="none" |
| 3963 | | className="animate-spin" |
| 3896 | width="12" |
| 3897 | height="12" |
| 3898 | viewBox="0 0 12 12" |
| 3899 | fill="currentColor" |
| 3964 | 3900 | aria-hidden="true" |
| 3965 | 3901 | > |
| 3966 | | <circle |
| 3967 | | cx="7" |
| 3968 | | cy="7" |
| 3969 | | r="5.5" |
| 3970 | | stroke="currentColor" |
| 3971 | | strokeWidth="1.5" |
| 3972 | | strokeLinecap="round" |
| 3973 | | strokeDasharray="20 12" |
| 3974 | | /> |
| 3902 | <rect x="2" y="2" width="8" height="8" rx="1.5" /> |
| 3975 | 3903 | </svg> |
| 3904 | </button> |
| 3905 | ) : pendingUserInputs.length === 0 ? ( |
| 3906 | showPlanFollowUpPrompt ? ( |
| 3907 | prompt.trim().length > 0 ? ( |
| 3908 | <Button |
| 3909 | type="submit" |
| 3910 | size="sm" |
| 3911 | className="h-9 rounded-full px-4 sm:h-8" |
| 3912 | disabled={isSendBusy || isConnecting} |
| 3913 | > |
| 3914 | {isConnecting || isSendBusy ? "Sending..." : "Refine"} |
| 3915 | </Button> |
| 3916 | ) : ( |
| 3917 | <div className="flex items-center"> |
| 3918 | <Button |
| 3919 | type="submit" |
| 3920 | size="sm" |
| 3921 | className="h-9 rounded-l-full rounded-r-none px-4 sm:h-8" |
| 3922 | disabled={isSendBusy || isConnecting} |
| 3923 | > |
| 3924 | {isConnecting || isSendBusy ? "Sending..." : "Implement"} |
| 3925 | </Button> |
| 3926 | <Menu> |
| 3927 | <MenuTrigger |
| 3928 | render={ |
| 3929 | <Button |
| 3930 | size="sm" |
| 3931 | variant="default" |
| 3932 | className="h-9 rounded-l-none rounded-r-full border-l-white/12 px-2 sm:h-8" |
| 3933 | aria-label="Implementation actions" |
| 3934 | disabled={isSendBusy || isConnecting} |
| 3935 | /> |
| 3936 | } |
| 3937 | > |
| 3938 | <ChevronDownIcon className="size-3.5" /> |
| 3939 | </MenuTrigger> |
| 3940 | <MenuPopup align="end" side="top"> |
| 3941 | <MenuItem |
| 3942 | disabled={isSendBusy || isConnecting} |
| 3943 | onClick={() => void onImplementPlanInNewThread()} |
| 3944 | > |
| 3945 | Implement in new thread |
| 3946 | </MenuItem> |
| 3947 | </MenuPopup> |
| 3948 | </Menu> |
| 3949 | </div> |
| 3950 | ) |
| 3976 | 3951 | ) : ( |
| 3977 | | <svg |
| 3978 | | width="14" |
| 3979 | | height="14" |
| 3980 | | viewBox="0 0 14 14" |
| 3981 | | fill="none" |
| 3982 | | aria-hidden="true" |
| 3952 | <button |
| 3953 | type="submit" |
| 3954 | className="flex h-9 w-9 items-center justify-center rounded-full bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary hover:scale-105 disabled:opacity-30 disabled:hover:scale-100 sm:h-8 sm:w-8" |
| 3955 | disabled={ |
| 3956 | isSendBusy || |
| 3957 | isConnecting || |
| 3958 | (!prompt.trim() && composerImages.length === 0) |
| 3959 | } |
| 3960 | aria-label={ |
| 3961 | isConnecting |
| 3962 | ? "Connecting" |
| 3963 | : isPreparingWorktree |
| 3964 | ? "Preparing worktree" |
| 3965 | : isSendBusy |
| 3966 | ? "Sending" |
| 3967 | : "Send message" |
| 3968 | } |
| 3983 | 3969 | > |
| 3984 | | <path |
| 3985 | | d="M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5" |
| 3986 | | stroke="currentColor" |
| 3987 | | strokeWidth="1.8" |
| 3988 | | strokeLinecap="round" |
| 3989 | | strokeLinejoin="round" |
| 3990 | | /> |
| 3991 | | </svg> |
| 3992 | | )} |
| 3993 | | </button> |
| 3994 | | ) |
| 3995 | | ) : null} |
| 3996 | | </div> |
| 3970 | {isConnecting || isSendBusy ? ( |
| 3971 | <svg |
| 3972 | width="14" |
| 3973 | height="14" |
| 3974 | viewBox="0 0 14 14" |
| 3975 | fill="none" |
| 3976 | className="animate-spin" |
| 3977 | aria-hidden="true" |
| 3978 | > |
| 3979 | <circle |
| 3980 | cx="7" |
| 3981 | cy="7" |
| 3982 | r="5.5" |
| 3983 | stroke="currentColor" |
| 3984 | strokeWidth="1.5" |
| 3985 | strokeLinecap="round" |
| 3986 | strokeDasharray="20 12" |
| 3987 | /> |
| 3988 | </svg> |
| 3989 | ) : ( |
| 3990 | <svg |
| 3991 | width="14" |
| 3992 | height="14" |
| 3993 | viewBox="0 0 14 14" |
| 3994 | fill="none" |
| 3995 | aria-hidden="true" |
| 3996 | > |
| 3997 | <path |
| 3998 | d="M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5" |
| 3999 | stroke="currentColor" |
| 4000 | strokeWidth="1.8" |
| 4001 | strokeLinecap="round" |
| 4002 | strokeLinejoin="round" |
| 4003 | /> |
| 4004 | </svg> |
| 4005 | )} |
| 4006 | </button> |
| 4007 | ) |
| 4008 | ) : null} |
| 4009 | </div> |
| 4010 | </div> |
| 4011 | )} |
| 3997 | 4012 | </div> |
| 3998 | | )} |
| 4013 | </form> |
| 3999 | 4014 | </div> |
| 4000 | | </form> |
| 4001 | | </div> |
| 4002 | | |
| 4003 | | {isGitRepo && ( |
| 4004 | | <BranchToolbar |
| 4005 | | threadId={activeThread.id} |
| 4006 | | onEnvModeChange={onEnvModeChange} |
| 4007 | | envLocked={envLocked} |
| 4008 | | onComposerFocusRequest={scheduleComposerFocus} |
| 4009 | | /> |
| 4010 | | )} |
| 4011 | 4015 | |
| 4012 | | </div>{/* end chat column */} |
| 4016 | {isGitRepo && ( |
| 4017 | <BranchToolbar |
| 4018 | threadId={activeThread.id} |
| 4019 | onEnvModeChange={onEnvModeChange} |
| 4020 | envLocked={envLocked} |
| 4021 | onComposerFocusRequest={scheduleComposerFocus} |
| 4022 | /> |
| 4023 | )} |
| 4024 | </div> |
| 4025 | {/* end chat column */} |
| 4013 | 4026 | |
| 4014 | 4027 | {/* Plan sidebar */} |
| 4015 | 4028 | {planSidebarOpen ? ( |
| ... | ... | @@ -4028,7 +4041,8 @@ export default function ChatView({ threadId }: ChatViewProps) { |
| 4028 | 4041 | }} |
| 4029 | 4042 | /> |
| 4030 | 4043 | ) : null} |
| 4031 | | </div>{/* end horizontal flex container */} |
| 4044 | </div> |
| 4045 | {/* end horizontal flex container */} |
| 4032 | 4046 | |
| 4033 | 4047 | {(() => { |
| 4034 | 4048 | if (!terminalState.terminalOpen || !activeProject) { |
| ... | ... | @@ -4465,10 +4479,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard( |
| 4465 | 4479 | const handler = (event: globalThis.KeyboardEvent) => { |
| 4466 | 4480 | if (event.metaKey || event.ctrlKey || event.altKey) return; |
| 4467 | 4481 | const target = event.target; |
| 4468 | | if ( |
| 4469 | | target instanceof HTMLInputElement || |
| 4470 | | target instanceof HTMLTextAreaElement |
| 4471 | | ) { |
| 4482 | if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) { |
| 4472 | 4483 | return; |
| 4473 | 4484 | } |
| 4474 | 4485 | // If the user has started typing a custom answer in the contenteditable |
| ... | ... | @@ -4542,12 +4553,12 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard( |
| 4542 | 4553 | <div className="min-w-0 flex-1"> |
| 4543 | 4554 | <span className="text-sm font-medium">{option.label}</span> |
| 4544 | 4555 | {option.description && option.description !== option.label ? ( |
| 4545 | | <span className="ml-2 text-xs text-muted-foreground/50">{option.description}</span> |
| 4556 | <span className="ml-2 text-xs text-muted-foreground/50"> |
| 4557 | {option.description} |
| 4558 | </span> |
| 4546 | 4559 | ) : null} |
| 4547 | 4560 | </div> |
| 4548 | | {isSelected ? ( |
| 4549 | | <CheckIcon className="size-3.5 shrink-0 text-blue-400" /> |
| 4550 | | ) : null} |
| 4561 | {isSelected ? <CheckIcon className="size-3.5 shrink-0 text-blue-400" /> : null} |
| 4551 | 4562 | </button> |
| 4552 | 4563 | ); |
| 4553 | 4564 | })} |
| ... | ... | @@ -4754,13 +4765,34 @@ const ProposedPlanCard = memo(function ProposedPlanCard({ |
| 4754 | 4765 | const [isSaveDialogOpen, setIsSaveDialogOpen] = useState(false); |
| 4755 | 4766 | const [savePath, setSavePath] = useState(""); |
| 4756 | 4767 | const [isSavingToWorkspace, setIsSavingToWorkspace] = useState(false); |
| 4768 | const [renderCollapsedMarkdown, setRenderCollapsedMarkdown] = useState(false); |
| 4757 | 4769 | const savePathInputId = useId(); |
| 4758 | 4770 | const title = proposedPlanTitle(planMarkdown) ?? "Proposed plan"; |
| 4759 | 4771 | const lineCount = planMarkdown.split("\n").length; |
| 4760 | 4772 | const canCollapse = planMarkdown.length > 900 || lineCount > 20; |
| 4773 | const displayedPlanMarkdown = stripDisplayedPlanMarkdown(planMarkdown); |
| 4774 | const collapsedPreview = canCollapse |
| 4775 | ? buildCollapsedProposedPlanPreviewMarkdown(planMarkdown, { maxLines: 10 }) |
| 4776 | : null; |
| 4761 | 4777 | const downloadFilename = buildProposedPlanMarkdownFilename(planMarkdown); |
| 4762 | 4778 | const saveContents = normalizePlanMarkdownForExport(planMarkdown); |
| 4763 | 4779 | |
| 4780 | useEffect(() => { |
| 4781 | if (!canCollapse || expanded) { |
| 4782 | setRenderCollapsedMarkdown(false); |
| 4783 | return; |
| 4784 | } |
| 4785 | setRenderCollapsedMarkdown(false); |
| 4786 | const frame = window.requestAnimationFrame(() => { |
| 4787 | startTransition(() => { |
| 4788 | setRenderCollapsedMarkdown(true); |
| 4789 | }); |
| 4790 | }); |
| 4791 | return () => { |
| 4792 | window.cancelAnimationFrame(frame); |
| 4793 | }; |
| 4794 | }, [canCollapse, expanded, collapsedPreview]); |
| 4795 | |
| 4764 | 4796 | const handleDownload = () => { |
| 4765 | 4797 | downloadPlanAsTextFile(downloadFilename, saveContents); |
| 4766 | 4798 | }; |
| ... | ... | @@ -4847,7 +4879,17 @@ const ProposedPlanCard = memo(function ProposedPlanCard({ |
| 4847 | 4879 | </div> |
| 4848 | 4880 | <div className="mt-4"> |
| 4849 | 4881 | <div className={cn("relative", canCollapse && !expanded && "max-h-104 overflow-hidden")}> |
| 4850 | | <ChatMarkdown text={planMarkdown} cwd={cwd} isStreaming={false} /> |
| 4882 | {canCollapse && !expanded ? ( |
| 4883 | renderCollapsedMarkdown ? ( |
| 4884 | <ChatMarkdown text={collapsedPreview ?? ""} cwd={cwd} isStreaming={false} /> |
| 4885 | ) : ( |
| 4886 | <pre className="whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground/80"> |
| 4887 | {collapsedPreview} |
| 4888 | </pre> |
| 4889 | ) |
| 4890 | ) : ( |
| 4891 | <ChatMarkdown text={displayedPlanMarkdown} cwd={cwd} isStreaming={false} /> |
| 4892 | )} |
| 4851 | 4893 | {canCollapse && !expanded ? ( |
| 4852 | 4894 | <div className="pointer-events-none absolute inset-x-0 bottom-0 h-24 bg-linear-to-t from-card/95 via-card/80 to-transparent" /> |
| 4853 | 4895 | ) : null} |
| ... | ... | @@ -5601,7 +5643,7 @@ const ProviderModelPicker = memo(function ProviderModelPicker(props: { |
| 5601 | 5643 | } |
| 5602 | 5644 | setIsMenuOpen(open); |
| 5603 | 5645 | }} |
| 5604 | | > |
| 5646 | >max-w-42 |
| 5605 | 5647 | <MenuTrigger |
| 5606 | 5648 | render={ |
| 5607 | 5649 | <Button |
| ... | ... | @@ -5610,7 +5652,7 @@ const ProviderModelPicker = memo(function ProviderModelPicker(props: { |
| 5610 | 5652 | className={cn( |
| 5611 | 5653 | "min-w-0 shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80", |
| 5612 | 5654 | props.compact ? "max-w-[10.5rem]" : "sm:px-3", |
| 5613 | | )} |
| 5655 | )}max-w-36 |
| 5614 | 5656 | disabled={props.disabled} |
| 5615 | 5657 | /> |
| 5616 | 5658 | } |