GeezerVison is showing github.com — Merge branch 'dev' into db-lock-retry-v2 · anomalyco/opencode@aae3d3c
File treeExpand file treeCollapse file tree Open diff view settings console/app/src/component
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/command-palette.spec.ts +46-2Lines changed: 46 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -85,13 +85,52 @@ test("appends search results without resetting the selected command", async ({ p | 85 | 85 | await expect(dialog.getByRole("option", { name: "Copy Project ID", exact: true })).toHaveCount(0) | 86 | 86 | }) | 87 | 87 |
| 88 | | -test("keeps the automatically selected file when session results arrive later", async ({ page }) => { | 89 | | - const warnings = captureConsoleWarnings(page) | | 88 | +test("selects the first session when it arrives above automatically selected files", async ({ page }) => { | 90 | 89 | const { dialog, input } = await openCommandPalette(page) | 91 | 90 | const sessions = Promise.withResolvers<void>() | 92 | 91 | await page.route("**/api/fs/find?*", (route) => | 93 | 92 | route.fulfill({ json: { data: [{ path: "README.md", type: "file" }] } }), | 94 | 93 | ) | | 94 | + await page.route("**/api/session?*", async (route) => { | | 95 | + await sessions.promise | | 96 | + await route.fulfill({ | | 97 | + json: { | | 98 | + data: Array.from({ length: 18 }, (_, index) => ({ | | 99 | + ...paletteSession, | | 100 | + id: index === 0 ? paletteSession.id : `ses_palette_readme_${index}`, | | 101 | + location: { directory: paletteSession.directory }, | | 102 | + title: `README work ${index + 1}`, | | 103 | + })), | | 104 | + }, | | 105 | + }) | | 106 | + }) | | 107 | + await input.fill("README") | | 108 | + await expect(dialog.getByRole("option", { name: "/ README.md", exact: true })).toHaveAttribute( | | 109 | + "aria-selected", | | 110 | + "true", | | 111 | + ) | | 112 | + sessions.resolve() | | 113 | + const first = dialog.getByRole("option", { name: /README work 1 command-palette/ }) | | 114 | + const second = dialog.getByRole("option", { name: /README work 2 command-palette/ }) | | 115 | + await expect(first).toHaveAttribute("aria-selected", "true") | | 116 | + await expect(first).toBeInViewport() | | 117 | + await input.press("ArrowDown") | | 118 | + await expect(second).toHaveAttribute("aria-selected", "true") | | 119 | + await expect(second).toBeInViewport() | | 120 | + await input.press("ArrowUp") | | 121 | + await expect(first).toHaveAttribute("aria-selected", "true") | | 122 | + await input.press("Enter") | | 123 | + await expect(dialog).toHaveCount(0) | | 124 | + await expect(page.getByRole("heading", { name: paletteSession.title, exact: true })).toBeVisible() | | 125 | +}) | | 126 | + | | 127 | +test("keeps a keyboard-selected file when session results arrive later", async ({ page }) => { | | 128 | + const warnings = captureConsoleWarnings(page) | | 129 | + const { dialog, input } = await openCommandPalette(page) | | 130 | + const sessions = Promise.withResolvers<void>() | | 131 | + await page.route("**/api/fs/find?*", (route) => | | 132 | + route.fulfill({ json: { data: [{ path: "README.txt", type: "file" }, { path: "README.md", type: "file" }] } }), | | 133 | + ) | 95 | 134 | await page.route("**/api/session?*", async (route) => { | 96 | 135 | await sessions.promise | 97 | 136 | await route.fulfill({ | @@ -102,6 +141,11 @@ test("keeps the automatically selected file when session results arrive later", | 102 | 141 | }) | 103 | 142 | await input.fill("README") | 104 | 143 | const file = dialog.getByRole("option", { name: "/ README.md", exact: true }) | | 144 | + await expect(dialog.getByRole("option", { name: "/ README.txt", exact: true })).toHaveAttribute( | | 145 | + "aria-selected", | | 146 | + "true", | | 147 | + ) | | 148 | + await input.press("ArrowDown") | 105 | 149 | await expect(file).toHaveAttribute("aria-selected", "true") | 106 | 150 | sessions.resolve() | 107 | 151 | await expect(dialog.getByRole("option", { name: /README work/ })).toBeVisible() | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/shell/commands/dialog.tsx +16-13Lines changed: 16 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,7 @@ import { Dialog, DialogBody } from "@opencode/ui/dialog" | 5 | 5 | import { Icon } from "@opencode/ui/icon" | 6 | 6 | import { Keybind } from "@opencode/ui/keybind" | 7 | 7 | import { TextInput } from "@opencode/ui/text-input" | 8 | | -import { createEffect, createMemo, For, Match, Show, Switch } from "solid-js" | | 8 | +import { createEffect, createMemo, For, Match, onCleanup, Show, Switch } from "solid-js" | 9 | 9 | import { createStore } from "solid-js/store" | 10 | 10 | import { formatKeybindParts } from "@/shell/commands/command" | 11 | 11 | import { useLanguage } from "@/runtime/i18n/language" | @@ -70,13 +70,13 @@ export function CommandPaletteView(props: { | 70 | 70 | }) { | 71 | 71 | const language = useLanguage() | 72 | 72 | const tabs = useTabs() | 73 | | - const [store, setStore] = createStore({ query: "", active: undefined as string | undefined }) | | 73 | + const [store, setStore] = createStore<{ query: string; active?: string }>({ query: "" }) | 74 | 74 |
| 75 | 75 | const search = createCommandPaletteSearch({ query: () => store.query, items: props.items, sources: props.sources }) | 76 | 76 | const visibleEntries = search.items | 77 | 77 | const groupedEntries = createMemo(() => groups(visibleEntries())) | 78 | 78 |
| 79 | | - // Keep keyboard selection stable when another search source adds results. | | 79 | + // Follow the first result until the user explicitly chooses a row. | 80 | 80 | const activeEntry = createMemo( | 81 | 81 | () => visibleEntries().find((entry) => entry.id === store.active) ?? visibleEntries()[0], | 82 | 82 | ) | @@ -85,28 +85,31 @@ export function CommandPaletteView(props: { | 85 | 85 | () => new Set(tabs.store.flatMap((tab) => (tab.type === "session" ? [`${tab.server}\0${tab.sessionId}`] : []))), | 86 | 86 | ) | 87 | 87 |
| 88 | | - createEffect(() => { | 89 | | - // Pin automatic selection too: a later source can insert rows before it. | 90 | | - const id = activeEntry()?.id | 91 | | - | 92 | | - if (store.active !== id) setStore("active", id) | 93 | | - }) | 94 | | - | 95 | 88 | createEffect(() => { | 96 | 89 | props.highlight(activeEntry()) | 97 | 90 | }) | 98 | 91 |
| 99 | 92 | let resultsRef: HTMLDivElement | undefined | 100 | 93 |
| | 94 | + createEffect(() => { | | 95 | + // Incoming results can move an explicitly selected row below the viewport. | | 96 | + visibleEntries() | | 97 | + | | 98 | + if (!activeEntry()) return | | 99 | + | | 100 | + const frame = requestAnimationFrame(() => { | | 101 | + resultsRef?.querySelector("[data-active]")?.scrollIntoView({ block: "nearest" }) | | 102 | + }) | | 103 | + | | 104 | + onCleanup(() => cancelAnimationFrame(frame)) | | 105 | + }) | | 106 | + | 101 | 107 | const move = (delta: -1 | 1) => { | 102 | 108 | const count = visibleEntries().length | 103 | 109 |
| 104 | 110 | if (count === 0) return | 105 | 111 | const index = visibleEntries().findIndex((entry) => entry.id === activeEntry()?.id) | 106 | 112 | setStore("active", visibleEntries()[(index + delta + count) % count].id) | 107 | | - requestAnimationFrame(() => { | 108 | | - resultsRef?.querySelector("[data-active]")?.scrollIntoView({ block: "nearest" }) | 109 | | - }) | 110 | 113 | } | 111 | 114 |
| 112 | 115 | const handleKeyDown = (event: KeyboardEvent) => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/effect/api/api.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1663,8 +1663,9 @@ export interface CredentialApi<E = never> { | 1663 | 1663 | readonly remove: CredentialRemoveOperation<E> | 1664 | 1664 | } | 1665 | 1665 |
| | 1666 | +export type ProjectListInput = { readonly archived?: boolean | undefined } | 1666 | 1667 | export type ProjectListOutput = ReadonlyArray<Project.Info> | 1667 | | -export type ProjectListOperation<E = never> = () => Effect.Effect<ProjectListOutput, E> | | 1668 | +export type ProjectListOperation<E = never> = (input?: ProjectListInput) => Effect.Effect<ProjectListOutput, E> | 1668 | 1669 |
| 1669 | 1670 | export type ProjectUpdateInput = { | 1670 | 1671 | readonly projectID: Project.ID | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/effect/generated/client.ts +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -164,6 +164,7 @@ import type { | 164 | 164 | CredentialActivateOutput, | 165 | 165 | CredentialRemoveInput, | 166 | 166 | CredentialRemoveOutput, | | 167 | + ProjectListInput, | 167 | 168 | ProjectListOutput, | 168 | 169 | ProjectUpdateInput, | 169 | 170 | ProjectUpdateOutput, | @@ -1102,8 +1103,10 @@ const adaptGroupCredential = (raw: RawClient["server.credential"]) => ({ | 1102 | 1103 | remove: EndpointCredentialRemove(raw), | 1103 | 1104 | }) | 1104 | 1105 |
| 1105 | | -const EndpointProjectList = (raw: RawClient["server.project"]) => () => | 1106 | | - preserveEffect<ProjectListOutput>()(raw["project.list"]({}).pipe(Effect.mapError(mapClientError))) | | 1106 | +const EndpointProjectList = (raw: RawClient["server.project"]) => (input?: ProjectListInput) => | | 1107 | + preserveEffect<ProjectListOutput>()( | | 1108 | + raw["project.list"]({ query: { archived: input?.["archived"] } }).pipe(Effect.mapError(mapClientError)), | | 1109 | + ) | 1107 | 1110 |
| 1108 | 1111 | const EndpointProjectUpdate = (raw: RawClient["server.project"]) => (input: ProjectUpdateInput) => | 1109 | 1112 | preserveEffect<ProjectUpdateOutput>()( | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/promise/generated/client.ts +10-2Lines changed: 10 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -158,6 +158,7 @@ import type { | 158 | 158 | CredentialActivateOutput, | 159 | 159 | CredentialRemoveInput, | 160 | 160 | CredentialRemoveOutput, | | 161 | + ProjectListInput, | 161 | 162 | ProjectListOutput, | 162 | 163 | ProjectUpdateInput, | 163 | 164 | ProjectUpdateOutput, | @@ -1473,9 +1474,16 @@ export function make(options: ClientOptions) { | 1473 | 1474 | ), | 1474 | 1475 | }, | 1475 | 1476 | project: { | 1476 | | - list: (requestOptions?: RequestOptions) => | | 1477 | + list: (input?: ProjectListInput, requestOptions?: RequestOptions) => | 1477 | 1478 | request<ProjectListOutput>( | 1478 | | - { method: "GET", path: `/api/project`, successStatus: 200, declaredStatuses: [400, 401, 404], empty: false }, | | 1479 | + { | | 1480 | + method: "GET", | | 1481 | + path: `/api/project`, | | 1482 | + query: { archived: input?.["archived"] }, | | 1483 | + successStatus: 200, | | 1484 | + declaredStatuses: [400, 401, 404], | | 1485 | + empty: false, | | 1486 | + }, | 1479 | 1487 | requestOptions, | 1480 | 1488 | ), | 1481 | 1489 | update: (input: ProjectUpdateInput, requestOptions?: RequestOptions) => | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/promise/generated/types.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -234,7 +234,7 @@ export type ProjectIcon = { url?: string; override?: string; color?: string } | 234 | 234 |
| 235 | 235 | export type ProjectCommands = { start?: string } | 236 | 236 |
| 237 | | -export type ProjectTime = { created: number; updated: number; active: number } | | 237 | +export type ProjectTime = { created: number; updated: number; active: number; archived?: number } | 238 | 238 |
| 239 | 239 | export type PermissionID = string | 240 | 240 |
| @@ -6127,6 +6127,8 @@ export type CredentialRemoveInput = { readonly credentialID: { readonly credenti | 6127 | 6127 |
| 6128 | 6128 | export type CredentialRemoveOutput = void | 6129 | 6129 |
| | 6130 | +export type ProjectListInput = { readonly archived?: { readonly archived?: boolean | undefined }["archived"] } | | 6131 | + | 6130 | 6132 | export type ProjectListOutput = Array<Project> | 6131 | 6133 |
| 6132 | 6134 | export type ProjectUpdateInput = { | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/solid/data.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1828,7 +1828,9 @@ export function createData(config: CreateDataInput) { | 1828 | 1828 | }, | 1829 | 1829 | project: { | 1830 | 1830 | list() { | 1831 | | - return Object.values(store.project.info).toSorted((a, b) => b.time.active - a.time.active) | | 1831 | + return Object.values(store.project.info) | | 1832 | + .filter((project) => project.time.archived === undefined) | | 1833 | + .toSorted((a, b) => b.time.active - a.time.active) | 1832 | 1834 | }, | 1833 | 1835 | get(projectID: string) { | 1834 | 1836 | return store.project.info[projectID] | |
Collapse file Copy file name to clipboardExpand all lines: packages/console/app/src/component/header.tsx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -186,7 +186,7 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo | 186 | 186 | </li> | 187 | 187 | <Show when={props.zen || props.go}> | 188 | 188 | <li> | 189 | | - <a href="/auth">{i18n.t("nav.login")}</a> | | 189 | + <a href="/console">{i18n.t("nav.login")}</a> | 190 | 190 | </li> | 191 | 191 | </Show> | 192 | 192 | <Show when={!props.hideGetStarted}> | @@ -311,7 +311,7 @@ export function Header(props: { zen?: boolean; go?: boolean; hideGetStarted?: bo | 311 | 311 | </li> | 312 | 312 | <Show when={props.zen || props.go}> | 313 | 313 | <li> | 314 | | - <a href="/auth">{i18n.t("nav.login")}</a> | | 314 | + <a href="/console">{i18n.t("nav.login")}</a> | 315 | 315 | </li> | 316 | 316 | </Show> | 317 | 317 | <Show when={!props.hideGetStarted}> | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/schema.json +12-2Lines changed: 12 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "version": "7", | 3 | 3 | "dialect": "sqlite", | 4 | | - "id": "e98619ef-c334-45e3-8c48-9932ed1ef290", | 5 | | - "prevIds": ["be60f352-8da1-40e1-8d70-dc41121cfbc5"], | | 4 | + "id": "5067fae0-90ff-4601-82d7-dd050ea9dc8f", | | 5 | + "prevIds": ["e98619ef-c334-45e3-8c48-9932ed1ef290"], | 6 | 6 | "ddl": [ | 7 | 7 | { | 8 | 8 | "name": "account_state", | | 710 | 710 | "entityType": "columns", | 711 | 711 | "table": "project" | 712 | 712 | }, | | 713 | + { | | 714 | + "type": "integer", | | 715 | + "notNull": false, | | 716 | + "autoincrement": false, | | 717 | + "default": null, | | 718 | + "generated": null, | | 719 | + "name": "time_archived", | | 720 | + "entityType": "columns", | | 721 | + "table": "project" | | 722 | + }, | 713 | 723 | { | 714 | 724 | "type": "text", | 715 | 725 | "notNull": true, | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/src/database/migration.gen.ts +2Lines changed: 2 additions & 0 deletions
|