Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): better right panel (new diffs styling) (#5260)
maria4fb03aff0bcd
diff --git a/apps/server/src/auth/RpcAuthorization.ts b/apps/server/src/auth/RpcAuthorization.tsindex fb753b9aa..c1d9f786a 100644--- a/apps/server/src/auth/RpcAuthorization.ts+++ b/apps/server/src/auth/RpcAuthorization.ts@@ -75,6 +75,7 @@ export const RPC_REQUIRED_SCOPES = {[WS_METHODS.vcsSwitchRef]: AuthOrchestrationOperateScope,[WS_METHODS.vcsInit]: AuthOrchestrationOperateScope,[WS_METHODS.reviewGetDiffPreview]: AuthReviewWriteScope,+ [WS_METHODS.reviewGetDiffFileContents]: AuthReviewWriteScope,[WS_METHODS.terminalOpen]: AuthTerminalOperateScope,[WS_METHODS.terminalAttach]: AuthTerminalOperateScope,[WS_METHODS.terminalWrite]: AuthTerminalOperateScope,diff --git a/apps/server/src/review/ReviewService.test.ts b/apps/server/src/review/ReviewService.test.tsindex 839eb73b2..01a469226 100644--- a/apps/server/src/review/ReviewService.test.ts+++ b/apps/server/src/review/ReviewService.test.ts@@ -57,6 +57,39 @@ describe("ReviewService", () => {}).pipe(Effect.provide(NodeServices.layer)),);+ it.effect("attributes file-content workspace violations to the file-content operation", () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const workspaceRoot = yield* fs.makeTempDirectoryScoped({ prefix: "t3-review-workspace-" });+ const outsideRoot = yield* fs.makeTempDirectoryScoped({ prefix: "t3-review-outside-" });+ const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-review-base-" });+ const detectCalls: Array<{ readonly cwd: string }> = [];++ const error = yield* Effect.gen(function* () {+ const review = yield* ReviewService.ReviewService;+ return yield* review+ .getDiffFileContents({+ cwd: outsideRoot,+ sourceKind: "working-tree",+ changeType: "change",+ baseRef: "HEAD",+ headRef: null,+ oldPath: "file.ts",+ newPath: "file.ts",+ })+ .pipe(Effect.flip);+ }).pipe(Effect.provide(makeLayer({ workspaceRoot, baseDir, detectCalls })));++ assert.strictEqual(error._tag, "VcsRepositoryDetectionError");+ assert.strictEqual(error.operation, "ReviewService.getDiffFileContents");+ assert.match(+ "detail" in error ? error.detail : "",+ /must stay within the configured workspace root/,+ );+ assert.deepStrictEqual(detectCalls, []);+ }).pipe(Effect.provide(NodeServices.layer)),+ );+it.effect("allows diff preview cwd inside the configured workspace root", () =>Effect.gen(function* () {const fs = yield* FileSystem.FileSystem;diff --git a/apps/server/src/review/ReviewService.ts b/apps/server/src/review/ReviewService.tsindex db1dc5bc8..275dcb416 100644--- a/apps/server/src/review/ReviewService.ts+++ b/apps/server/src/review/ReviewService.ts@@ -8,6 +8,8 @@ import * as Path from "effect/Path";import {VcsRepositoryDetectionError,VcsUnsupportedOperationError,+ type ReviewDiffFileContentsInput,+ type ReviewDiffFileContentsResult,type ReviewDiffPreviewError,type ReviewDiffPreviewInput,type ReviewDiffPreviewResult,@@ -23,6 +25,9 @@ export class ReviewService extends Context.Service<readonly getDiffPreview: (input: ReviewDiffPreviewInput,) => Effect.Effect<ReviewDiffPreviewResult, ReviewDiffPreviewError>;+ readonly getDiffFileContents: (+ input: ReviewDiffFileContentsInput,+ ) => Effect.Effect<ReviewDiffFileContentsResult, ReviewDiffPreviewError>;}>()("t3/review/ReviewService") {}@@ -58,6 +63,7 @@ export const make = Effect.gen(function* () {};const assertWorkspaceBoundCwd = Effect.fn("ReviewService.assertWorkspaceBoundCwd")(function* (+ operation: "ReviewService.getDiffPreview" | "ReviewService.getDiffFileContents",cwd: string,) {const [candidate, workspaceRoot, worktreesRoot] = yield* Effect.all([@@ -71,16 +77,19 @@ export const make = Effect.gen(function* () {}return yield* new VcsRepositoryDetectionError({- operation: "ReviewService.getDiffPreview",+ operation,cwd,- detail: "Review diff preview cwd must stay within the configured workspace root.",+ detail:+ operation === "ReviewService.getDiffPreview"+ ? "Review diff preview cwd must stay within the configured workspace root."+ : "Review diff file contents cwd must stay within the configured workspace root.",});});const getDiffPreview: ReviewService["Service"]["getDiffPreview"] = Effect.fn("ReviewService.getDiffPreview",)(function* (input) {- yield* assertWorkspaceBoundCwd(input.cwd);+ yield* assertWorkspaceBoundCwd("ReviewService.getDiffPreview", input.cwd);const handle = yield* vcsRegistry.detect({ cwd: input.cwd, requestedKind: "auto" });if (!handle) {@@ -106,8 +115,26 @@ export const make = Effect.gen(function* () {return yield* getDriverDiffPreview(input);});+ const getDiffFileContents: ReviewService["Service"]["getDiffFileContents"] = Effect.fn(+ "ReviewService.getDiffFileContents",+ )(function* (input) {+ yield* assertWorkspaceBoundCwd("ReviewService.getDiffFileContents", input.cwd);++ const handle = yield* vcsRegistry.detect({ cwd: input.cwd, requestedKind: "auto" });+ if (handle?.kind !== "git") {+ return yield* new VcsUnsupportedOperationError({+ operation: "ReviewService.getDiffFileContents",+ kind: handle?.kind ?? "unknown",+ detail: "Unchanged diff expansion currently requires a Git repository.",+ });+ }++ return yield* git.getReviewDiffFileContents(input);+ });+return ReviewService.of({getDiffPreview,+ getDiffFileContents,});});diff --git a/apps/server/src/server.test.ts b/apps/server/src/server.test.tsindex e67ece99f..8628aeef3 100644--- a/apps/server/src/server.test.ts+++ b/apps/server/src/server.test.ts@@ -5249,6 +5249,11 @@ it.layer(NodeServices.layer)("server router seam", (it) => {},],}),+ getDiffFileContents: () =>+ Effect.succeed({+ oldContents: "before\n",+ newContents: "after\n",+ }),},},});@@ -5363,6 +5368,22 @@ it.layer(NodeServices.layer)("server router seam", (it) => {),);assert.equal(diffPreview.sources[0]?.diff, "dirty-diff");++ const diffFileContents = yield* Effect.scoped(+ withWsRpcClient(wsUrl, (client) =>+ client[WS_METHODS.reviewGetDiffFileContents]({+ cwd: "/tmp/repo",+ sourceKind: "working-tree",+ changeType: "change",+ baseRef: "HEAD",+ headRef: null,+ oldPath: "README.md",+ newPath: "README.md",+ }),+ ),+ );+ assert.equal(diffFileContents.oldContents, "before\n");+ assert.equal(diffFileContents.newContents, "after\n");}).pipe(Effect.provide(NodeHttpServer.layerTest)),);diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.tsindex 55aa8f388..192efe5a7 100644--- a/apps/server/src/vcs/GitVcsDriver.ts+++ b/apps/server/src/vcs/GitVcsDriver.ts@@ -20,6 +20,8 @@ import {type VcsCreateWorktreeResult,type ReviewDiffPreviewInput,type ReviewDiffPreviewResult,+ type ReviewDiffFileContentsInput,+ type ReviewDiffFileContentsResult,type VcsInitInput,type VcsListRefsInput,type VcsListRefsResult,@@ -221,6 +223,9 @@ export class GitVcsDriver extends Context.Service<readonly getReviewDiffPreview: (input: ReviewDiffPreviewInput,) => Effect.Effect<ReviewDiffPreviewResult, GitCommandError>;+ readonly getReviewDiffFileContents: (+ input: ReviewDiffFileContentsInput,+ ) => Effect.Effect<ReviewDiffFileContentsResult, GitCommandError>;readonly readConfigValue: (cwd: string,key: string,diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.tsindex 24d53cd48..6e352f013 100644--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts@@ -14,7 +14,7 @@ import * as Stream from "effect/Stream";import * as TestClock from "effect/testing/TestClock";import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";-import { GitCommandError } from "@t3tools/contracts";+import { GitCommandError, type ReviewDiffFileContentsInput } from "@t3tools/contracts";import { ServerConfig } from "../config.ts";import { makeGitVcsDriverCore, splitNullSeparatedGitStdoutPaths } from "./GitVcsDriverCore.ts";import * as GitVcsDriver from "./GitVcsDriver.ts";@@ -78,6 +78,20 @@ const writeTextFile = (yield* fileSystem.writeFileString(filePath, contents);});+const makeReviewDiffFileContentsInput = (+ cwd: string,+ overrides: Partial<Omit<ReviewDiffFileContentsInput, "cwd">> = {},+): ReviewDiffFileContentsInput => ({+ cwd,+ sourceKind: "working-tree",+ changeType: "change",+ baseRef: "HEAD",+ headRef: null,+ oldPath: "README.md",+ newPath: "README.md",+ ...overrides,+});+const git = (cwd: string,args: ReadonlyArray<string>,@@ -803,6 +817,107 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {);}),);++ it.effect("loads full file contents for working-tree diff expansion", () =>+ Effect.gen(function* () {+ const cwd = yield* makeTmpDir();+ yield* initRepoWithCommit(cwd);+ const driver = yield* GitVcsDriver.GitVcsDriver;+ const pathService = yield* Path.Path;+ yield* writeTextFile(cwd, "nested/.keep", "");+ yield* writeTextFile(cwd, "README.md", "# changed\nunchanged context\n");++ const contents = yield* driver.getReviewDiffFileContents(+ makeReviewDiffFileContentsInput(pathService.join(cwd, "nested")),+ );++ assert.strictEqual(contents.oldContents, "# test\n");+ assert.strictEqual(contents.newContents, "# changed\nunchanged context\n");+ }),+ );++ it.effect("attributes working-tree filesystem failures to the failing operation", () =>+ Effect.gen(function* () {+ const cwd = yield* makeTmpDir();+ yield* initRepoWithCommit(cwd);+ const driver = yield* GitVcsDriver.GitVcsDriver;++ const error = yield* driver+ .getReviewDiffFileContents(+ makeReviewDiffFileContentsInput(cwd, {+ changeType: "new",+ oldPath: "missing.ts",+ newPath: "missing.ts",+ }),+ )+ .pipe(Effect.flip);++ assert.deepInclude(error, {+ _tag: "GitCommandError",+ operation: "GitVcsDriver.getReviewDiffFileContents.workingTree.fs.realPath",+ command: "fs.realPath",+ cwd,+ detail: "Could not resolve diff file 'missing.ts'.",+ });+ }),+ );++ it.effect("loads new and deleted files without reading their missing side", () =>+ Effect.gen(function* () {+ const cwd = yield* makeTmpDir();+ yield* initRepoWithCommit(cwd);+ const driver = yield* GitVcsDriver.GitVcsDriver;+ const fileSystem = yield* FileSystem.FileSystem;+ const pathService = yield* Path.Path;+ yield* writeTextFile(cwd, "added.ts", "export const added = true;\n");+ yield* fileSystem.remove(pathService.join(cwd, "README.md"));++ const [added, deleted] = yield* Effect.all([+ driver.getReviewDiffFileContents(+ makeReviewDiffFileContentsInput(cwd, {+ changeType: "new",+ oldPath: "added.ts",+ newPath: "added.ts",+ }),+ ),+ driver.getReviewDiffFileContents(+ makeReviewDiffFileContentsInput(cwd, { changeType: "deleted" }),+ ),+ ]);++ assert.deepStrictEqual(added, {+ oldContents: "",+ newContents: "export const added = true;\n",+ });+ assert.deepStrictEqual(deleted, {+ oldContents: "# test\n",+ newContents: "",+ });+ }),+ );++ it.effect("loads merge-base and head contents for branch diff expansion", () =>+ Effect.gen(function* () {+ const cwd = yield* makeTmpDir();+ const { initialBranch } = yield* initRepoWithCommit(cwd);+ const driver = yield* GitVcsDriver.GitVcsDriver;+ yield* git(cwd, ["checkout", "-b", "feature/context"]);+ yield* writeTextFile(cwd, "README.md", "# branch change\nunchanged context\n");+ yield* git(cwd, ["add", "README.md"]);+ yield* git(cwd, ["commit", "-m", "change readme"]);++ const contents = yield* driver.getReviewDiffFileContents(+ makeReviewDiffFileContentsInput(cwd, {+ sourceKind: "branch-range",+ baseRef: initialBranch,+ headRef: "feature/context",+ }),+ );++ assert.strictEqual(contents.oldContents, "# test\n");+ assert.strictEqual(contents.newContents, "# branch change\nunchanged context\n");+ }),+ );});describe("repository status", () => {diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.tsindex e44dc0486..abcb10a8c 100644--- a/apps/server/src/vcs/GitVcsDriverCore.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.ts@@ -21,6 +21,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";import {GitCommandError,+ type ReviewDiffFileContentsInput,type ReviewDiffPreviewInput,type ReviewDiffPreviewSource,type VcsRef,@@ -46,6 +47,7 @@ const RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES = 19_000;const RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES = 59_000;const REVIEW_DIFF_PATCH_MAX_OUTPUT_BYTES = 120_000;const REVIEW_UNTRACKED_DIFF_MAX_OUTPUT_BYTES = 80_000;+const REVIEW_DIFF_FILE_MAX_OUTPUT_BYTES = 1024 * 1024;const WORKSPACE_FILES_MAX_OUTPUT_BYTES = 120_000;const STATUS_UPSTREAM_REFRESH_INTERVAL = Duration.seconds(15);const STATUS_UPSTREAM_REFRESH_TIMEOUT = Duration.seconds(5);@@ -2270,6 +2272,163 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*};});+ const reviewDiffFileError = (+ input: ReviewDiffFileContentsInput,+ detail: string,+ cause?: unknown,+ ) =>+ new GitCommandError({+ operation: "GitVcsDriver.getReviewDiffFileContents",+ command: "git",+ cwd: input.cwd,+ detail,+ ...(cause === undefined ? {} : { cause }),+ });++ const isPathWithinRoot = (root: string, candidate: string) => {+ const relative = path.relative(root, candidate);+ return (+ relative === "" ||+ (relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))+ );+ };++ const readReviewFileAtRevision = Effect.fn("readReviewFileAtRevision")(function* (+ input: ReviewDiffFileContentsInput,+ revision: string,+ relativePath: string,+ ) {+ const result = yield* executeGit(+ "GitVcsDriver.getReviewDiffFileContents.revision",+ input.cwd,+ ["show", `${revision}:${relativePath}`],+ { maxOutputBytes: REVIEW_DIFF_FILE_MAX_OUTPUT_BYTES },+ );+ if (result.stdout.includes("\0")) {+ return yield* reviewDiffFileError(input, `Cannot expand binary file '${relativePath}'.`);+ }+ return result.stdout;+ });++ const readWorkingTreeReviewFile = Effect.fn("readWorkingTreeReviewFile")(function* (+ input: ReviewDiffFileContentsInput,+ repositoryRoot: string,+ ) {+ const fileError = (stage: string, detail: string, cause?: unknown) =>+ new GitCommandError({+ operation: `GitVcsDriver.getReviewDiffFileContents.workingTree.${stage}`,+ command: stage,+ cwd: input.cwd,+ detail,+ ...(cause === undefined ? {} : { cause }),+ });+ const requestedPath = path.resolve(repositoryRoot, input.newPath);+ if (!isPathWithinRoot(repositoryRoot, requestedPath)) {+ return yield* fileError(+ "path.resolve",+ `Diff file '${input.newPath}' resolves outside the review workspace.`,+ );+ }++ const [realRepositoryRoot, realTarget] = yield* Effect.all([+ fileSystem.realPath(repositoryRoot),+ fileSystem.realPath(requestedPath),+ ]).pipe(+ Effect.mapError((cause) =>+ fileError("fs.realPath", `Could not resolve diff file '${input.newPath}'.`, cause),+ ),+ );+ if (!isPathWithinRoot(realRepositoryRoot, realTarget)) {+ return yield* fileError(+ "fs.realPath",+ `Diff file '${input.newPath}' resolves outside the review workspace.`,+ );+ }++ const info = yield* fileSystem+ .stat(realTarget)+ .pipe(+ Effect.mapError((cause) =>+ fileError("fs.stat", `Could not inspect diff file '${input.newPath}'.`, cause),+ ),+ );+ if (info.type !== "File") {+ return yield* fileError("fs.stat", `Diff path '${input.newPath}' is not a file.`);+ }+ if (info.size > BigInt(REVIEW_DIFF_FILE_MAX_OUTPUT_BYTES)) {+ return yield* fileError(+ "fs.stat",+ `Diff file '${input.newPath}' exceeds the 1 MB expansion limit.`,+ );+ }++ const bytes = yield* fileSystem+ .readFile(realTarget)+ .pipe(+ Effect.mapError((cause) =>+ fileError("fs.readFile", `Could not read diff file '${input.newPath}'.`, cause),+ ),+ );+ if (bytes.includes(0)) {+ return yield* fileError("fs.readFile", `Cannot expand binary file '${input.newPath}'.`);+ }+ return new TextDecoder("utf-8").decode(bytes);+ });++ const getReviewDiffFileContents = Effect.fn("getReviewDiffFileContents")(function* (+ input: ReviewDiffFileContentsInput,+ ) {+ if (input.sourceKind === "working-tree") {+ const repositoryRoot = yield* runGitStdout(+ "GitVcsDriver.getReviewDiffFileContents.repositoryRoot",+ input.cwd,+ ["rev-parse", "--show-toplevel"],+ ).pipe(Effect.map((value) => value.trim()));+ if (repositoryRoot.length === 0) {+ return yield* reviewDiffFileError(input, "Could not resolve the Git repository root.");+ }+ const [oldContents, newContents] = yield* Effect.all(+ [+ input.changeType === "new"+ ? Effect.succeed("")+ : readReviewFileAtRevision(input, input.baseRef ?? "HEAD", input.oldPath),+ input.changeType === "deleted"+ ? Effect.succeed("")+ : readWorkingTreeReviewFile(input, repositoryRoot),+ ],+ { concurrency: 2 },+ );+ return { oldContents, newContents };+ }++ if (!input.baseRef || !input.headRef) {+ return yield* reviewDiffFileError(+ input,+ "Branch diff file expansion requires both base and head refs.",+ );+ }+ const mergeBase = yield* runGitStdout(+ "GitVcsDriver.getReviewDiffFileContents.mergeBase",+ input.cwd,+ ["merge-base", input.baseRef, input.headRef],+ ).pipe(Effect.map((value) => value.trim()));+ if (mergeBase.length === 0) {+ return yield* reviewDiffFileError(input, "Could not resolve the branch comparison base.");+ }+ const [oldContents, newContents] = yield* Effect.all(+ [+ input.changeType === "new"+ ? Effect.succeed("")+ : readReviewFileAtRevision(input, mergeBase, input.oldPath),+ input.changeType === "deleted"+ ? Effect.succeed("")+ : readReviewFileAtRevision(input, input.headRef, input.newPath),+ ],+ { concurrency: 2 },+ );+ return { oldContents, newContents };+ });+const readConfigValue: GitVcsDriver.GitVcsDriver["Service"]["readConfigValue"] = (cwd, key) =>runGitStdout("GitVcsDriver.readConfigValue", cwd, ["config", "--get", key], true).pipe(Effect.map((stdout) => stdout.trim()),@@ -2903,6 +3062,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*pullCurrentBranch: (cwd) => withListRefsInvalidation(cwd, pullCurrentBranch(cwd)),readRangeContext,getReviewDiffPreview,+ getReviewDiffFileContents,readConfigValue,listRefs,createWorktree: (input) => withListRefsInvalidation(input.cwd, createWorktree(input)),diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.tsindex 909a51a4c..4ece17cc1 100644--- a/apps/server/src/ws.ts+++ b/apps/server/src/ws.ts@@ -1854,6 +1854,12 @@ const makeWsRpcLayer = (observeRpcEffect(WS_METHODS.reviewGetDiffPreview, review.getDiffPreview(input), {"rpc.aggregate": "review",}),+ [WS_METHODS.reviewGetDiffFileContents]: (input) =>+ observeRpcEffect(+ WS_METHODS.reviewGetDiffFileContents,+ review.getDiffFileContents(input),+ { "rpc.aggregate": "review" },+ ),[WS_METHODS.terminalOpen]: (input) =>observeRpcEffect(WS_METHODS.terminalOpen, terminalManager.open(input), {"rpc.aggregate": "terminal",diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex c1c49fec8..1a20525af 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -5648,7 +5648,14 @@ function ChatViewContent(props: ChatViewProps) {/>);const panelLayoutControls = (- <div className="workspace-titlebar-controls z-50 mr-px gap-1 [-webkit-app-region:no-drag]">+ <div+ className={cn(+ "workspace-titlebar-controls z-50 gap-1 [-webkit-app-region:no-drag]",+ rightPanelOpen && !shouldUsePlanSidebarSheet+ ? "right-2 wco:right-[var(--workspace-controls-right)]"+ : "mr-px",+ )}+ >{rightPanelOpen && !shouldUsePlanSidebarSheet ? (<RightPanelMaximizeControlmaximized={rightPanelMaximized}diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsxindex d10cb39f0..a10cdafd7 100644--- a/apps/web/src/components/DiffPanel.tsx+++ b/apps/web/src/components/DiffPanel.tsx@@ -1,4 +1,5 @@import { useAtomValue } from "@effect/atom-react";+import type { FileDiffContentsLoader } from "@pierre/diffs";import { useParams } from "@tanstack/react-router";import {isAtomCommandInterrupted,@@ -15,6 +16,7 @@ import {ChevronsUpDownIcon,Columns2Icon,PilcrowIcon,+ RefreshCwIcon,Rows3Icon,SearchIcon,TextWrapIcon,@@ -67,6 +69,7 @@ import {} from "./ui/menu";import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";import { useEnvironmentQuery } from "../state/query";+import { useAtomCommand } from "../state/use-atom-command";import { serverEnvironment } from "../state/server";import { reviewEnvironment } from "../state/review";import { vcsEnvironment } from "../state/vcs";@@ -91,9 +94,9 @@ const DIFF_PANEL_UNSAFE_CSS = `[data-virtualizer-buffer] {--diffs-header-font-family: var(--font-sans) !important;--diffs-font-family: var(--font-mono) !important;- --diffs-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;- --diffs-light-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;- --diffs-dark-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;+ --diffs-bg: var(--background) !important;+ --diffs-light-bg: var(--background) !important;+ --diffs-dark-bg: var(--background) !important;--diffs-token-light-bg: transparent;--diffs-token-dark-bg: transparent;@@ -102,13 +105,25 @@ const DIFF_PANEL_UNSAFE_CSS = `--diffs-bg-separator-override: color-mix(in srgb, var(--background) 95%, var(--foreground));--diffs-bg-buffer-override: color-mix(in srgb, var(--background) 90%, var(--foreground));- --diffs-bg-addition-override: color-mix(in srgb, var(--background) 92%, var(--success));- --diffs-bg-addition-number-override: color-mix(in srgb, var(--background) 88%, var(--success));+ --diffs-bg-addition-override: light-dark(+ color-mix(in srgb, var(--background) 50%, var(--success)),+ color-mix(in srgb, var(--background) 70%, var(--success))+ );+ --diffs-bg-addition-number-override: light-dark(+ color-mix(in srgb, var(--background) 35%, var(--success)),+ color-mix(in srgb, var(--background) 60%, var(--success))+ );--diffs-bg-addition-hover-override: color-mix(in srgb, var(--background) 85%, var(--success));--diffs-bg-addition-emphasis-override: color-mix(in srgb, var(--background) 80%, var(--success));- --diffs-bg-deletion-override: color-mix(in srgb, var(--background) 92%, var(--destructive));- --diffs-bg-deletion-number-override: color-mix(in srgb, var(--background) 88%, var(--destructive));+ --diffs-bg-deletion-override: light-dark(+ color-mix(in srgb, var(--background) 50%, var(--destructive)),+ color-mix(in srgb, var(--background) 70%, var(--destructive))+ );+ --diffs-bg-deletion-number-override: light-dark(+ color-mix(in srgb, var(--background) 35%, var(--destructive)),+ color-mix(in srgb, var(--background) 60%, var(--destructive))+ );--diffs-bg-deletion-hover-override: color-mix(in srgb, var(--background) 85%, var(--destructive));--diffs-bg-deletion-emphasis-override: color-mix(in srgb,@@ -119,9 +134,66 @@ const DIFF_PANEL_UNSAFE_CSS = `background-color: var(--diffs-bg) !important;}+:is(+ [data-line],+ [data-line-annotation],+ [data-merge-conflict],+ [data-merge-conflict-actions],+ [data-no-newline]+)[data-selected-line] {+ --diffs-line-bg: light-dark(+ color-mix(+ in lab,+ var(--background) 88%,+ color-mix(in srgb, var(--background) 50%, var(--diffs-modified-base))+ ),+ color-mix(+ in lab,+ var(--background) 80%,+ color-mix(in srgb, var(--background) 70%, var(--diffs-modified-base))+ )+ ) !important;+}++:is([data-gutter-buffer], [data-column-number])[data-selected-line] {+ --diffs-line-bg: light-dark(+ color-mix(+ in lab,+ var(--background) 91%,+ color-mix(in srgb, var(--background) 35%, var(--diffs-modified-base))+ ),+ color-mix(+ in lab,+ var(--background) 85%,+ color-mix(in srgb, var(--background) 60%, var(--diffs-modified-base))+ )+ ) !important;+}++[data-indicators="bars"]+ :is([data-column-number], [data-gutter-buffer="annotation"])[data-selected-line] {+ position: relative;+}++[data-indicators="bars"]+ :is([data-column-number], [data-gutter-buffer="annotation"])[data-selected-line]::before {+ position: absolute !important;+ inset-block: 0 !important;+ inset-inline-start: 0 !important;+ display: block !important;+ width: 4px !important;+ min-width: 4px !important;+ max-width: 4px !important;+ height: auto !important;+ padding: 0 !important;+ content: "" !important;+ background-color: var(--diffs-modified-base) !important;+ background-image: none !important;+}+[data-file-info] {- background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;- border-block-color: var(--border) !important;+ background-color: var(--background) !important;+ border-block-color: transparent !important;color: var(--foreground) !important;}@@ -129,14 +201,103 @@ const DIFF_PANEL_UNSAFE_CSS = `position: sticky !important;top: 0;z-index: 4;- background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;- border-bottom: 1px solid var(--border) !important;+ background-color: var(--background) !important;+ border-bottom-color: transparent !important;align-items: center !important;font-family: var(--font-sans) !important;font-size: 12px !important;line-height: 1 !important;min-height: 32px !important;padding-block: 6px !important;+ padding-inline: 8px 12px !important;+}++[data-diffs-header]:hover {+ background-color: color-mix(in srgb, var(--background) 97%, var(--foreground)) !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"]) {+ height: 24px !important;+ margin-block: 0 !important;+ background-color: var(--background) !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])+ [data-separator-wrapper] {+ padding-inline: 8px 12px !important;+ background-color: transparent !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])+ [data-separator-content] {+ gap: 8px;+ padding-inline: 0 !important;+ background-color: transparent !important;+ color: color-mix(in srgb, var(--foreground) 52%, var(--background)) !important;+ font-family: var(--font-sans) !important;+ font-size: 11px !important;+ text-decoration: none !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])+ [data-unmodified-lines] {+ display: flex !important;+ min-width: 0;+ flex: 1 1 auto;+ align-items: center;+ gap: 8px;+ cursor: pointer;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])+ [data-unmodified-lines]::before,+:is([data-separator="line-info"], [data-separator="line-info-basic"])+ [data-unmodified-lines]::after {+ width: auto;+ height: 1px;+ flex: 1 1 auto;+ content: "";+ background-color: color-mix(in srgb, var(--background) 92%, var(--foreground));+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])[data-expand-index]+ [data-separator-wrapper] {+ grid-template-columns: 0 minmax(0, 1fr) !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])[data-expand-index]+ [data-separator-content] {+ grid-column: 2 !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"])+ [data-expand-button] {+ display: none !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"]):has(+ [data-expand-button]+ )+ [data-separator-content] {+ cursor: pointer;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"]):has(+ [data-expand-button]+ ):hover+ [data-separator-content] {+ color: color-mix(in srgb, var(--foreground) 76%, var(--background)) !important;+}++:is([data-separator="line-info"], [data-separator="line-info-basic"]):has(+ [data-expand-button]+ ):hover+ [data-unmodified-lines]::before,+:is([data-separator="line-info"], [data-separator="line-info-basic"]):has(+ [data-expand-button]+ ):hover+ [data-unmodified-lines]::after {+ background-color: color-mix(in srgb, var(--background) 84%, var(--foreground));}[data-diffs-header] [data-header-content] {@@ -205,7 +366,12 @@ export default function DiffPanel({scopeKey: null,fileKeys: EMPTY_COLLAPSED_DIFF_FILE_KEYS,}));+ const [codeViewRevision, setCodeViewRevision] = useState(0);const codeViewRef = useRef<AnnotatableCodeViewHandle>(null);+ const lastCompletedTurnRefreshRef = useRef<{+ readonly threadKey: string | null;+ readonly turnId: TurnId | null;+ } | null>(null);const routeThreadRef = useParams({strict: false,@@ -230,6 +396,7 @@ export default function DiffPanel({activeThread?.environmentId ?? null,serverConfig?.availableEditors ?? [],);+ const getDiffFileContents = useAtomCommand(reviewEnvironment.diffFileContents);const gitStatusQuery = useEnvironmentQuery(activeThread !== null && activeThread !== undefined && activeCwd != null? vcsEnvironment.status({@@ -298,6 +465,7 @@ export default function DiffPanel({const collapseScopeKey = routeThreadRef? `${routeThreadRef.environmentId}:${routeThreadRef.threadId}:${reviewSectionId}`: null;+ const codeViewMountKey = `${collapseScopeKey ?? reviewSectionId}:${codeViewRevision}`;const collapsedDiffFileKeys =collapsedDiffFiles.scopeKey === collapseScopeKey? collapsedDiffFiles.fileKeys@@ -360,9 +528,93 @@ export default function DiffPanel({const branchDiffPreview = shouldRetryBranchDiffAtEnvironmentCwd? fallbackBranchDiffPreview: primaryBranchDiffPreview;+ const refreshBranchDiffPreview = branchDiffPreview.refresh;+ const canRefreshGitDiff =+ isGitRepo && selectedTurnId === null && activeThread != null && activeCwd != null;+ const activeThreadRefreshKey = routeThreadRef+ ? `${routeThreadRef.environmentId}:${routeThreadRef.threadId}`+ : null;++ useEffect(() => {+ if (!canRefreshGitDiff) return;+ const refreshOnFocus = () => refreshBranchDiffPreview();+ window.addEventListener("focus", refreshOnFocus);+ return () => window.removeEventListener("focus", refreshOnFocus);+ }, [canRefreshGitDiff, refreshBranchDiffPreview]);++ useEffect(() => {+ const current = {+ threadKey: activeThreadRefreshKey,+ turnId: latestTurn?.turnId ?? null,+ };+ const previous = lastCompletedTurnRefreshRef.current;+ if (!canRefreshGitDiff) {+ return;+ }+ if (previous === null || previous.threadKey !== current.threadKey) {+ lastCompletedTurnRefreshRef.current = current;+ return;+ }+ if (previous.turnId === current.turnId) return;+ refreshBranchDiffPreview();+ lastCompletedTurnRefreshRef.current = current;+ }, [activeThreadRefreshKey, canRefreshGitDiff, latestTurn?.turnId, refreshBranchDiffPreview]);+const selectedGitSource = branchDiffPreview.data?.sources.find((source) => source.kind === (selectedGitScope === "unstaged" ? "working-tree" : "branch-range"),);+ const loadDiffFiles = useMemo<FileDiffContentsLoader | undefined>(() => {+ const preview = branchDiffPreview.data;+ if (selectedTurnId !== null || !activeThread || !preview || !selectedGitSource) {+ return undefined;+ }++ const source = selectedGitSource;+ return async (fileDiff) => {+ const newPath = resolveFileDiffPath(fileDiff);+ const oldPath = fileDiff.prevName+ ? resolveFileDiffPath({ ...fileDiff, name: fileDiff.prevName })+ : newPath;+ const result = await getDiffFileContents({+ environmentId: activeThread.environmentId,+ input: {+ cwd: preview.cwd,+ sourceKind: source.kind,+ changeType: fileDiff.type,+ baseRef: source.baseRef,+ headRef: source.headRef,+ oldPath,+ newPath,+ },+ });+ if (result._tag !== "Success") {+ throw squashAtomCommandFailure(result);+ }++ const newFile = {+ name: newPath,+ contents: result.value.newContents,+ cacheKey: `${source.diffHash}:new:${newPath}`,+ };+ if (fileDiff.type === "rename-pure") {+ return { oldFile: null, newFile };+ }+ return {+ oldFile: {+ name: oldPath,+ contents: result.value.oldContents,+ cacheKey: `${source.diffHash}:old:${oldPath}`,+ },+ newFile,+ };+ };+ }, [+ activeThread,+ branchDiffPreview.data,+ getDiffFileContents,+ selectedGitSource,+ selectedTurnId,+ ]);const localBranchRefs = useEnvironmentQuery(selectedTurnId === null &&selectedGitScope === "branch" &&@@ -439,10 +691,17 @@ export default function DiffPanel({}),);}, [renderablePatch]);+ const renderableFileEntries = useMemo(+ () =>+ renderableFiles.map((fileDiff) => ({+ fileDiff,+ fileKey: buildFileDiffRenderKey(fileDiff),+ })),+ [renderableFiles],+ );const codeViewFiles = useMemo(() =>- renderableFiles.map((fileDiff) => {- const fileKey = buildFileDiffRenderKey(fileDiff);+ renderableFileEntries.map(({ fileDiff, fileKey }) => {return {fileDiff,filePath: resolveFileDiffPath(fileDiff),@@ -450,18 +709,19 @@ export default function DiffPanel({collapsed: collapsedDiffFileKeys.has(fileKey),};}),- [collapsedDiffFileKeys, renderableFiles],+ [collapsedDiffFileKeys, renderableFileEntries],);const diffFileKeys = useMemo(() => codeViewFiles.map((file) => file.fileKey), [codeViewFiles]);const allDiffFilesCollapsed = areAllDiffFilesCollapsed(diffFileKeys, collapsedDiffFileKeys);const diffLineStat = useMemo(() => getDiffLineStat(renderableFiles), [renderableFiles]);+ const selectedDiffFileKey = selectedFilePath+ ? (codeViewFiles.find((candidate) => candidate.filePath === selectedFilePath)?.fileKey ?? null)+ : null;useEffect(() => {- if (!selectedFilePath) return;- const file = codeViewFiles.find((candidate) => candidate.filePath === selectedFilePath);- if (!file) return;- codeViewRef.current?.scrollTo({ type: "item", id: file.fileKey, align: "start" });- }, [codeViewFiles, selectedFilePath, selectedFileRevealRequestId]);+ if (!selectedDiffFileKey) return;+ codeViewRef.current?.scrollTo({ type: "item", id: selectedDiffFileKey, align: "start" });+ }, [codeViewMountKey, selectedDiffFileKey, selectedFileRevealRequestId]);const openDiffFile = useCallback((filePath: string) => {@@ -506,6 +766,7 @@ export default function DiffPanel({);const toggleDiffFileCollapse = useCallback(() => {+ setCodeViewRevision((current) => current + 1);setCollapsedDiffFiles((current) => {const currentKeys =current.scopeKey === collapseScopeKey ? current.fileKeys : EMPTY_COLLAPSED_DIFF_FILE_KEYS;@@ -724,23 +985,45 @@ export default function DiffPanel({layout="inline"/>)}+ {canRefreshGitDiff && (+ <Tooltip>+ <TooltipTrigger+ render={+ <Button+ type="button"+ size="icon-sm"+ variant="ghost"+ aria-label={branchDiffPreview.isPending ? "Refreshing diff" : "Refresh diff"}+ onClick={refreshBranchDiffPreview}+ />+ }+ >+ <RefreshCwIcon+ className={cn("size-3.5", branchDiffPreview.isPending && "animate-spin")}+ />+ </TooltipTrigger>+ <TooltipPopup side="top">+ {branchDiffPreview.isPending ? "Refreshing diff…" : "Refresh diff"}+ </TooltipPopup>+ </Tooltip>+ )}{codeViewFiles.length > 0 && (<Tooltip><TooltipTriggerrender={<Buttontype="button"- size="icon-xs"- variant="outline"+ size="icon-sm"+ variant="ghost"aria-label={allDiffFilesCollapsed ? "Expand all files" : "Collapse all files"}onClick={toggleDiffFileCollapse}/>}>{allDiffFilesCollapsed ? (- <ChevronsUpDownIcon className="size-3" />+ <ChevronsUpDownIcon className="size-3.5" />) : (- <ChevronsDownUpIcon className="size-3" />+ <ChevronsDownUpIcon className="size-3.5" />)}</TooltipTrigger><TooltipPopup side="top">@@ -749,9 +1032,8 @@ export default function DiffPanel({</Tooltip>)}<ToggleGroup- className="shrink-0"- variant="outline"- size="xs"+ className="shrink-0 gap-1"+ size="sm"value={[diffRenderMode]}onValueChange={(value) => {const next = value[0];@@ -760,11 +1042,11 @@ export default function DiffPanel({}}}>- <Toggle aria-label="Stacked diff view" value="stacked">- <Rows3Icon className="size-3" />+ <Toggle aria-label="Stacked diff view" value="stacked" variant="ghost">+ <Rows3Icon className="size-3.5" /></Toggle>- <Toggle aria-label="Split diff view" value="split">- <Columns2Icon className="size-3" />+ <Toggle aria-label="Split diff view" value="split" variant="ghost">+ <Columns2Icon className="size-3.5" /></Toggle></ToggleGroup><Tooltip>@@ -772,8 +1054,8 @@ export default function DiffPanel({render={<Togglearia-label={wordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}- variant="outline"- size="xs"+ variant="ghost"+ size="sm"pressed={wordWrap}onPressedChange={(pressed) => {setWordWrap(Boolean(pressed));@@ -781,7 +1063,7 @@ export default function DiffPanel({/>}>- <TextWrapIcon className="size-3" />+ <TextWrapIcon className="size-3.5" /></TooltipTrigger><TooltipPopup side="top">{wordWrap ? "Disable line wrapping" : "Enable line wrapping"}@@ -794,8 +1076,8 @@ export default function DiffPanel({aria-label={diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}- variant="outline"- size="xs"+ variant="ghost"+ size="sm"pressed={diffIgnoreWhitespace}onPressedChange={(pressed) => {setDiffIgnoreWhitespace(Boolean(pressed));@@ -803,7 +1085,7 @@ export default function DiffPanel({/>}>- <PilcrowIcon className="size-3" />+ <PilcrowIcon className="size-3.5" /></TooltipTrigger><TooltipPopup side="top">{diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}@@ -875,8 +1157,9 @@ export default function DiffPanel({}}><AnnotatableCodeView- viewerRef={codeViewRef}key={collapseScopeKey ?? reviewSectionId}+ viewerRef={codeViewRef}+ codeViewKey={codeViewMountKey}className="diff-render-surface h-full min-h-0 overflow-auto"files={codeViewFiles}sectionId={reviewSectionId}@@ -891,7 +1174,7 @@ export default function DiffPanel({<buttontype="button"className={cn(- "inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden",+ "-ms-0.5 inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden",getDiffCollapseIconClassName(fileDiff),)}aria-label={collapsed ? `Expand ${filePath}` : `Collapse ${filePath}`}@@ -923,8 +1206,14 @@ export default function DiffPanel({themeType: resolvedTheme as DiffThemeType,unsafeCSS: DIFF_PANEL_UNSAFE_CSS,stickyHeaders: true,- itemMetrics: { diffHeaderHeight: 33 },- layout: { paddingTop: 0, paddingBottom: 8, gap: 8 },+ ...(loadDiffFiles ? { loadDiffFiles } : {}),+ itemMetrics: {+ diffHeaderHeight: 32,+ hunkSeparatorHeight: 24,+ paddingTop: 0,+ paddingBottom: 0,+ },+ layout: { paddingTop: 0, paddingBottom: 0, gap: 0 },}}/></div>diff --git a/apps/web/src/components/DiffPanelShell.tsx b/apps/web/src/components/DiffPanelShell.tsxindex e727a8005..c13af4d95 100644--- a/apps/web/src/components/DiffPanelShell.tsx+++ b/apps/web/src/components/DiffPanelShell.tsx@@ -10,7 +10,8 @@ export type DiffPanelMode = "inline" | "sheet" | "sidebar" | "embedded";function getDiffPanelHeaderRowClassName(mode: DiffPanelMode) {const shouldUseDragRegion = isElectron && mode !== "sheet" && mode !== "embedded";return cn(- "flex items-center justify-between gap-2 px-4",+ "flex items-center justify-between gap-2",+ mode === "embedded" ? "px-2" : "px-4",shouldUseDragRegion? "drag-region h-[52px] border-b border-border wco:h-[env(titlebar-area-height)] wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]": "surface-subheader",@@ -59,30 +60,53 @@ export function DiffPanelHeaderSkeleton() {);}+function DiffFileHeaderSkeleton({ titleClassName }: { titleClassName: string }) {+ return (+ <div className="flex h-8 items-center gap-2 px-2 pr-3">+ <div className="flex size-5 shrink-0 items-center justify-center">+ <Skeleton className="size-2.5 rounded-[2px]" />+ </div>+ <Skeleton className="size-5 shrink-0 rounded-md" />+ <Skeleton className={cn("h-3 rounded-full", titleClassName)} />+ <div className="ml-auto flex shrink-0 items-center gap-2">+ <Skeleton className="h-3 w-5 rounded-full" />+ <Skeleton className="h-3 w-5 rounded-full" />+ </div>+ </div>+ );+}++function DiffCodeLineSkeleton({ contentClassName }: { contentClassName: string }) {+ return (+ <div className="flex items-center gap-3">+ <Skeleton className="h-2.5 w-5 shrink-0 rounded-full" />+ <Skeleton className={cn("h-2.5 rounded-full", contentClassName)} />+ </div>+ );+}+export function DiffPanelLoadingState(props: { label: string }) {return (- <div className="flex min-h-0 flex-1 flex-col p-2">- <div- className="flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-border/60 bg-card/25"- role="status"- aria-live="polite"- aria-label={props.label}- >- <div className="flex items-center gap-2 border-b border-border/50 px-3 py-2">- <Skeleton className="h-4 w-32 rounded-full" />- <Skeleton className="ml-auto h-4 w-20 rounded-full" />- </div>- <div className="flex min-h-0 flex-1 flex-col gap-4 px-3 py-4">- <div className="space-y-2">- <Skeleton className="h-3 w-full rounded-full" />- <Skeleton className="h-3 w-full rounded-full" />- <Skeleton className="h-3 w-10/12 rounded-full" />- <Skeleton className="h-3 w-11/12 rounded-full" />- <Skeleton className="h-3 w-9/12 rounded-full" />- </div>- <span className="sr-only">{props.label}</span>- </div>+ <div+ className="min-h-0 flex-1 overflow-hidden bg-background"+ role="status"+ aria-live="polite"+ aria-label={props.label}+ >+ <DiffFileHeaderSkeleton titleClassName="w-1/2 max-w-64" />+ <div className="flex h-6 items-center gap-2 px-2 pr-3">+ <div className="h-px flex-1 bg-border/40" />+ <Skeleton className="h-2.5 w-24 rounded-full" />+ <div className="h-px flex-1 bg-border/40" />+ </div>+ <div className="space-y-2 px-3 py-2">+ <DiffCodeLineSkeleton contentClassName="w-2/3" />+ <DiffCodeLineSkeleton contentClassName="w-4/5" />+ <DiffCodeLineSkeleton contentClassName="w-3/5" /></div>+ <DiffFileHeaderSkeleton titleClassName="w-2/5 max-w-52" />+ <DiffFileHeaderSkeleton titleClassName="w-3/5 max-w-72" />+ <span className="sr-only">{props.label}</span></div>);}diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsxindex fe652b6fd..2b9fa1660 100644--- a/apps/web/src/components/RightPanelTabs.tsx+++ b/apps/web/src/components/RightPanelTabs.tsx@@ -221,14 +221,14 @@ function surfaceTitle(function PreviewFavicon({ url }: { url: string | null }) {const faviconUrl = faviconUrlForOrigin(url, 32);const [failedUrl, setFailedUrl] = useState<string | null>(null);- if (!faviconUrl || failedUrl === faviconUrl) return <Globe2 className="size-3.5 shrink-0" />;+ if (!faviconUrl || failedUrl === faviconUrl) return <Globe2 className="size-3 shrink-0" />;return (<imgsrc={faviconUrl}alt=""aria-hiddendraggable={false}- className="size-3.5 shrink-0 rounded-sm"+ className="size-3 shrink-0 rounded-sm"onError={() => setFailedUrl(faviconUrl)}/>);@@ -250,22 +250,22 @@ function SurfaceIcon({return <PreviewFavicon url={url} />;}case "diff":- return <FileDiff className="size-3.5 shrink-0" />;+ return <FileDiff className="size-3 shrink-0" />;case "files":- return <Files className="size-3.5 shrink-0" />;+ return <Files className="size-3 shrink-0" />;case "file":return (<PierreEntryIconpathValue={surface.relativePath}kind="file"theme={theme}- className="size-3.5"+ className="size-3"/>);case "terminal":- return <TerminalSquare className="size-3.5 shrink-0" />;+ return <TerminalSquare className="size-3 shrink-0" />;case "plan":- return <ClipboardList className="size-3.5 shrink-0" />;+ return <ClipboardList className="size-3 shrink-0" />;}}@@ -358,7 +358,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {<divclassName={cn("workspace-topbar gap-1 pl-2",- !ownsDesktopTitleBar && "[--workspace-topbar-height:--spacing(11)]",+ props.mode !== "inline" && "[--workspace-topbar-height:--spacing(11)]",props.mode === "inline" ? "pr-28" : "pr-3",ownsDesktopTitleBar && "wco:pr-[calc(var(--workspace-native-controls-inset)+6rem)]",props.mode === "inline" && props.maximized && COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,@@ -385,62 +385,57 @@ export function RightPanelTabs(props: RightPanelTabsProps) {onAuxClick={(event) => handleTabAuxClick(event, surface)}onContextMenu={(event) => void handleTabContextMenu(event, surface)}className={cn(- "group flex h-7 min-w-25 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-sm",+ "group/tab flex h-6 max-w-36 shrink-0 items-center gap-0.5 rounded-md pr-2 pl-1.5 text-xs",active? "bg-accent text-foreground": "text-muted-foreground hover:bg-accent/60 hover:text-foreground",)}>+ <button+ type="button"+ className="group/close relative flex size-4 shrink-0 items-center justify-center rounded-sm hover:bg-muted"+ aria-label={`Close ${title}`}+ onClick={() => props.onCloseSurface(surface)}+ >+ <span className="relative flex size-3 items-center justify-center group-hover/tab:hidden group-focus-visible/close:hidden">+ <SurfaceIcon+ surface={surface}+ sessions={props.previewSessions}+ theme={resolvedTheme}+ />+ {pending ? (+ <span+ className="absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full bg-current"+ aria-hidden+ />+ ) : null}+ </span>+ <X className="hidden size-3 group-hover/tab:block group-focus-visible/close:block" />+ </button><Tooltip><TooltipTriggerrender={<buttontype="button"- className="flex min-w-0 flex-1 items-center gap-1.5"+ className="flex min-w-0 items-center"onClick={() => props.onActivate(surface)}>- <SurfaceIcon- surface={surface}- sessions={props.previewSessions}- theme={resolvedTheme}- /><span className="truncate">{title}</span></button>}/><TooltipPopup>{title}</TooltipPopup></Tooltip>- <button- type="button"- className={cn(- "relative flex size-4 shrink-0 items-center justify-center rounded hover:bg-muted focus:opacity-100",- pending ? "opacity-100" : "opacity-0 group-hover:opacity-100",- )}- aria-label={`Close ${title}`}- onClick={() => props.onCloseSurface(surface)}- >- {pending ? (- <>- <span- className="size-2 rounded-full bg-current group-hover:hidden"- aria-hidden- />- <X className="hidden size-3 group-hover:block" />- </>- ) : (- <X className="size-3" />- )}- </button></div>);})}{props.surfaces.length > 0 ? (<Menu><MenuTrigger- className="relative inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground"+ className="relative inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground"aria-label="Add panel surface">- <Plus className="size-4" />+ <Plus className="size-3.5" /></MenuTrigger><MenuPopup align="start" side="bottom" sideOffset={6} className="min-w-44"><SurfaceMenuItem@@ -478,7 +473,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {</ScrollArea>{props.layoutControls}</div>- <div className="flex min-h-0 flex-1 flex-col">+ <div className="flex min-h-0 flex-1 flex-col" data-right-panel-surface-content>{props.activeSurfaceId === null ? (<RightPanelEmptyStateonAddBrowser={props.onAddBrowser}diff --git a/apps/web/src/components/diffs/AnnotatableCodeView.test.tsx b/apps/web/src/components/diffs/AnnotatableCodeView.test.tsxnew file mode 100644index 000000000..bb8f8ebd9--- /dev/null+++ b/apps/web/src/components/diffs/AnnotatableCodeView.test.tsx@@ -0,0 +1,59 @@+import { renderToStaticMarkup } from "react-dom/server";+import { beforeEach, describe, expect, it, vi } from "vite-plus/test";++const testState = vi.hoisted(() => ({+ codeViewOptions: null as Record<string, unknown> | null,+}));++vi.mock("@pierre/diffs/react", () => ({+ CodeView: (props: { options: Record<string, unknown> }) => {+ testState.codeViewOptions = props.options;+ return null;+ },+}));++vi.mock("~/composerDraftStore", () => ({+ useComposerDraftStore: (selector: (store: Record<string, unknown>) => unknown) =>+ selector({+ addReviewComment: vi.fn(),+ removeReviewComment: vi.fn(),+ getComposerDraft: () => undefined,+ }),+}));++vi.mock("../files/LocalCommentAnnotation", () => ({+ LocalCommentAnnotation: () => null,+}));++vi.mock("../files/fileCommentAnnotations", () => ({+ nextFileCommentId: () => "comment-test",+}));++import { AnnotatableCodeView } from "./AnnotatableCodeView";++describe("AnnotatableCodeView", () => {+ beforeEach(() => {+ testState.codeViewOptions = null;+ });++ it("opens comments from Pierre's gutter action without ending line selection", () => {+ renderToStaticMarkup(+ <AnnotatableCodeView+ codeViewKey="test-view"+ files={[]}+ sectionId="working-tree"+ sectionTitle="Working tree"+ composerDraftTarget={"draft-test" as never}+ options={{}}+ renderHeaderPrefix={() => null}+ />,+ );++ expect(testState.codeViewOptions).toMatchObject({+ enableGutterUtility: true,+ enableLineSelection: true,+ onGutterUtilityClick: expect.any(Function),+ });+ expect(testState.codeViewOptions).not.toHaveProperty("onLineSelectionEnd");+ });+});diff --git a/apps/web/src/components/diffs/AnnotatableCodeView.tsx b/apps/web/src/components/diffs/AnnotatableCodeView.tsxindex 6cea64fb5..0decaa3ac 100644--- a/apps/web/src/components/diffs/AnnotatableCodeView.tsx+++ b/apps/web/src/components/diffs/AnnotatableCodeView.tsx@@ -71,6 +71,7 @@ function appendAnnotationEntry(}interface AnnotatableCodeViewProps {+ codeViewKey: string;files: ReadonlyArray<{fileDiff: FileDiffMetadata;filePath: string;@@ -95,6 +96,7 @@ interface DiffSelectionContext {}export function AnnotatableCodeView({+ codeViewKey,files,sectionId,sectionTitle,@@ -117,6 +119,7 @@ export function AnnotatableCodeView({fileKey: string;annotation: DiffCommentLineAnnotation;} | null>(null);+ const [draftText, setDraftText] = useState("");const filesByKey = useMemo(() => new Map(files.map((file) => [file.fileKey, file])), [files]);const items = useMemo<CodeViewDiffItem<DiffCommentAnnotationGroup>[]>(@@ -167,6 +170,7 @@ export function AnnotatableCodeView({setSelectedLines(null);if (draft?.annotation.metadata.entries.some((entry) => entry.id === entryId)) {setDraft(null);+ setDraftText("");} else {removeReviewComment(composerDraftTarget, entryId);}@@ -193,6 +197,7 @@ export function AnnotatableCodeView({if (comment) addReviewComment(composerDraftTarget, comment);setSelectedLines(null);setDraft(null);+ setDraftText("");},[addReviewComment, composerDraftTarget, draft, filesByKey, sectionId, sectionTitle],);@@ -215,6 +220,7 @@ export function AnnotatableCodeView({text: "",});if (!comment) return;+ setDraftText("");setDraft({fileKey: item.id,annotation: {@@ -232,6 +238,7 @@ export function AnnotatableCodeView({const hasOpenComment = draft !== null;return (<CodeView<DiffCommentAnnotationGroup>+ key={codeViewKey}{...(viewerRef ? { ref: viewerRef } : {})}{...(className ? { className } : {})}items={items}@@ -241,28 +248,34 @@ export function AnnotatableCodeView({...options,enableGutterUtility: !hasOpenComment,enableLineSelection: !hasOpenComment,- onLineSelectionEnd: beginComment,+ onGutterUtilityClick: beginComment,}}renderHeaderPrefix={(item) =>item.type === "diff"? renderHeaderPrefix(item.fileDiff, item.id, item.collapsed === true): null}- renderAnnotation={(annotation) => (- <div className="py-1">- {annotation.metadata.entries.map((entry) => (- <LocalCommentAnnotation- key={entry.id}- kind={entry.kind}- rangeLabel={entry.rangeLabel}- text={entry.text}- onCancel={() => removeEntry(entry.id)}- onComment={(text) => submitEntry(entry.id, text)}- onDelete={() => removeEntry(entry.id)}- />- ))}- </div>- )}+ renderAnnotation={(annotation) => {+ const hasDraft = annotation.metadata.entries.some((entry) => entry.kind === "draft");+ return (+ <div+ className={hasDraft ? "py-1" : "divide-y divide-border/30 border-y border-border/30"}+ >+ {annotation.metadata.entries.map((entry) => (+ <LocalCommentAnnotation+ key={entry.id}+ kind={entry.kind}+ rangeLabel={entry.rangeLabel}+ text={entry.kind === "draft" ? draftText : entry.text}+ onTextChange={setDraftText}+ onCancel={() => removeEntry(entry.id)}+ onComment={(text) => submitEntry(entry.id, text)}+ onDelete={() => removeEntry(entry.id)}+ />+ ))}+ </div>+ );+ }}/>);}diff --git a/apps/web/src/components/files/LocalCommentAnnotation.test.tsx b/apps/web/src/components/files/LocalCommentAnnotation.test.tsxnew file mode 100644index 000000000..f24460ca4--- /dev/null+++ b/apps/web/src/components/files/LocalCommentAnnotation.test.tsx@@ -0,0 +1,66 @@+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vite-plus/test";++import { LocalCommentAnnotation } from "./LocalCommentAnnotation";++const callbacks = {+ onTextChange: vi.fn(),+ onCancel: vi.fn(),+ onComment: vi.fn(),+ onDelete: vi.fn(),+};++describe("LocalCommentAnnotation", () => {+ it("renders the draft composer directly in the selected diff", () => {+ const markup = renderToStaticMarkup(+ <LocalCommentAnnotation kind="draft" rangeLabel="+78" text="" {...callbacks} />,+ );++ expect(markup).toContain("font-sans");+ expect(markup).not.toContain("chat-composer-glass");+ expect(markup).not.toContain("font-mono");+ expect(markup).not.toContain("Local comment");+ expect(markup).not.toContain("on +78");+ expect(markup).toContain("⌘/Ctrl Enter to send");+ expect(markup).toContain("Add a comment…");+ expect(markup).toContain(">Comment</button>");+ expect(markup).toContain("autofocus");+ const textareaControl = markup.match(/<span[^>]*data-slot="textarea-control"[^>]*>/)?.[0];+ expect(textareaControl).toBeDefined();+ expect(textareaControl).not.toContain("ring-ring");+ expect(markup).toContain("cursor-text");+ });++ it("renders a saved comment without a nested card or redundant range label", () => {+ const markup = renderToStaticMarkup(+ <LocalCommentAnnotation+ kind="comment"+ rangeLabel="+78"+ text="Please keep this branch explicit."+ {...callbacks}+ />,+ );++ expect(markup).toContain("font-sans");+ expect(markup).not.toContain("chat-composer-glass");+ expect(markup).not.toContain("on +78");+ expect(markup).toContain("Please keep this branch explicit.");+ expect(markup).toContain('aria-label="Delete comment"');+ expect(markup).toContain("border-s-2");+ expect(markup).toContain("bg-primary/[0.045]");+ expect(markup).toContain("lucide-message-circle");+ });++ it("renders draft text owned by the annotation wrapper", () => {+ const markup = renderToStaticMarkup(+ <LocalCommentAnnotation+ kind="draft"+ rangeLabel="+78"+ text="Keep this unsaved draft"+ {...callbacks}+ />,+ );++ expect(markup).toContain("Keep this unsaved draft");+ });+});diff --git a/apps/web/src/components/files/LocalCommentAnnotation.tsx b/apps/web/src/components/files/LocalCommentAnnotation.tsxindex a2765b02d..19581a74d 100644--- a/apps/web/src/components/files/LocalCommentAnnotation.tsx+++ b/apps/web/src/components/files/LocalCommentAnnotation.tsx@@ -8,6 +8,7 @@ interface LocalCommentAnnotationProps {kind: "draft" | "comment";rangeLabel: string;text: string;+ onTextChange?: (text: string) => void;onCancel: () => void;onComment: (text: string) => void;onDelete: () => void;@@ -16,32 +17,34 @@ interface LocalCommentAnnotationProps {export function LocalCommentAnnotation({kind,rangeLabel,- text: savedText,+ text,+ onTextChange,onCancel,onComment,onDelete,}: LocalCommentAnnotationProps) {- const [text, setText] = useState("");+ const [localDraftText, setLocalDraftText] = useState("");+ const displayedText = kind === "draft" && !onTextChange ? localDraftText : text;if (kind === "comment") {return (<divdata-file-comment-annotation- className="mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-sm"+ className="group/comment flex min-w-0 items-start gap-2.5 border-s-2 border-primary/55 bg-primary/[0.045] px-3 py-2.5 font-sans text-foreground"contentEditable={false}onPointerDown={(event) => event.stopPropagation()}>- <div className="flex items-center gap-2">- <MessageCircle className="size-4 text-muted-foreground" />- <span className="text-xs font-medium">Local comment</span>- <span className="ml-auto text-[11px] text-muted-foreground">{rangeLabel}</span>- <Button variant="ghost" size="icon-xs" aria-label="Delete comment" onClick={onDelete}>- <Trash2 className="size-3.5" />- </Button>- </div>- <p className="mt-2 whitespace-pre-wrap text-sm leading-relaxed text-foreground">- {savedText}- </p>+ <MessageCircle className="mt-0.5 size-3.5 shrink-0 text-primary/70" aria-hidden="true" />+ <p className="min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5">{displayedText}</p>+ <Button+ className="-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100"+ variant="ghost"+ size="icon-xs"+ aria-label="Delete comment"+ onClick={onDelete}+ >+ <Trash2 className="size-3" />+ </Button></div>);}@@ -49,39 +52,49 @@ export function LocalCommentAnnotation({return (<divdata-file-comment-annotation- className="mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-lg"+ className="px-3 py-2 font-sans text-foreground"contentEditable={false}onPointerDown={(event) => event.stopPropagation()}>- <div className="flex items-center gap-2">- <MessageCircle className="size-4 text-muted-foreground" />- <span className="text-sm font-medium">Local comment</span>- </div>- <div className="mt-1 text-xs text-muted-foreground">Comment on lines {rangeLabel}</div><TextareaautoFocus- className="mt-3"+ unstyled+ className="relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12"size="sm"- value={text}- placeholder="Request change"+ value={displayedText}+ placeholder="Add a comment…"aria-label={`Comment on lines ${rangeLabel}`}- onChange={(event) => setText(event.target.value)}+ onChange={(event) => (onTextChange ?? setLocalDraftText)(event.target.value)}+ onFocus={(event) => {+ const end = event.currentTarget.value.length;+ event.currentTarget.setSelectionRange(end, end);+ }}onKeyDown={(event) => {if (event.key === "Escape") {event.preventDefault();onCancel();}- if ((event.metaKey || event.ctrlKey) && event.key === "Enter" && text.trim()) {+ if ((event.metaKey || event.ctrlKey) && event.key === "Enter" && displayedText.trim()) {event.preventDefault();- onComment(text.trim());+ onComment(displayedText.trim());}}}/>- <div className="mt-3 flex justify-end gap-2">- <Button variant="ghost" size="sm" onClick={onCancel}>+ <div className="mt-1.5 flex items-center gap-1">+ <span className="mr-auto text-[10px] text-muted-foreground/70">⌘/Ctrl Enter to send</span>+ <Button+ className="text-muted-foreground hover:text-foreground"+ variant="ghost"+ size="xs"+ onClick={onCancel}+ >Cancel</Button>- <Button size="sm" disabled={!text.trim()} onClick={() => onComment(text.trim())}>+ <Button+ size="xs"+ disabled={!displayedText.trim()}+ onClick={() => onComment(displayedText.trim())}+ >Comment</Button></div>diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex 9d7b4a41e..18890cc7d 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -406,6 +406,13 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil@apply flex h-10 min-h-10 shrink-0 items-center border-b border-border/60 bg-background;}+ [data-preview-panel-mode="inline"] [data-right-panel-surface-content] [data-surface-subheader] {+ height: calc(var(--spacing) * 7);+ min-height: calc(var(--spacing) * 7);+ margin-bottom: calc(var(--spacing) * 3);+ border-bottom-color: transparent;+ }+.chat-composer-horizontal-inset {padding-inline-start: calc(env(safe-area-inset-left) + 0.75rem);padding-inline-end: calc(env(safe-area-inset-right) + 0.75rem);diff --git a/apps/web/src/lib/diffRendering.test.ts b/apps/web/src/lib/diffRendering.test.tsindex 8ab8b25bb..13cd58984 100644--- a/apps/web/src/lib/diffRendering.test.ts+++ b/apps/web/src/lib/diffRendering.test.ts@@ -1,5 +1,10 @@import { describe, expect, it } from "vite-plus/test";-import { buildPatchCacheKey, getDiffLineStat, getRenderablePatch } from "./diffRendering";+import {+ buildFileDiffRenderKey,+ buildPatchCacheKey,+ getDiffLineStat,+ getRenderablePatch,+} from "./diffRendering";describe("buildPatchCacheKey", () => {it("returns a stable cache key for identical content", () => {@@ -83,6 +88,30 @@ describe("getRenderablePatch", () => {});});+describe("buildFileDiffRenderKey", () => {+ it("keeps file identity stable when Pierre hydrates a partial diff", () => {+ const patch = [+ "diff --git a/example.ts b/example.ts",+ "--- a/example.ts",+ "+++ b/example.ts",+ "@@ -1 +1 @@",+ "-before",+ "+after",+ ].join("\n");+ const parsed = getRenderablePatch(patch, "hydrated-key");+ expect(parsed?.kind).toBe("files");+ if (parsed?.kind !== "files") return;++ const file = parsed.files[0];+ expect(file).toBeDefined();+ if (!file) return;+ const key = buildFileDiffRenderKey(file);+ file.cacheKey = `${file.cacheKey}:hydrated`;++ expect(buildFileDiffRenderKey(file)).toBe(key);+ });+});+describe("getDiffLineStat", () => {it("totals additions and deletions across every file and hunk", () => {const patch = [diff --git a/apps/web/src/lib/diffRendering.ts b/apps/web/src/lib/diffRendering.tsindex 493474d8a..5a9e5d30d 100644--- a/apps/web/src/lib/diffRendering.ts+++ b/apps/web/src/lib/diffRendering.ts@@ -152,7 +152,10 @@ export function resolveFileDiffPath(fileDiff: FileDiffMetadata): string {}export function buildFileDiffRenderKey(fileDiff: FileDiffMetadata): string {- return fileDiff.cacheKey ?? `${fileDiff.prevName ?? "none"}:${fileDiff.name}`;+ const cacheKey = fileDiff.cacheKey;+ if (!cacheKey) return `${fileDiff.prevName ?? "none"}:${fileDiff.name}`;++ return cacheKey.endsWith(":hydrated") ? cacheKey.slice(0, -":hydrated".length) : cacheKey;}export function getDiffCollapseIconClassName(fileDiff: FileDiffMetadata): string {diff --git a/packages/client-runtime/src/state/review.ts b/packages/client-runtime/src/state/review.tsindex 0d78d6edd..ddd13db83 100644--- a/packages/client-runtime/src/state/review.ts+++ b/packages/client-runtime/src/state/review.ts@@ -1,17 +1,41 @@import { WS_METHODS } from "@t3tools/contracts";import { Atom } from "effect/unstable/reactivity";-import { createEnvironmentRpcQueryAtomFamily } from "./runtime.ts";+import {+ createAtomCommandScheduler,+ createEnvironmentRpcCommand,+ createEnvironmentRpcQueryAtomFamily,+} from "./runtime.ts";import type { EnvironmentRegistry } from "../connection/registry.ts";export function createReviewEnvironmentAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>,) {+ const diffFileScheduler = createAtomCommandScheduler();return {diffPreview: createEnvironmentRpcQueryAtomFamily(runtime, {label: "environment-data:review:diff-preview",tag: WS_METHODS.reviewGetDiffPreview,staleTimeMs: 5_000,}),+ diffFileContents: createEnvironmentRpcCommand(runtime, {+ label: "environment-data:review:diff-file-contents",+ tag: WS_METHODS.reviewGetDiffFileContents,+ scheduler: diffFileScheduler,+ concurrency: {+ mode: "singleFlight",+ key: ({ environmentId, input }) =>+ JSON.stringify([+ environmentId,+ input.cwd,+ input.sourceKind,+ input.baseRef,+ input.headRef,+ input.oldPath,+ input.newPath,+ input.changeType,+ ]),+ },+ }),};}diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.tsindex a92eb972d..3eb710f09 100644--- a/packages/contracts/src/ipc.ts+++ b/packages/contracts/src/ipc.ts@@ -18,7 +18,12 @@ import type {VcsStatusInput,VcsStatusResult,} from "./git.ts";-import type { ReviewDiffPreviewInput, ReviewDiffPreviewResult } from "./review.ts";+import type {+ ReviewDiffFileContentsInput,+ ReviewDiffFileContentsResult,+ ReviewDiffPreviewInput,+ ReviewDiffPreviewResult,+} from "./review.ts";import type { FilesystemBrowseInput, FilesystemBrowseResult } from "./filesystem.ts";import type { AssetCreateUrlInput, AssetCreateUrlResult } from "./assets.ts";import type {@@ -1203,6 +1208,9 @@ export interface EnvironmentApi {};review: {getDiffPreview: (input: ReviewDiffPreviewInput) => Promise<ReviewDiffPreviewResult>;+ getDiffFileContents: (+ input: ReviewDiffFileContentsInput,+ ) => Promise<ReviewDiffFileContentsResult>;};orchestration: {dispatchCommand: (command: ClientOrchestrationCommand) => Promise<{ sequence: number }>;diff --git a/packages/contracts/src/review.ts b/packages/contracts/src/review.tsindex a6b879a0c..93f100b5f 100644--- a/packages/contracts/src/review.ts+++ b/packages/contracts/src/review.ts@@ -25,6 +25,23 @@ export const ReviewDiffPreviewSource = Schema.Struct({});export type ReviewDiffPreviewSource = typeof ReviewDiffPreviewSource.Type;+export const ReviewDiffFileContentsInput = Schema.Struct({+ cwd: TrimmedNonEmptyString,+ sourceKind: ReviewDiffPreviewSourceKind,+ changeType: Schema.Literals(["change", "rename-pure", "rename-changed", "new", "deleted"]),+ baseRef: Schema.NullOr(TrimmedNonEmptyString),+ headRef: Schema.NullOr(TrimmedNonEmptyString),+ oldPath: TrimmedNonEmptyString,+ newPath: TrimmedNonEmptyString,+});+export type ReviewDiffFileContentsInput = typeof ReviewDiffFileContentsInput.Type;++export const ReviewDiffFileContentsResult = Schema.Struct({+ oldContents: Schema.String,+ newContents: Schema.String,+});+export type ReviewDiffFileContentsResult = typeof ReviewDiffFileContentsResult.Type;+export const ReviewDiffPreviewResult = Schema.Struct({cwd: TrimmedNonEmptyString,generatedAt: Schema.DateTimeUtc,diff --git a/packages/contracts/src/rpc.ts b/packages/contracts/src/rpc.tsindex 400011f88..42cafae31 100644--- a/packages/contracts/src/rpc.ts+++ b/packages/contracts/src/rpc.ts@@ -45,6 +45,8 @@ import {VcsStatusStreamEvent,} from "./git.ts";import {+ ReviewDiffFileContentsInput,+ ReviewDiffFileContentsResult,ReviewDiffPreviewError,ReviewDiffPreviewInput,ReviewDiffPreviewResult,@@ -197,6 +199,7 @@ export const WS_METHODS = {// Review methodsreviewGetDiffPreview: "review.getDiffPreview",+ reviewGetDiffFileContents: "review.getDiffFileContents",// Terminal methodsterminalOpen: "terminal.open",@@ -566,6 +569,12 @@ export const WsReviewGetDiffPreviewRpc = Rpc.make(WS_METHODS.reviewGetDiffPrevieerror: Schema.Union([ReviewDiffPreviewError, EnvironmentAuthorizationError]),});+export const WsReviewGetDiffFileContentsRpc = Rpc.make(WS_METHODS.reviewGetDiffFileContents, {+ payload: ReviewDiffFileContentsInput,+ success: ReviewDiffFileContentsResult,+ error: Schema.Union([ReviewDiffPreviewError, EnvironmentAuthorizationError]),+});+export const WsTerminalOpenRpc = Rpc.make(WS_METHODS.terminalOpen, {payload: TerminalOpenInput,success: TerminalSessionSnapshot,@@ -830,6 +839,7 @@ export const WsRpcGroup = RpcGroup.make(WsVcsSwitchRefRpc,WsVcsInitRpc,WsReviewGetDiffPreviewRpc,+ WsReviewGetDiffFileContentsRpc,WsTerminalOpenRpc,WsTerminalAttachRpc,WsTerminalWriteRpc,