Explorar el Código

fix(app): prompt input overflow issue (#11840)

Filip hace 3 semanas
padre
commit
aadd2e13d7

+ 30 - 12
packages/app/src/components/prompt-input.tsx

@@ -1896,8 +1896,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
             </div>
             </div>
           </Show>
           </Show>
         </div>
         </div>
-        <div class="relative p-3 flex items-center justify-between">
-          <div class="flex items-center justify-start gap-0.5">
+        <div class="relative p-3 flex items-center justify-between gap-2">
+          <div class="flex items-center gap-2 min-w-0 flex-1">
             <Switch>
             <Switch>
               <Match when={store.mode === "shell"}>
               <Match when={store.mode === "shell"}>
                 <div class="flex items-center gap-2 px-2 h-6">
                 <div class="flex items-center gap-2 px-2 h-6">
@@ -1909,6 +1909,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
               <Match when={store.mode === "normal"}>
               <Match when={store.mode === "normal"}>
                 <TooltipKeybind
                 <TooltipKeybind
                   placement="top"
                   placement="top"
+                  gutter={8}
                   title={language.t("command.agent.cycle")}
                   title={language.t("command.agent.cycle")}
                   keybind={command.keybind("agent.cycle")}
                   keybind={command.keybind("agent.cycle")}
                 >
                 >
@@ -1916,7 +1917,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
                     options={local.agent.list().map((agent) => agent.name)}
                     options={local.agent.list().map((agent) => agent.name)}
                     current={local.agent.current()?.name ?? ""}
                     current={local.agent.current()?.name ?? ""}
                     onSelect={local.agent.set}
                     onSelect={local.agent.set}
-                    class="capitalize"
+                    class={`capitalize ${local.model.variant.list().length > 0 ? "max-w-[80px]" : "max-w-[120px]"}`}
+                    valueClass="truncate"
                     variant="ghost"
                     variant="ghost"
                   />
                   />
                 </TooltipKeybind>
                 </TooltipKeybind>
@@ -1925,36 +1927,51 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
                   fallback={
                   fallback={
                     <TooltipKeybind
                     <TooltipKeybind
                       placement="top"
                       placement="top"
+                      gutter={8}
                       title={language.t("command.model.choose")}
                       title={language.t("command.model.choose")}
                       keybind={command.keybind("model.choose")}
                       keybind={command.keybind("model.choose")}
                     >
                     >
-                      <Button as="div" variant="ghost" onClick={() => dialog.show(() => <DialogSelectModelUnpaid />)}>
+                      <Button
+                        as="div"
+                        variant="ghost"
+                        class="px-2 min-w-0 max-w-[140px]"
+                        onClick={() => dialog.show(() => <DialogSelectModelUnpaid />)}
+                      >
                         <Show when={local.model.current()?.provider?.id}>
                         <Show when={local.model.current()?.provider?.id}>
                           <ProviderIcon id={local.model.current()!.provider.id as IconName} class="size-4 shrink-0" />
                           <ProviderIcon id={local.model.current()!.provider.id as IconName} class="size-4 shrink-0" />
                         </Show>
                         </Show>
-                        {local.model.current()?.name ?? language.t("dialog.model.select.title")}
-                        <Icon name="chevron-down" size="small" />
+                        <span class="truncate max-w-[100px]">
+                          {local.model.current()?.name ?? language.t("dialog.model.select.title")}
+                        </span>
+                        <Icon name="chevron-down" size="small" class="shrink-0" />
                       </Button>
                       </Button>
                     </TooltipKeybind>
                     </TooltipKeybind>
                   }
                   }
                 >
                 >
                   <TooltipKeybind
                   <TooltipKeybind
                     placement="top"
                     placement="top"
+                    gutter={8}
                     title={language.t("command.model.choose")}
                     title={language.t("command.model.choose")}
                     keybind={command.keybind("model.choose")}
                     keybind={command.keybind("model.choose")}
                   >
                   >
-                    <ModelSelectorPopover triggerAs={Button} triggerProps={{ variant: "ghost" }}>
+                    <ModelSelectorPopover
+                      triggerAs={Button}
+                      triggerProps={{ variant: "ghost", class: "min-w-0 max-w-[140px]" }}
+                    >
                       <Show when={local.model.current()?.provider?.id}>
                       <Show when={local.model.current()?.provider?.id}>
                         <ProviderIcon id={local.model.current()!.provider.id as IconName} class="size-4 shrink-0" />
                         <ProviderIcon id={local.model.current()!.provider.id as IconName} class="size-4 shrink-0" />
                       </Show>
                       </Show>
-                      {local.model.current()?.name ?? language.t("dialog.model.select.title")}
-                      <Icon name="chevron-down" size="small" />
+                      <span class="truncate max-w-[100px]">
+                        {local.model.current()?.name ?? language.t("dialog.model.select.title")}
+                      </span>
+                      <Icon name="chevron-down" size="small" class="shrink-0" />
                     </ModelSelectorPopover>
                     </ModelSelectorPopover>
                   </TooltipKeybind>
                   </TooltipKeybind>
                 </Show>
                 </Show>
                 <Show when={local.model.variant.list().length > 0}>
                 <Show when={local.model.variant.list().length > 0}>
                   <TooltipKeybind
                   <TooltipKeybind
                     placement="top"
                     placement="top"
+                    gutter={8}
                     title={language.t("command.model.variant.cycle")}
                     title={language.t("command.model.variant.cycle")}
                     keybind={command.keybind("model.variant.cycle")}
                     keybind={command.keybind("model.variant.cycle")}
                   >
                   >
@@ -1971,6 +1988,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
                 <Show when={permission.permissionsEnabled() && params.id}>
                 <Show when={permission.permissionsEnabled() && params.id}>
                   <TooltipKeybind
                   <TooltipKeybind
                     placement="top"
                     placement="top"
+                    gutter={8}
                     title={language.t("command.permissions.autoaccept.enable")}
                     title={language.t("command.permissions.autoaccept.enable")}
                     keybind={command.keybind("permissions.autoaccept")}
                     keybind={command.keybind("permissions.autoaccept")}
                   >
                   >
@@ -2000,7 +2018,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
               </Match>
               </Match>
             </Switch>
             </Switch>
           </div>
           </div>
-          <div class="flex items-center gap-3 absolute right-3 bottom-3">
+          <div class="flex items-center gap-1 shrink-0">
             <input
             <input
               ref={fileInputRef}
               ref={fileInputRef}
               type="file"
               type="file"
@@ -2012,14 +2030,14 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
                 e.currentTarget.value = ""
                 e.currentTarget.value = ""
               }}
               }}
             />
             />
