GeezerVison is showing github.com — fix(tui): show current location in working copies; order by created; … · isaacfinnegan/whispercode@1c2a2b0
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/core/src/project.ts +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,7 @@ export * as ProjectV2 from "./project" | 2 | 2 | export * as Project from "./project" | 3 | 3 |
| 4 | 4 | import { Context, Effect, Layer, Schema } from "effect" | 5 | | -import { eq } from "drizzle-orm" | | 5 | +import { asc, desc, eq } from "drizzle-orm" | 6 | 6 | import path from "path" | 7 | 7 | import { AbsolutePath, withStatics } from "./schema" | 8 | 8 | import { FSUtil } from "./fs-util" | @@ -76,11 +76,10 @@ export const layer = Layer.effect( | 76 | 76 | .select({ directory: ProjectDirectoryTable.directory }) | 77 | 77 | .from(ProjectDirectoryTable) | 78 | 78 | .where(eq(ProjectDirectoryTable.project_id, input.projectID)) | | 79 | + .orderBy(desc(ProjectDirectoryTable.time_created), asc(ProjectDirectoryTable.directory)) | 79 | 80 | .all() | 80 | 81 | .pipe(Effect.orDie) | 81 | | - return rows | 82 | | - .toSorted((a, b) => a.directory.localeCompare(b.directory)) | 83 | | - .map((row) => AbsolutePath.make(row.directory)) | | 82 | + return rows.map((row) => AbsolutePath.make(row.directory)) | 84 | 83 | }) | 85 | 84 |
| 86 | 85 | const cached = Effect.fnUntraced(function* (dir: string) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/project.test.ts +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,7 +65,7 @@ describe("Project directories schemas", () => { | 65 | 65 | }), | 66 | 66 | ) | 67 | 67 |
| 68 | | - it.effect("lists stored project directories only for the requested project", () => | | 68 | + it.effect("lists stored project directories newest first for the requested project", () => | 69 | 69 | Effect.gen(function* () { | 70 | 70 | const project = yield* ProjectV2.Service | 71 | 71 | const { db } = yield* Database.Service | @@ -82,16 +82,16 @@ describe("Project directories schemas", () => { | 82 | 82 | yield* db | 83 | 83 | .insert(ProjectDirectoryTable) | 84 | 84 | .values([ | 85 | | - { project_id: projectID, directory: AbsolutePath.make("/repo/z"), type: "root" }, | 86 | | - { project_id: projectID, directory: AbsolutePath.make("/repo/a"), type: "main" }, | 87 | | - { project_id: otherID, directory: AbsolutePath.make("/other"), type: "main" }, | | 85 | + { project_id: projectID, directory: AbsolutePath.make("/repo/z"), type: "root", time_created: 2 }, | | 86 | + { project_id: projectID, directory: AbsolutePath.make("/repo/a"), type: "main", time_created: 1 }, | | 87 | + { project_id: otherID, directory: AbsolutePath.make("/other"), type: "main", time_created: 3 }, | 88 | 88 | ]) | 89 | 89 | .run() | 90 | 90 | .pipe(Effect.orDie) | 91 | 91 |
| 92 | 92 | expect(yield* project.directories({ projectID })).toEqual([ | 93 | | - AbsolutePath.make("/repo/a"), | 94 | 93 | AbsolutePath.make("/repo/z"), | | 94 | + AbsolutePath.make("/repo/a"), | 95 | 95 | ]) | 96 | 96 | }), | 97 | 97 | ) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/component/dialog-move-session.tsx +9-4Lines changed: 9 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,11 @@ const REFRESH_FRAMES = ["■", "⬝"] | 15 | 15 |
| 16 | 16 | export type MoveSessionSelection = { type: "directory"; directory: string } | { type: "new" } | 17 | 17 |
| 18 | | -export function DialogMoveSession(props: { projectID: string; onSelect: (selection: MoveSessionSelection) => void }) { | | 18 | +export function DialogMoveSession(props: { | | 19 | + projectID: string | | 20 | + current?: MoveSessionSelection | | 21 | + onSelect: (selection: MoveSessionSelection) => void | | 22 | +}) { | 19 | 23 | const dialog = useDialog() | 20 | 24 | const sdk = useSDK() | 21 | 25 | const dimensions = useTerminalDimensions() | @@ -42,7 +46,7 @@ export function DialogMoveSession(props: { projectID: string; onSelect: (selecti | 42 | 46 | }, | 43 | 47 | ) | 44 | 48 |
| 45 | | - const options = createMemo<DialogSelectOption<string | undefined>[]>(() => { | | 49 | + const options = createMemo<DialogSelectOption<MoveSessionSelection | undefined>[]>(() => { | 46 | 50 | if (directories.loading) return [{ title: "Loading project directories...", value: undefined }] | 47 | 51 | if (directories.error) return [{ title: "Failed to load project directories", value: undefined }] | 48 | 52 | const data = directories() | @@ -88,7 +92,7 @@ export function DialogMoveSession(props: { projectID: string; onSelect: (selecti | 88 | 92 | <span style={{ fg: theme.textMuted }}>{visible.slice(split)}</span> | 89 | 93 | </> | 90 | 94 | ) : undefined, | 91 | | - value: item.location, | | 95 | + value: { type: "directory", directory: item.location } as const, | 92 | 96 | category: item.root === data?.main ? "Project" : "Working copies", | 93 | 97 | titleWidth, | 94 | 98 | truncateTitle: "left" as const, | @@ -103,8 +107,9 @@ export function DialogMoveSession(props: { projectID: string; onSelect: (selecti | 103 | 107 | <DialogSelect | 104 | 108 | title="Move session" | 105 | 109 | options={options()} | | 110 | + current={props.current} | 106 | 111 | onSelect={(option) => { | 107 | | - if (option.value) props.onSelect({ type: "directory", directory: option.value }) | | 112 | + if (option.value) props.onSelect(option.value) | 108 | 113 | }} | 109 | 114 | actions={[ | 110 | 115 | { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/component/prompt/move.tsx +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,9 +51,12 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess | 51 | 51 | function open() { | 52 | 52 | const projectID = input.projectID() | 53 | 53 | if (!projectID) return | | 54 | + const sessionID = input.sessionID() | | 55 | + const session = sessionID ? sync.session.get(sessionID) : undefined | 54 | 56 | dialog.replace(() => ( | 55 | 57 | <DialogMoveSession | 56 | 58 | projectID={projectID} | | 59 | + current={homeDestination?.destination() ?? (session ? { type: "directory", directory: session.directory } : undefined)} | 57 | 60 | onSelect={(selection) => { | 58 | 61 | const sessionID = input.sessionID() | 59 | 62 | if (!sessionID) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/config/keybind.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -207,7 +207,7 @@ export const Definitions = { | 207 | 207 | "dialog.select.submit": keybind("return", "Submit selected dialog item"), | 208 | 208 | "dialog.prompt.submit": keybind("return", "Submit dialog prompt"), | 209 | 209 | "dialog.mcp.toggle": keybind("space", "Toggle MCP in MCP dialog"), | 210 | | - "dialog.move_session.new": keybind("ctrl+w", "New project copy"), | | 210 | + "dialog.move_session.new": keybind("ctrl+m", "New project copy"), | 211 | 211 | "prompt.autocomplete.prev": keybind("up,ctrl+p", "Move to previous autocomplete item"), | 212 | 212 | "prompt.autocomplete.next": keybind("down,ctrl+n", "Move to next autocomplete item"), | 213 | 213 | "prompt.autocomplete.hide": keybind("escape", "Hide autocomplete"), | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/home/footer.tsx +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,11 +11,10 @@ function Directory(props: { api: TuiPluginApi }) { | 11 | 11 | const destination = useHomeSessionDestination() | 12 | 12 | const dir = createMemo(() => { | 13 | 13 | const selected = destination?.destination() | 14 | | - if (selected?.type === "new") return | 15 | | - if (selected?.type === "directory") return selected.directory.replace(Global.Path.home, "~") | 16 | | - const dir = props.api.state.path.directory || process.cwd() | 17 | | - const out = dir.replace(Global.Path.home, "~") | 18 | | - const branch = props.api.state.vcs?.branch | | 14 | + if (!selected || selected.type === "new") return | | 15 | + const out = selected.directory.replace(Global.Path.home, "~") | | 16 | + const branch = | | 17 | + selected.directory === (props.api.state.path.directory || process.cwd()) ? props.api.state.vcs?.branch : undefined | 19 | 18 | if (branch) return out + ":" + branch | 20 | 19 | return out | 21 | 20 | }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/routes/home/session-destination.tsx +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { createContext, createSignal, useContext, type Accessor, type ParentProps, type Setter } from "solid-js" | | 1 | +import { createContext, createMemo, createSignal, useContext, type Accessor, type ParentProps, type Setter } from "solid-js" | | 2 | +import { useSync } from "../../context/sync" | 2 | 3 |
| 3 | 4 | export type HomeSessionDestination = { type: "directory"; directory: string } | { type: "new" } | 4 | 5 |
| @@ -11,7 +12,11 @@ type Context = { | 11 | 12 | const HomeSessionDestinationContext = createContext<Context>() | 12 | 13 |
| 13 | 14 | export function HomeSessionDestinationProvider(props: ParentProps) { | 14 | | - const [destination, setDestination] = createSignal<HomeSessionDestination>() | | 15 | + const sync = useSync() | | 16 | + const [selected, setDestination] = createSignal<HomeSessionDestination>() | | 17 | + const destination = createMemo<HomeSessionDestination>(() => | | 18 | + selected() ?? { type: "directory", directory: sync.path.directory || process.cwd() }, | | 19 | + ) | 15 | 20 | return ( | 16 | 21 | <HomeSessionDestinationContext.Provider | 17 | 22 | value={{ destination, setDestination, clear: () => setDestination(undefined) }} | |
|