Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

diffFileActions.ts

25 lines720 Bytes

1import type { ScopedThreadRef } from "@t3tools/contracts";
2​
3import { useRightPanelStore } from "./rightPanelStore";
4import { resolvePathLinkTarget } from "./terminal-links";
5​
6interface OpenDiffFilePrimaryActionInput {
7 readonly threadRef: ScopedThreadRef | null;
8 readonly filePath: string;
9 readonly activeCwd: string | undefined;
10 readonly openInEditor: (targetPath: string) => void;
12​
13export function openDiffFilePrimaryAction({
14 threadRef,
15 filePath,
16 activeCwd,
17 openInEditor,
18}: OpenDiffFilePrimaryActionInput): void {
19 if (threadRef) {
20 useRightPanelStore.getState().openFile(threadRef, filePath);
21 return;
22 }
23​
24 openInEditor(activeCwd ? resolvePathLinkTarget(filePath, activeCwd) : filePath);