feat: open Changes as a workspace tab (#2298)

Open the complete working comparison in a desktop workspace tab while preserving inline sidebar diffs when the tab is closed.

Working and commit comparisons share one diff panel, and workspace layout is the sole owner of live tab persistence and identity.

Refs #1520
This commit is contained in:
nikuscs
2026-07-22 20:57:18 +02:00
committed by GitHub
parent 76a5edb020
commit 512c9b31a8
61 changed files with 1581 additions and 2012 deletions
+13 -4
View File
@@ -12,6 +12,7 @@ interface UseCheckoutDiffQueryOptions {
baseRef?: string;
ignoreWhitespace?: boolean;
enabled?: boolean;
queryScope?: string;
}
type CheckoutDiffQueryPayload = Omit<SubscribeCheckoutDiffResponse["payload"], "subscriptionId">;
@@ -44,6 +45,7 @@ export function useCheckoutDiffQuery({
baseRef,
ignoreWhitespace,
enabled = true,
queryScope,
}: UseCheckoutDiffQueryOptions) {
const isConnected = useHostRuntimeIsConnected(serverId);
const normalizedCompare = useMemo(
@@ -53,10 +55,17 @@ export function useCheckoutDiffQuery({
const compareMode = normalizedCompare.mode;
const compareBaseRef = normalizedCompare.baseRef;
const compareIgnoreWhitespace = normalizedCompare.ignoreWhitespace;
const queryKey = useMemo(
() => checkoutDiffQueryKey(serverId, cwd, mode, baseRef, compareIgnoreWhitespace),
[serverId, cwd, mode, baseRef, compareIgnoreWhitespace],
);
const queryKey = useMemo(() => {
const comparisonKey = checkoutDiffQueryKey(
serverId,
cwd,
compareMode,
compareBaseRef,
compareIgnoreWhitespace,
);
const normalizedScope = queryScope?.trim();
return normalizedScope ? [...comparisonKey, "scope", normalizedScope] : comparisonKey;
}, [serverId, cwd, compareMode, compareBaseRef, compareIgnoreWhitespace, queryScope]);
const subscriptionId = useMemo(() => `checkoutDiff:${JSON.stringify(queryKey)}`, [queryKey]);
const routeEnabled = Boolean(enabled && isConnected && cwd);