Skip to content

Commit caafdc2

Browse files
adamdotdeviniamdavidhill
authored andcommitted
feat(app): session timeline/turn rework (anomalyco#13196)
Co-authored-by: David Hill <[email protected]>
1 parent 1526a9c commit caafdc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3084
-2403
lines changed

packages/app/e2e/models/model-picker.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ test("smoke model selection updates prompt footer", async ({ page, gotoSession }
2828
const key = await target.getAttribute("data-key")
2929
if (!key) throw new Error("Failed to resolve model key from list item")
3030

31-
const name = (await target.locator("span").first().innerText()).trim()
3231
const model = key.split(":").slice(1).join(":")
3332

3433
await input.fill(model)
@@ -37,6 +36,13 @@ test("smoke model selection updates prompt footer", async ({ page, gotoSession }
3736

3837
await expect(dialog).toHaveCount(0)
3938

40-
const form = page.locator(promptSelector).locator("xpath=ancestor::form[1]")
41-
await expect(form.locator('[data-component="button"]').filter({ hasText: name }).first()).toBeVisible()
39+
await page.locator(promptSelector).click()
40+
await page.keyboard.type("/model")
41+
await expect(command).toBeVisible()
42+
await command.hover()
43+
await page.keyboard.press("Enter")
44+
45+
const dialogAgain = page.getByRole("dialog")
46+
await expect(dialogAgain).toBeVisible()
47+
await expect(dialogAgain.locator(`[data-slot="list-item"][data-key="${key}"][data-selected="true"]`)).toBeVisible()
4248
})

packages/app/src/components/dialog-select-model.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function ModelSelectorPopover(props: {
121121
}}
122122
modal={false}
123123
placement="top-start"
124-
gutter={8}
124+
gutter={4}
125125
>
126126
<Kobalte.Trigger as={props.triggerAs ?? "div"} {...props.triggerProps}>
127127
{props.children}

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

Lines changed: 296 additions & 142 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ export const PromptContextItems: Component<ContextItemsProps> = (props) => {
4141
>
4242
<div
4343
classList={{
44-
"group shrink-0 flex flex-col rounded-[6px] pl-2 pr-1 py-1 max-w-[200px] h-12 transition-all transition-transform shadow-xs-border hover:shadow-xs-border-hover": true,
45-
"cursor-pointer hover:bg-surface-interactive-weak": !!item.commentID && !selected,
46-
"cursor-pointer bg-surface-interactive-hover hover:bg-surface-interactive-hover shadow-xs-border-hover":
47-
selected,
44+
"group shrink-0 flex flex-col rounded-[6px] pl-2 pr-1 py-1 max-w-[200px] h-12 cursor-default transition-all transition-transform shadow-xs-border hover:shadow-xs-border-hover": true,
45+
"hover:bg-surface-interactive-weak": !!item.commentID && !selected,
46+
"bg-surface-interactive-hover hover:bg-surface-interactive-hover shadow-xs-border-hover": selected,
4847
"bg-background-stronger": !selected,
4948
}}
5049
onClick={() => props.openComment(item)}

packages/app/src/components/prompt-input/placeholder.test.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,40 @@ describe("promptPlaceholder", () => {
99
mode: "shell",
1010
commentCount: 0,
1111
example: "example",
12+
suggest: true,
1213
t,
1314
})
1415
expect(value).toBe("prompt.placeholder.shell")
1516
})
1617

1718
test("returns summarize placeholders for comment context", () => {
18-
expect(promptPlaceholder({ mode: "normal", commentCount: 1, example: "example", t })).toBe(
19+
expect(promptPlaceholder({ mode: "normal", commentCount: 1, example: "example", suggest: true, t })).toBe(
1920
"prompt.placeholder.summarizeComment",
2021
)
21-
expect(promptPlaceholder({ mode: "normal", commentCount: 2, example: "example", t })).toBe(
22+
expect(promptPlaceholder({ mode: "normal", commentCount: 2, example: "example", suggest: true, t })).toBe(
2223
"prompt.placeholder.summarizeComments",
2324
)
2425
})
2526

26-
test("returns default placeholder with example", () => {
27+
test("returns default placeholder with example when suggestions enabled", () => {
2728
const value = promptPlaceholder({
2829
mode: "normal",
2930
commentCount: 0,
3031
example: "translated-example",
32+
suggest: true,
3133
t,
3234
})
3335
expect(value).toBe("prompt.placeholder.normal:translated-example")
3436
})
37+
38+
test("returns simple placeholder when suggestions disabled", () => {
39+
const value = promptPlaceholder({
40+
mode: "normal",
41+
commentCount: 0,
42+
example: "translated-example",
43+
suggest: false,
44+
t,
45+
})
46+
expect(value).toBe("prompt.placeholder.simple")
47+
})
3548
})

packages/app/src/components/prompt-input/placeholder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ type PromptPlaceholderInput = {
22
mode: "normal" | "shell"
33
commentCount: number
44
example: string
5+
suggest: boolean
56
t: (key: string, params?: Record<string, string>) => string
67
}
78

89
export function promptPlaceholder(input: PromptPlaceholderInput) {
910
if (input.mode === "shell") return input.t("prompt.placeholder.shell")
1011
if (input.commentCount > 1) return input.t("prompt.placeholder.summarizeComments")
1112
if (input.commentCount === 1) return input.t("prompt.placeholder.summarizeComment")
13+
if (!input.suggest) return input.t("prompt.placeholder.simple")
1214
return input.t("prompt.placeholder.normal", { example: input.example })
1315
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export const PromptPopover: Component<PromptPopoverProps> = (props) => {
4040
ref={(el) => {
4141
if (props.popover === "slash") props.setSlashPopoverRef(el)
4242
}}
43-
class="absolute inset-x-0 -top-3 -translate-y-full origin-bottom-left max-h-80 min-h-10
44-
overflow-auto no-scrollbar flex flex-col p-2 rounded-md
45-
border border-border-base bg-surface-raised-stronger-non-alpha shadow-md"
43+
class="absolute inset-x-0 -top-2 -translate-y-full origin-bottom-left max-h-80 min-h-10
44+
overflow-auto no-scrollbar flex flex-col p-2 rounded-[12px]
45+
bg-surface-raised-stronger-non-alpha shadow-[var(--shadow-lg-border-base)]"
4646
onMouseDown={(e) => e.preventDefault()}
4747
>
4848
<Switch>

packages/app/src/components/prompt-input/submit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,17 @@ export function createPromptSubmit(input: PromptSubmitInput) {
8080
queued.abort.abort()
8181
queued.cleanup()
8282
pending.delete(sessionID)
83+
globalSync.todo.set(sessionID, undefined)
8384
return Promise.resolve()
8485
}
8586
return sdk.client.session
8687
.abort({
8788
sessionID,
8889
})
8990
.catch(() => {})
91+
.finally(() => {
92+
globalSync.todo.set(sessionID, undefined)
93+
})
9094
}
9195

9296
const restoreCommentItems = (items: CommentItem[]) => {

0 commit comments

Comments
 (0)