-            <div class="flex items-center gap-2">
+            <div class="flex items-center gap-1 mr-1">
               <SessionContextUsage />
               <SessionContextUsage />
               <Show when={store.mode === "normal"}>
               <Show when={store.mode === "normal"}>
                 <Tooltip placement="top" value={language.t("prompt.action.attachFile")}>
                 <Tooltip placement="top" value={language.t("prompt.action.attachFile")}>
                   <Button
                   <Button
                     type="button"
                     type="button"
                     variant="ghost"
                     variant="ghost"
-                    class="size-6"
+                    class="size-6 px-1"
                     onClick={() => fileInputRef.click()}
                     onClick={() => fileInputRef.click()}
                     aria-label={language.t("prompt.action.attachFile")}
                     aria-label={language.t("prompt.action.attachFile")}
                   >
                   >

+ 1 - 1
packages/app/src/components/session-context-usage.tsx

@@ -64,7 +64,7 @@ export function SessionContextUsage(props: SessionContextUsageProps) {
   }
   }
 
 
   const circle = () => (
   const circle = () => (
-    <div class="p-1">
+    <div class="flex items-center justify-center">
       <ProgressCircle size={16} strokeWidth={2} percentage={context()?.percentage ?? 0} />
       <ProgressCircle size={16} strokeWidth={2} percentage={context()?.percentage ?? 0} />
     </div>
     </div>
   )
   )

+ 3 - 1
packages/ui/src/components/select.tsx

@@ -11,6 +11,7 @@ export type SelectProps<T> = Omit<ComponentProps<typeof Kobalte<T>>, "value" | "
   value?: (x: T) => string
   value?: (x: T) => string
   label?: (x: T) => string
   label?: (x: T) => string
   groupBy?: (x: T) => string
   groupBy?: (x: T) => string
+  valueClass?: ComponentProps<"div">["class"]
   onSelect?: (value: T | undefined) => void
   onSelect?: (value: T | undefined) => void
   onHighlight?: (value: T | undefined) => (() => void) | void
   onHighlight?: (value: T | undefined) => (() => void) | void
   class?: ComponentProps<"div">["class"]
   class?: ComponentProps<"div">["class"]
@@ -30,6 +31,7 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
     "value",
     "value",
     "label",
     "label",
     "groupBy",
     "groupBy",
+    "valueClass",
     "onSelect",
     "onSelect",
     "onHighlight",
     "onHighlight",
     "onOpenChange",
     "onOpenChange",
@@ -140,7 +142,7 @@ export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">)
           [local.class ?? ""]: !!local.class,
           [local.class ?? ""]: !!local.class,
         }}
         }}
       >
       >
-        <Kobalte.Value<T> data-slot="select-select-trigger-value">
+        <Kobalte.Value<T> data-slot="select-select-trigger-value" class={local.valueClass}>
           {(state) => {
           {(state) => {
             const selected = state.selectedOption() ?? local.current
             const selected = state.selectedOption() ?? local.current
             if (!selected) return local.placeholder || ""
             if (!selected) return local.placeholder || ""