Skip to content

Commit 5c70883

Browse files
authored
fix(app): polish prompt composer controls (anomalyco#17388)
1 parent 389daa0 commit 5c70883

2 files changed

Lines changed: 60 additions & 64 deletions

File tree

packages/app/src/components/prompt-input.tsx

Lines changed: 59 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
121121
let slashPopoverRef!: HTMLDivElement
122122

123123
const mirror = { input: false }
124-
const inset = 52
124+
const inset = 56
125125
const space = `${inset}px`
126126

127127
const scrollCursorIntoView = () => {
@@ -1031,6 +1031,17 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
10311031
if (!id) return permission.isAutoAcceptingDirectory(sdk.directory)
10321032
return permission.isAutoAccepting(id, sdk.directory)
10331033
})
1034+
const acceptLabel = createMemo(() =>
1035+
language.t(accepting() ? "command.permissions.autoaccept.disable" : "command.permissions.autoaccept.enable"),
1036+
)
1037+
const toggleAccept = () => {
1038+
if (!params.id) {
1039+
permission.toggleAutoAcceptDirectory(sdk.directory)
1040+
return
1041+
}
1042+
1043+
permission.toggleAutoAccept(params.id, sdk.directory)
1044+
}
10341045

10351046
const { abort, handleSubmit } = createPromptSubmit({
10361047
info,
@@ -1337,33 +1348,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
13371348
}}
13381349
/>
13391350

1340-
<div
1341-
aria-hidden={store.mode !== "normal"}
1342-
class="flex items-center gap-1"
1343-
style={{
1344-
"pointer-events": buttonsSpring() > 0.5 ? "auto" : "none",
1345-
}}
1346-
>
1347-
<TooltipKeybind
1348-
placement="top"
1349-
title={language.t("prompt.action.attachFile")}
1350-
keybind={command.keybind("file.attach")}
1351-
>
1352-
<Button
1353-
data-action="prompt-attach"
1354-
type="button"
1355-
variant="ghost"
1356-
class="size-8 p-0"
1357-
style={buttons()}
1358-
onClick={pick}
1359-
disabled={store.mode !== "normal"}
1360-
tabIndex={store.mode === "normal" ? undefined : -1}
1361-
aria-label={language.t("prompt.action.attachFile")}
1362-
>
1363-
<Icon name="plus" class="size-4.5" />
1364-
</Button>
1365-
</TooltipKeybind>
1366-
1351+
<div class="flex items-center gap-1 pointer-events-auto">
13671352
<Tooltip
13681353
placement="top"
13691354
inactive={!prompt.dirty() && !working()}
@@ -1400,42 +1385,30 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
14001385
</div>
14011386

