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.
Open diff files in editor from diff header clicks
Julius Marmingedb31c362135d
diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsxindex 92c2af1d0..3b77edda2 100644--- a/apps/web/src/components/DiffPanel.tsx+++ b/apps/web/src/components/DiffPanel.tsx@@ -7,6 +7,8 @@ import { ChevronLeftIcon, ChevronRightIcon, Columns2Icon, Rows3Icon } from "luciimport { useCallback, useEffect, useMemo, useRef, useState } from "react";import { checkpointDiffQueryOptions } from "~/lib/providerReactQuery";import { cn } from "~/lib/utils";+import { readNativeApi } from "../nativeApi";+import { preferredTerminalEditor, resolvePathLinkTarget } from "../terminal-links";import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch";import { isElectron } from "../env";import { useTheme } from "../hooks/useTheme";@@ -58,6 +60,21 @@ const DIFF_PANEL_UNSAFE_CSS = `border-block-color: var(--border) !important;color: var(--foreground) !important;}++[data-title] {+ cursor: pointer;+ transition:+ color 120ms ease,+ text-decoration-color 120ms ease;+ text-decoration: underline;+ text-decoration-color: transparent;+ text-underline-offset: 2px;+}++[data-title]:hover {+ color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;+ text-decoration-color: currentColor;+}`;type RenderablePatch =@@ -144,6 +161,8 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {const diffSearch = useSearch({ strict: false, select: (search) => parseDiffRouteSearch(search) });const activeThreadId = routeThreadId;const activeThread = state.threads.find((thread) => thread.id === activeThreadId);+ const activeProject = state.projects.find((project) => project.id === activeThread?.projectId);+ const activeCwd = activeThread?.worktreePath ?? activeProject?.cwd;const { turnDiffSummaries, inferredCheckpointTurnCountByTurnId } =useTurnDiffSummaries(activeThread);const orderedTurnDiffSummaries = useMemo(@@ -264,6 +283,18 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {target?.scrollIntoView({ block: "nearest" });}, [selectedFilePath, renderableFiles]);+ const openDiffFileInEditor = useCallback(+ (filePath: string) => {+ const api = readNativeApi();+ if (!api) return;+ const targetPath = activeCwd ? resolvePathLinkTarget(filePath, activeCwd) : filePath;+ void api.shell.openInEditor(targetPath, preferredTerminalEditor()).catch((error) => {+ console.warn("Failed to open diff file in editor.", error);+ });+ },+ [activeCwd],+ );+const selectTurn = (turnId: TurnId) => {if (!activeThread) return;void navigate({@@ -508,7 +539,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {</div>) : renderablePatch.kind === "files" ? (<Virtualizer- className="diff-render-surface h-full min-h-0 overflow-auto px-3 py-2"+ className="diff-render-surface h-full min-h-0 overflow-auto p-2 "config={{overscrollSize: 600,intersectionObserverMargin: 1200,@@ -522,7 +553,17 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {<divkey={themedFileKey}data-diff-file-path={filePath}- className="diff-render-file rounded-md"+ className="diff-render-file mb-2 rounded-md last:mb-0"+ onClickCapture={(event) => {+ const nativeEvent = event.nativeEvent as MouseEvent;+ const composedPath = nativeEvent.composedPath?.() ?? [];+ const clickedHeader = composedPath.some((node) => {+ if (!(node instanceof Element)) return false;+ return node.hasAttribute("data-title");+ });+ if (!clickedHeader) return;+ openDiffFileInEditor(filePath);+ }}><FileDifffileDiff={fileDiff}@@ -539,7 +580,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {})}</Virtualizer>) : (- <div className="h-full overflow-auto px-3 py-2">+ <div className="h-full overflow-auto p-2"><div className="space-y-2"><p className="text-[11px] text-muted-foreground/75">{renderablePatch.reason}</p><pre className="max-h-[72vh] overflow-auto rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90">