214a8f5cce
* fix: scope multi-repo file editor open/save to the right repo The editor open/save/sync/delete chain dropped the repository_name in multi-repo task workspaces, so the backend resolved paths against the bare task root and failed with "file not found". Thread the repo subpath through openFile, save, sync, and delete, and store it on FileEditorState. * fix: pass repo from diff Edit button to multi-repo file editor The diff/changes "Edit" button opened files without their repository scope, so multi-repo files resolved against the bare task root and failed with "file not found". Thread repository_name through the diff and review toolbars into onOpenFile. * fix: preserve repo across tab restore and stale syncs Address review feedback: persisted file tabs dropped the repo subpath, so a multi-repo file reopened against the bare task root after a browser refresh. Persist and restore `repo` on StoredFileTab. Also guard the workspace sync against a tab being swapped to a different repo mid-fetch, and widen the remaining onOpenFile type declarations to carry repo. * fix: thread repo into editor panel fallback fetch Address review feedback: FileEditorPanel's useFileLoader fallback fetch (triggered when the open-files map is transiently empty, e.g. after a session switch) called requestFileContent without the repo subpath, re-introducing the multi-repo "file not found" failure. Record repo on the panel params and forward it through useFileLoader. Also assert the full restored-tab shape in the local-storage round-trip test. * fix: guard editor fetches against stale session/repo races Address review feedback: file open and the panel fallback fetch could apply a late response after the user navigated away. openFile now drops the result if the active session changed mid-fetch (via fetchFileEditorState), and the panel loader keys its in-flight guard by session+path+repo so a changed target re-fetches and stale responses are discarded.
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
"use client";
|
|
|
|
import { memo } from "react";
|
|
import { useEditorProvider } from "@/hooks/use-editor-resolver";
|
|
import {
|
|
DiffViewer as PierreDiffViewer,
|
|
DiffViewInline as PierreDiffViewInline,
|
|
} from "./diff-viewer";
|
|
import { MonacoDiffViewer } from "@/components/editors/monaco/monaco-diff-viewer";
|
|
import type { FileDiffData, DiffComment } from "@/lib/diff/types";
|
|
import type { RevertBlockInfo } from "./diff-viewer";
|
|
export type { RevertBlockInfo };
|
|
|
|
interface DiffViewerResolverProps {
|
|
data: FileDiffData;
|
|
enableComments?: boolean;
|
|
sessionId?: string;
|
|
onCommentAdd?: (comment: DiffComment) => void;
|
|
onCommentDelete?: (commentId: string) => void;
|
|
onCommentRun?: (comment: DiffComment) => void;
|
|
comments?: DiffComment[];
|
|
className?: string;
|
|
compact?: boolean;
|
|
hideHeader?: boolean;
|
|
onOpenFile?: (filePath: string, repo?: string) => void;
|
|
onPreviewMarkdown?: (filePath: string) => void;
|
|
onRevert?: (filePath: string) => void;
|
|
enableAcceptReject?: boolean;
|
|
onRevertBlock?: (filePath: string, info: RevertBlockInfo) => void;
|
|
wordWrap?: boolean;
|
|
editable?: boolean;
|
|
onModifiedContentChange?: (filePath: string, content: string) => void;
|
|
/** Enable diff expansion (pierre-diffs only - Monaco has built-in expansion) */
|
|
enableExpansion?: boolean;
|
|
/** Base git ref for fetching old content (pierre-diffs only) */
|
|
baseRef?: string;
|
|
/** Controlled expand-unchanged state (pierre-diffs only) */
|
|
expandUnchanged?: boolean;
|
|
/** Callback when expand-unchanged is toggled (pierre-diffs only) */
|
|
onToggleExpandUnchanged?: () => void;
|
|
/** Multi-repo subpath for the file (e.g. "kandev"); empty for single-repo. */
|
|
repo?: string;
|
|
}
|
|
|
|
export const DiffViewerResolved = memo(function DiffViewerResolved(props: DiffViewerResolverProps) {
|
|
const provider = useEditorProvider("diff-viewer");
|
|
if (provider === "monaco") {
|
|
// Strip pierre-diffs-only props
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
const {
|
|
enableComments,
|
|
baseRef,
|
|
enableExpansion,
|
|
expandUnchanged,
|
|
onToggleExpandUnchanged,
|
|
onPreviewMarkdown,
|
|
repo,
|
|
...rest
|
|
} = props;
|
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
return <MonacoDiffViewer {...rest} />;
|
|
}
|
|
return <PierreDiffViewer {...props} />;
|
|
});
|
|
|
|
export function DiffViewInlineResolved({
|
|
data,
|
|
className,
|
|
}: {
|
|
data: FileDiffData;
|
|
className?: string;
|
|
}) {
|
|
const provider = useEditorProvider("chat-diff");
|
|
if (provider === "monaco") {
|
|
return <MonacoDiffViewer data={data} compact hideHeader className={className} />;
|
|
}
|
|
return <PierreDiffViewInline data={data} className={className} />;
|
|
}
|