14021387
<div class="pointer-events-none absolute bottom-2 left-2">
1403-
<div class="pointer-events-auto">
1388+
<div
1389+
aria-hidden={store.mode !== "normal"}
1390+
class="pointer-events-auto"
1391+
style={{
1392+
"pointer-events": buttonsSpring() > 0.5 ? "auto" : "none",
1393+
}}
1394+
>
14041395
<TooltipKeybind
14051396
placement="top"
1406-
gutter={8}
1407-
title={language.t(
1408-
accepting() ? "command.permissions.autoaccept.disable" : "command.permissions.autoaccept.enable",
1409-
)}
1410-
keybind={command.keybind("permissions.autoaccept")}
1397+
title={language.t("prompt.action.attachFile")}
1398+
keybind={command.keybind("file.attach")}
14111399
>
14121400
<Button
1413-
data-action="prompt-permissions"
1401+
data-action="prompt-attach"
1402+
type="button"
14141403
variant="ghost"
1415-
onClick={() => {
1416-
if (!params.id) {
1417-
permission.toggleAutoAcceptDirectory(sdk.directory)
1418-
return
1419-
}
1420-
permission.toggleAutoAccept(params.id, sdk.directory)
1421-
}}
1422-
classList={{
1423-
"size-6 flex items-center justify-center": true,
1424-
"text-text-base": !accepting(),
1425-
"hover:bg-surface-success-base": accepting(),
1426-
}}
1427-
aria-label={
1428-
accepting()
1429-
? language.t("command.permissions.autoaccept.disable")
1430-
: language.t("command.permissions.autoaccept.enable")
1431-
}
1432-
aria-pressed={accepting()}
1404+
class="size-8 p-0"
1405+
style={buttons()}
1406+
onClick={pick}
1407+
disabled={store.mode !== "normal"}
1408+
tabIndex={store.mode === "normal" ? undefined : -1}
1409+
aria-label={language.t("prompt.action.attachFile")}
14331410
>
1434-
<Icon
1435-
name="chevron-double-right"
1436-
size="small"
1437-
classList={{ "text-icon-success-base": accepting() }}
1438-
/>
1411+
<Icon name="plus" class="size-4.5" />
14391412
</Button>
14401413
</TooltipKeybind>
14411414
</div>
@@ -1468,8 +1441,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
14681441
options={agentNames()}
14691442
current={local.agent.current()?.name ?? ""}
14701443
onSelect={local.agent.set}
1471-
class="capitalize max-w-[160px]"
1472-
valueClass="truncate text-13-regular"
1444+
class="capitalize max-w-[160px] text-text-base"
1445+
valueClass="truncate text-13-regular text-text-base"
14731446
triggerStyle={control()}
14741447
variant="ghost"
14751448
/>
@@ -1487,7 +1460,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
14871460
as="div"
14881461
variant="ghost"
14891462
size="normal"
1490-
class="min-w-0 max-w-[320px] text-13-regular group"
1463+
class="min-w-0 max-w-[320px] text-13-regular text-text-base group"
14911464
style={control()}
14921465
onClick={() => dialog.show(() => <DialogSelectModelUnpaid />)}
14931466
>
@@ -1518,7 +1491,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
15181491
variant: "ghost",
15191492
size: "normal",
15201493
style: control(),
1521-
class: "min-w-0 max-w-[320px] text-13-regular group",
1494+
class: "min-w-0 max-w-[320px] text-13-regular text-text-base group",
15221495
}}
15231496
>
15241497
<Show when={local.model.current()?.provider?.id}>
@@ -1547,12 +1520,34 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
15471520
current={local.model.variant.current() ?? "default"}
15481521
label={(x) => (x === "default" ? language.t("common.default") : x)}
15491522
onSelect={(x) => local.model.variant.set(x === "default" ? undefined : x)}
1550-
class="capitalize max-w-[160px]"
1551-
valueClass="truncate text-13-regular"
1523+
class="capitalize max-w-[160px] text-text-base"
1524+
valueClass="truncate text-13-regular text-text-base"
15521525
triggerStyle={control()}
15531526
variant="ghost"
15541527
/>
15551528
</TooltipKeybind>
1529+
<TooltipKeybind
1530+
placement="top"
1531+
gutter={8}
1532+
title={acceptLabel()}
1533+
keybind={command.keybind("permissions.autoaccept")}
1534+
>
1535+
<Button
1536+
data-action="prompt-permissions"
1537+
variant="ghost"
1538+
onClick={toggleAccept}
1539+
classList={{
1540+
"h-7 w-7 p-0 shrink-0 flex items-center justify-center": true,
1541+
"text-text-base": !accepting(),
1542+
"hover:bg-surface-success-base": accepting(),
1543+
}}
1544+
style={control()}
1545+
aria-label={acceptLabel()}
1546+
aria-pressed={accepting()}
1547+
>
1548+
<Icon name="shield" size="small" classList={{ "text-icon-success-base": accepting() }} />
1549+
</Button>
1550+
</TooltipKeybind>
15561551
</div>
15571552
</div>
15581553
</div>

packages/ui/src/components/icon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const icons = {
8282
check: `<path d="M5 11.9657L8.37838 14.7529L15 5.83398" stroke="currentColor" stroke-linecap="square"/>`,
8383
photo: `<path d="M16.6665 16.6666L11.6665 11.6666L9.99984 13.3333L6.6665 9.99996L3.08317 13.5833M2.9165 2.91663H17.0832V17.0833H2.9165V2.91663ZM13.3332 7.49996C13.3332 8.30537 12.6803 8.95829 11.8748 8.95829C11.0694 8.95829 10.4165 8.30537 10.4165 7.49996C10.4165 6.69454 11.0694 6.04163 11.8748 6.04163C12.6803 6.04163 13.3332 6.69454 13.3332 7.49996Z" stroke="currentColor" stroke-linecap="square"/>`,
8484
share: `<path d="M10.0013 12.0846L10.0013 3.33464M13.7513 6.66797L10.0013 2.91797L6.2513 6.66797M17.0846 10.418V17.0846H2.91797V10.418" stroke="currentColor" stroke-linecap="square"/>`,
85+
shield: `<path d="M7.49935 9.3737L9.16602 11.0404L12.4994 7.70703M9.99935 2.08203L17.0827 4.3737V9.92565C17.0827 14.0694 13.3327 16.2487 9.99935 18.047C6.66602 16.2487 2.91602 14.0694 2.91602 9.92565V4.3737L9.99935 2.08203Z" stroke="currentColor" stroke-linecap="square"/>`,
8586
download: `<path d="M13.9583 10.6257L10 14.584L6.04167 10.6257M10 2.08398V13.959M16.25 17.9173H3.75" stroke="currentColor" stroke-linecap="square"/>`,
8687
menu: `<path d="M2.5 5H17.5M2.5 10H17.5M2.5 15H17.5" stroke="currentColor" stroke-linecap="square"/>`,
8788
server: `<rect x="3.35547" y="1.92969" width="13.2857" height="16.1429" stroke="currentColor"/><rect x="3.35547" y="11.9297" width="13.2857" height="6.14286" stroke="currentColor"/><rect x="12.8555" y="14.2852" width="1.42857" height="1.42857" fill="currentColor"/><rect x="10" y="14.2852" width="1.42857" height="1.42857" fill="currentColor"/>`,

0 commit comments

Comments
 (0)