GeezerVison is showing github.com — feat(app): support current review data · anomalyco/opencode@e97a955
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/app/e2e/regression/review-line-comment.spec.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -143,9 +143,9 @@ async function openReview(page: Page) { | 143 | 143 |
| 144 | 144 | await page.goto(`/${base64Encode(directory)}/session/${sessionID}`) | 145 | 145 | await expectSessionTitle(page, title) | 146 | | - const diffResponse = page.waitForResponse((response) => new URL(response.url()).pathname === "/vcs/diff") | | 146 | + const diffResponse = page.waitForResponse((response) => new URL(response.url()).pathname === "/api/vcs/diff") | 147 | 147 | await page.getByRole("tab", { name: "Changes" }).click() | 148 | | - expect(await (await diffResponse).json()).toHaveLength(1) | | 148 | + expect((await (await diffResponse).json()).data).toHaveLength(1) | 149 | 149 |
| 150 | 150 | const review = page.locator('[data-component="session-review"]') | 151 | 151 | await expectAppVisible(review) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/review-state-persistence.spec.ts +8-6Lines changed: 8 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,18 +92,20 @@ async function setup(page: Page) { | 92 | 92 | route.fulfill({ | 93 | 93 | status: 200, | 94 | 94 | contentType: "application/json", | 95 | | - body: JSON.stringify({ branch: "feature", default_branch: "dev" }), | | 95 | + body: JSON.stringify({ location: { directory }, data: { branch: "feature", defaultBranch: "dev" } }), | 96 | 96 | }), | 97 | 97 | ) | 98 | 98 | await page.route("**/vcs/diff**", (route) => | 99 | 99 | route.fulfill({ | 100 | 100 | status: 200, | 101 | 101 | contentType: "application/json", | 102 | | - body: JSON.stringify( | 103 | | - new URL(route.request().url()).searchParams.get("mode") === "branch" | 104 | | - ? [diff("src/alpha.ts"), diff("src/beta.ts")] | 105 | | - : [diff("src/alpha.ts"), diff("src/gamma.ts")], | 106 | | - ), | | 102 | + body: JSON.stringify({ | | 103 | + location: { directory }, | | 104 | + data: | | 105 | + new URL(route.request().url()).searchParams.get("mode") === "branch" | | 106 | + ? [diff("src/alpha.ts"), diff("src/beta.ts")] | | 107 | + : [diff("src/alpha.ts"), diff("src/gamma.ts")], | | 108 | + }), | 107 | 109 | }), | 108 | 110 | ) | 109 | 111 | await page.addInitScript( | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/pages/session/file-tabs.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -235,7 +235,7 @@ export function SessionFileView(props: SessionFileViewProps) { | 235 | 235 | const source = props.diff | 236 | 236 | if (!source) return | 237 | 237 | const loaded = loadedDiff() | 238 | | - return normalize(loaded?.source === source && loaded.version === props.diffVersion ? loaded.value : source) | | 238 | + return normalize(loaded && loaded.source === source && loaded.version === props.diffVersion ? loaded.value : source) | 239 | 239 | }) | 240 | 240 |
| 241 | 241 | return ( | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/pages/session/review-tab.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { createEffect, onCleanup, type JSX } from "solid-js" | 2 | 2 | import { makeEventListener } from "@solid-primitives/event-listener" | 3 | 3 | import type { SnapshotFileDiff, VcsFileDiff } from "@opencode-ai/sdk/v2" | | 4 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 4 | 5 | import { SessionReview } from "@opencode-ai/session-ui/session-review" | 5 | 6 | import type { | 6 | 7 | SessionReviewCommentActions, | @@ -14,7 +15,7 @@ import type { LineComment } from "@/context/comments" | 14 | 15 |
| 15 | 16 | export type DiffStyle = "unified" | "split" | 16 | 17 |
| 17 | | -type ReviewDiff = SnapshotFileDiff | VcsFileDiff | | 18 | +type ReviewDiff = FileDiffInfo | SnapshotFileDiff | VcsFileDiff | 18 | 19 |
| 19 | 20 | export interface SessionReviewTabProps { | 20 | 21 | title?: JSX.Element | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/pages/session/session-side-panel.tsx +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,7 @@ import { IconButtonV2 } from "@opencode-ai/ui/v2/icon-button-v2" | 24 | 24 | import { KeybindV2 } from "@opencode-ai/ui/v2/keybind-v2" | 25 | 25 | import { TooltipV2 } from "@opencode-ai/ui/v2/tooltip-v2" | 26 | 26 | import type { SnapshotFileDiff, VcsFileDiff } from "@opencode-ai/sdk/v2" | | 27 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 27 | 28 | import { ConstrainDragYAxis, getDraggableId } from "@/utils/solid-dnd" | 28 | 29 | import { useDialog } from "@opencode-ai/ui/context/dialog" | 29 | 30 |
| @@ -56,15 +57,16 @@ import { setSessionHandoff } from "@/pages/session/handoff" | 56 | 57 | import { useSessionLayout } from "@/pages/session/session-layout" | 57 | 58 | import { SessionFileBrowserTab, type SessionFileBrowserState } from "@/pages/session/v2/session-file-browser-tab" | 58 | 59 |
| 59 | | -type RenderDiff = (SnapshotFileDiff & { file: string }) | VcsFileDiff | | 60 | +type ReviewDiff = FileDiffInfo | SnapshotFileDiff | VcsFileDiff | | 61 | +type RenderDiff = FileDiffInfo | (SnapshotFileDiff & { file: string }) | VcsFileDiff | 60 | 62 |
| 61 | | -function renderDiff(value: SnapshotFileDiff | VcsFileDiff): value is RenderDiff { | | 63 | +function renderDiff(value: ReviewDiff): value is RenderDiff { | 62 | 64 | return typeof value.file === "string" | 63 | 65 | } | 64 | 66 |
| 65 | 67 | export function SessionSidePanel(props: { | 66 | 68 | canReview: () => boolean | 67 | | - diffs: () => (SnapshotFileDiff | VcsFileDiff)[] | | 69 | + diffs: () => ReviewDiff[] | 68 | 70 | diffsReady: () => boolean | 69 | 71 | empty: () => string | 70 | 72 | hasReview: () => boolean | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/pages/session/v2/review-diff-kinds.ts +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { SnapshotFileDiff, VcsFileDiff } from "@opencode-ai/sdk/v2" | | 2 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 2 | 3 | import type { Kind } from "@/components/file-tree-v2" | 3 | 4 | import { normalizeFileTreeV2Path } from "@/components/file-tree-v2-model" | 4 | 5 |
| 5 | | -export type RenderDiff = (SnapshotFileDiff & { file: string }) | VcsFileDiff | | 6 | +export type RenderDiff = FileDiffInfo | (SnapshotFileDiff & { file: string }) | VcsFileDiff | 6 | 7 |
| 7 | 8 | export function normalizePath(p: string) { | 8 | 9 | return normalizeFileTreeV2Path(p) | 9 | 10 | } | 10 | 11 |
| 11 | | -export function filterRenderableDiff(value: SnapshotFileDiff | VcsFileDiff): value is RenderDiff { | | 12 | +export function filterRenderableDiff(value: FileDiffInfo | SnapshotFileDiff | VcsFileDiff): value is RenderDiff { | 12 | 13 | return typeof value.file === "string" | 13 | 14 | } | 14 | 15 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/pages/session/v2/review-panel-v2.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { createMemo, createResource, createSignal, Show, type JSX } from "solid-js" | 2 | 2 | import type { SnapshotFileDiff, VcsFileDiff } from "@opencode-ai/sdk/v2" | | 3 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 3 | 4 | import { | 4 | 5 | SESSION_REVIEW_V2_SIDEBAR_WIDTH_MAX, | 5 | 6 | SESSION_REVIEW_V2_SIDEBAR_WIDTH_MIN, | @@ -30,7 +31,7 @@ import { | 30 | 31 | import type { ReviewPanelV2State } from "@/pages/session/v2/review-panel-v2-state" | 31 | 32 | import { applyFileListKeyDown, SessionFileListV2 } from "@/pages/session/v2/session-file-list-v2" | 32 | 33 |
| 33 | | -type ReviewDiff = SnapshotFileDiff | VcsFileDiff | | 34 | +type ReviewDiff = FileDiffInfo | SnapshotFileDiff | VcsFileDiff | 34 | 35 |
| 35 | 36 | export type ReviewPanelV2Props = { | 36 | 37 | title?: JSX.Element | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/utils/diffs.test.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { describe, expect, test } from "bun:test" | 2 | 2 | import type { SnapshotFileDiff } from "@opencode-ai/sdk/v2" | | 3 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 3 | 4 | import type { Message } from "@opencode-ai/sdk/v2/client" | 4 | 5 | import { diffs, message } from "./diffs" | 5 | 6 |
| @@ -9,7 +10,7 @@ const item = { | 9 | 10 | additions: 1, | 10 | 11 | deletions: 1, | 11 | 12 | status: "modified", | 12 | | -} satisfies SnapshotFileDiff | | 13 | +} satisfies FileDiffInfo & SnapshotFileDiff | 13 | 14 |
| 14 | 15 | describe("diffs", () => { | 15 | 16 | test("keeps valid arrays", () => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/utils/diffs.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { SnapshotFileDiff, VcsFileDiff } from "@opencode-ai/sdk/v2" | | 2 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 2 | 3 | import type { Message } from "@opencode-ai/sdk/v2/client" | 3 | 4 |
| 4 | | -type Diff = SnapshotFileDiff | VcsFileDiff | | 5 | +type Diff = FileDiffInfo | SnapshotFileDiff | VcsFileDiff | 5 | 6 |
| 6 | 7 | function diff(value: unknown): value is Diff { | 7 | 8 | if (!value || typeof value !== "object" || Array.isArray(value)) return false | |
Collapse file Copy file name to clipboardExpand all lines: packages/session-ui/src/components/session-diff.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { parseDiffFromFile, parsePatchFiles, type FileDiffMetadata } from "@pierre/diffs" | 2 | 2 | import { parsePatch } from "diff" | 3 | 3 | import type { SnapshotFileDiff, VcsFileDiff } from "@opencode-ai/sdk/v2" | | 4 | +import type { FileDiffInfo } from "@opencode-ai/client/promise" | 4 | 5 |
| 5 | 6 | type LegacyDiff = { | 6 | 7 | file: string | @@ -13,7 +14,7 @@ type LegacyDiff = { | 13 | 14 | } | 14 | 15 |
| 15 | 16 | type SnapshotDiff = SnapshotFileDiff & { file: string } | 16 | | -type ReviewDiff = SnapshotDiff | VcsFileDiff | LegacyDiff | | 17 | +type ReviewDiff = SnapshotDiff | FileDiffInfo | VcsFileDiff | LegacyDiff | 17 | 18 | export type DiffSource = Pick<LegacyDiff, "file" | "patch" | "before" | "after"> | 18 | 19 |
| 19 | 20 | export type ViewDiff = { | |
|