Merge branch 'main' into t3code/remote-git-projects
This commit is contained in:
16 files changed
+308
-6
No files matched your search
@@ -52,6 +52,7 @@ const clientSettings: ClientSettings = {
|
||||
autoOpenPlanSidebar: false,
|
||||
confirmThreadArchive: true,
|
||||
confirmThreadDelete: false,
|
||||
diffIgnoreWhitespace: true,
|
||||
diffWordWrap: true,
|
||||
favorites: [],
|
||||
providerModelPreferences: {},
|
||||
|
||||
@@ -506,6 +506,7 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
fromCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 1),
|
||||
toCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 2),
|
||||
fallbackFromToHead: false,
|
||||
ignoreWhitespace: false,
|
||||
});
|
||||
assert.equal(incrementalDiff.includes("README.md"), true);
|
||||
|
||||
@@ -514,6 +515,7 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
fromCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 0),
|
||||
toCheckpointRef: checkpointRefForThreadTurn(THREAD_ID, 2),
|
||||
fallbackFromToHead: false,
|
||||
ignoreWhitespace: false,
|
||||
});
|
||||
assert.equal(fullDiff.includes("README.md"), true);
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ describe("CheckpointDiffQueryLive", () => {
|
||||
readonly fromCheckpointRef: CheckpointRef;
|
||||
readonly toCheckpointRef: CheckpointRef;
|
||||
readonly cwd: string;
|
||||
readonly ignoreWhitespace: boolean;
|
||||
}> = [];
|
||||
|
||||
const threadCheckpointContext = makeThreadCheckpointContext({
|
||||
@@ -68,9 +69,14 @@ describe("CheckpointDiffQueryLive", () => {
|
||||
return true;
|
||||
}),
|
||||
restoreCheckpoint: () => Effect.succeed(true),
|
||||
diffCheckpoints: ({ fromCheckpointRef, toCheckpointRef, cwd }) =>
|
||||
diffCheckpoints: ({ fromCheckpointRef, toCheckpointRef, cwd, ignoreWhitespace }) =>
|
||||
Effect.sync(() => {
|
||||
diffCheckpointsCalls.push({ fromCheckpointRef, toCheckpointRef, cwd });
|
||||
diffCheckpointsCalls.push({
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef,
|
||||
cwd,
|
||||
ignoreWhitespace,
|
||||
});
|
||||
return "diff patch";
|
||||
}),
|
||||
deleteCheckpointRefs: () => Effect.void,
|
||||
@@ -102,6 +108,7 @@ describe("CheckpointDiffQueryLive", () => {
|
||||
threadId,
|
||||
fromTurnCount: 0,
|
||||
toTurnCount: 1,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
@@ -113,6 +120,7 @@ describe("CheckpointDiffQueryLive", () => {
|
||||
cwd: "/tmp/workspace",
|
||||
fromCheckpointRef: expectedFromRef,
|
||||
toCheckpointRef,
|
||||
ignoreWhitespace: true,
|
||||
},
|
||||
]);
|
||||
expect(result).toEqual({
|
||||
@@ -123,6 +131,67 @@ describe("CheckpointDiffQueryLive", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("defaults to hide whitespace changes", async () => {
|
||||
const projectId = ProjectId.make("project-default-whitespace");
|
||||
const threadId = ThreadId.make("thread-default-whitespace");
|
||||
const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
|
||||
const diffCheckpointsCalls: Array<{ readonly ignoreWhitespace: boolean }> = [];
|
||||
|
||||
const threadCheckpointContext = makeThreadCheckpointContext({
|
||||
projectId,
|
||||
threadId,
|
||||
workspaceRoot: "/tmp/workspace",
|
||||
worktreePath: null,
|
||||
checkpointTurnCount: 1,
|
||||
checkpointRef: toCheckpointRef,
|
||||
});
|
||||
|
||||
const checkpointStore: CheckpointStoreShape = {
|
||||
isGitRepository: () => Effect.succeed(true),
|
||||
captureCheckpoint: () => Effect.void,
|
||||
hasCheckpointRef: () => Effect.succeed(true),
|
||||
restoreCheckpoint: () => Effect.succeed(true),
|
||||
diffCheckpoints: ({ ignoreWhitespace }) =>
|
||||
Effect.sync(() => {
|
||||
diffCheckpointsCalls.push({ ignoreWhitespace });
|
||||
return "diff patch";
|
||||
}),
|
||||
deleteCheckpointRefs: () => Effect.void,
|
||||
};
|
||||
|
||||
const layer = CheckpointDiffQueryLive.pipe(
|
||||
Layer.provideMerge(Layer.succeed(CheckpointStore, checkpointStore)),
|
||||
Layer.provideMerge(
|
||||
Layer.succeed(ProjectionSnapshotQuery, {
|
||||
getSnapshot: () =>
|
||||
Effect.die("CheckpointDiffQuery should not request the full orchestration snapshot"),
|
||||
getShellSnapshot: () =>
|
||||
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
|
||||
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
|
||||
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
|
||||
getProjectShellById: () => Effect.succeed(Option.none()),
|
||||
getFirstActiveThreadIdByProjectId: () => Effect.succeed(Option.none()),
|
||||
getThreadCheckpointContext: () => Effect.succeed(Option.some(threadCheckpointContext)),
|
||||
getThreadShellById: () => Effect.succeed(Option.none()),
|
||||
getThreadDetailById: () => Effect.succeed(Option.none()),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
await Effect.runPromise(
|
||||
Effect.gen(function* () {
|
||||
const query = yield* CheckpointDiffQuery;
|
||||
return yield* query.getTurnDiff({
|
||||
threadId,
|
||||
fromTurnCount: 0,
|
||||
toTurnCount: 1,
|
||||
});
|
||||
}).pipe(Effect.provide(layer)),
|
||||
);
|
||||
|
||||
expect(diffCheckpointsCalls).toEqual([{ ignoreWhitespace: true }]);
|
||||
});
|
||||
|
||||
it("fails when the thread is missing from the snapshot", async () => {
|
||||
const threadId = ThreadId.make("thread-missing");
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ const make = Effect.gen(function* () {
|
||||
const getTurnDiff: CheckpointDiffQueryShape["getTurnDiff"] = Effect.fn("getTurnDiff")(
|
||||
function* (input) {
|
||||
const operation = "CheckpointDiffQuery.getTurnDiff";
|
||||
const ignoreWhitespace = input.ignoreWhitespace ?? true;
|
||||
|
||||
if (input.fromTurnCount === input.toTurnCount) {
|
||||
const emptyDiff: OrchestrationGetTurnDiffResultType = {
|
||||
@@ -131,6 +132,7 @@ const make = Effect.gen(function* () {
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef,
|
||||
fallbackFromToHead: false,
|
||||
ignoreWhitespace,
|
||||
});
|
||||
|
||||
const turnDiff: OrchestrationGetTurnDiffResultType = {
|
||||
@@ -157,6 +159,7 @@ const make = Effect.gen(function* () {
|
||||
threadId: input.threadId,
|
||||
fromTurnCount: 0,
|
||||
toTurnCount: input.toTurnCount,
|
||||
ignoreWhitespace: input.ignoreWhitespace ?? true,
|
||||
}).pipe(Effect.map((result): OrchestrationGetFullThreadDiffResult => result));
|
||||
|
||||
return {
|
||||
|
||||
@@ -114,6 +114,7 @@ it.layer(TestLayer)("CheckpointStoreLive", (it) => {
|
||||
cwd: tmp,
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
|
||||
expect(diff).toContain("diff --git");
|
||||
@@ -121,5 +122,80 @@ it.layer(TestLayer)("CheckpointStoreLive", (it) => {
|
||||
expect(diff).toContain("+line 04999");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("can hide indentation churn when changes wrap existing lines", () =>
|
||||
Effect.gen(function* () {
|
||||
const tmp = yield* makeTmpDir();
|
||||
yield* initRepoWithCommit(tmp);
|
||||
const checkpointStore = yield* CheckpointStore;
|
||||
const threadId = ThreadId.make("thread-checkpoint-store-whitespace");
|
||||
const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
|
||||
const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
|
||||
|
||||
const componentPath = path.join(tmp, "Component.tsx");
|
||||
yield* writeTextFile(
|
||||
componentPath,
|
||||
[
|
||||
"export function View() {",
|
||||
" return (",
|
||||
" <section>",
|
||||
" <h1>Title</h1>",
|
||||
" <p>Body</p>",
|
||||
" </section>",
|
||||
" );",
|
||||
"}",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
yield* checkpointStore.captureCheckpoint({
|
||||
cwd: tmp,
|
||||
checkpointRef: fromCheckpointRef,
|
||||
});
|
||||
yield* writeTextFile(
|
||||
componentPath,
|
||||
[
|
||||
"export function View() {",
|
||||
" return (",
|
||||
" <section>",
|
||||
" {isReady ? (",
|
||||
" <div>",
|
||||
" <h1>Title</h1>",
|
||||
" <p>Body</p>",
|
||||
" </div>",
|
||||
" ) : null}",
|
||||
" </section>",
|
||||
" );",
|
||||
"}",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
yield* checkpointStore.captureCheckpoint({
|
||||
cwd: tmp,
|
||||
checkpointRef: toCheckpointRef,
|
||||
});
|
||||
|
||||
const normalDiff = yield* checkpointStore.diffCheckpoints({
|
||||
cwd: tmp,
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef,
|
||||
ignoreWhitespace: false,
|
||||
});
|
||||
const whitespaceIgnoredDiff = yield* checkpointStore.diffCheckpoints({
|
||||
cwd: tmp,
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
|
||||
expect(normalDiff).toContain("diff --git");
|
||||
expect(normalDiff).toContain("- <h1>Title</h1>");
|
||||
expect(normalDiff).toContain("+ <h1>Title</h1>");
|
||||
expect(whitespaceIgnoredDiff).toContain("diff --git");
|
||||
expect(whitespaceIgnoredDiff).toContain("+ {isReady ? (");
|
||||
expect(whitespaceIgnoredDiff).toContain("+ <div>");
|
||||
expect(whitespaceIgnoredDiff).not.toContain("- <h1>Title</h1>");
|
||||
expect(whitespaceIgnoredDiff).not.toContain("+ <h1>Title</h1>");
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -259,10 +259,20 @@ const makeCheckpointStore = Effect.gen(function* () {
|
||||
});
|
||||
}
|
||||
|
||||
const diffArgs = [
|
||||
"diff",
|
||||
"--patch",
|
||||
"--minimal",
|
||||
"--no-color",
|
||||
...(input.ignoreWhitespace ? ["--ignore-all-space"] : []),
|
||||
fromCommitOid,
|
||||
toCommitOid,
|
||||
];
|
||||
|
||||
const result = yield* vcs.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["diff", "--patch", "--minimal", "--no-color", fromCommitOid, toCommitOid],
|
||||
args: diffArgs,
|
||||
maxOutputBytes: CHECKPOINT_DIFF_MAX_OUTPUT_BYTES,
|
||||
});
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface DiffCheckpointsInput {
|
||||
readonly fromCheckpointRef: CheckpointRef;
|
||||
readonly toCheckpointRef: CheckpointRef;
|
||||
readonly fallbackFromToHead?: boolean;
|
||||
readonly ignoreWhitespace: boolean;
|
||||
}
|
||||
|
||||
export interface DeleteCheckpointRefsInput {
|
||||
|
||||
@@ -237,6 +237,7 @@ const make = Effect.gen(function* () {
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef: targetCheckpointRef,
|
||||
fallbackFromToHead: false,
|
||||
ignoreWhitespace: false,
|
||||
})
|
||||
.pipe(
|
||||
Effect.map((diff) =>
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
Columns2Icon,
|
||||
PilcrowIcon,
|
||||
Rows3Icon,
|
||||
TextWrapIcon,
|
||||
} from "lucide-react";
|
||||
@@ -172,6 +173,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
|
||||
const settings = useSettings();
|
||||
const [diffRenderMode, setDiffRenderMode] = useState<DiffRenderMode>("stacked");
|
||||
const [diffWordWrap, setDiffWordWrap] = useState(settings.diffWordWrap);
|
||||
const [diffIgnoreWhitespace, setDiffIgnoreWhitespace] = useState(settings.diffIgnoreWhitespace);
|
||||
const patchViewportRef = useRef<HTMLDivElement>(null);
|
||||
const turnStripRef = useRef<HTMLDivElement>(null);
|
||||
const previousDiffOpenRef = useRef(false);
|
||||
@@ -277,6 +279,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
|
||||
threadId: activeThreadId,
|
||||
fromTurnCount: activeCheckpointRange?.fromTurnCount ?? null,
|
||||
toTurnCount: activeCheckpointRange?.toTurnCount ?? null,
|
||||
ignoreWhitespace: diffIgnoreWhitespace,
|
||||
cacheScope: selectedTurn ? `turn:${selectedTurn.turnId}` : conversationCacheScope,
|
||||
enabled: isGitRepo,
|
||||
}),
|
||||
@@ -317,9 +320,10 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
|
||||
useEffect(() => {
|
||||
if (diffOpen && !previousDiffOpenRef.current) {
|
||||
setDiffWordWrap(settings.diffWordWrap);
|
||||
setDiffIgnoreWhitespace(settings.diffIgnoreWhitespace);
|
||||
}
|
||||
previousDiffOpenRef.current = diffOpen;
|
||||
}, [diffOpen, settings.diffWordWrap]);
|
||||
}, [diffOpen, settings.diffIgnoreWhitespace, settings.diffWordWrap]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedFilePath || !patchViewportRef.current) {
|
||||
@@ -551,6 +555,18 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
|
||||
>
|
||||
<TextWrapIcon className="size-3" />
|
||||
</Toggle>
|
||||
<Toggle
|
||||
aria-label={diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
|
||||
title={diffIgnoreWhitespace ? "Show whitespace changes" : "Hide whitespace changes"}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
pressed={diffIgnoreWhitespace}
|
||||
onPressedChange={(pressed) => {
|
||||
setDiffIgnoreWhitespace(Boolean(pressed));
|
||||
}}
|
||||
>
|
||||
<PilcrowIcon className="size-3" />
|
||||
</Toggle>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -386,6 +386,9 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
...(settings.diffWordWrap !== DEFAULT_UNIFIED_SETTINGS.diffWordWrap
|
||||
? ["Diff line wrapping"]
|
||||
: []),
|
||||
...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace
|
||||
? ["Diff whitespace changes"]
|
||||
: []),
|
||||
...(settings.autoOpenPlanSidebar !== DEFAULT_UNIFIED_SETTINGS.autoOpenPlanSidebar
|
||||
? ["Auto-open task panel"]
|
||||
: []),
|
||||
@@ -415,6 +418,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
settings.confirmThreadDelete,
|
||||
settings.addProjectBaseDirectory,
|
||||
settings.defaultThreadEnvMode,
|
||||
settings.diffIgnoreWhitespace,
|
||||
settings.diffWordWrap,
|
||||
settings.enableAssistantStreaming,
|
||||
settings.timestampFormat,
|
||||
@@ -889,6 +893,32 @@ export function GeneralSettingsPanel() {
|
||||
}
|
||||
/>
|
||||
|
||||
<SettingsRow
|
||||
title="Hide whitespace changes"
|
||||
description="Set whether the diff panel ignores whitespace-only edits by default."
|
||||
resetAction={
|
||||
settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace ? (
|
||||
<SettingResetButton
|
||||
label="diff whitespace changes"
|
||||
onClick={() =>
|
||||
updateSettings({
|
||||
diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
control={
|
||||
<Switch
|
||||
checked={settings.diffIgnoreWhitespace}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({ diffIgnoreWhitespace: Boolean(checked) })
|
||||
}
|
||||
aria-label="Hide whitespace changes by default"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
<SettingsRow
|
||||
title="Assistant output"
|
||||
description="Show token-by-token output while a response is in progress."
|
||||
|
||||
@@ -30,6 +30,7 @@ describe("providerQueryKeys.checkpointDiff", () => {
|
||||
threadId,
|
||||
fromTurnCount: 1,
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: false,
|
||||
} as const;
|
||||
|
||||
expect(
|
||||
@@ -44,10 +45,32 @@ describe("providerQueryKeys.checkpointDiff", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("includes ignoreWhitespace so normal and whitespace-hidden diffs do not collide", () => {
|
||||
const baseInput = {
|
||||
environmentId,
|
||||
threadId,
|
||||
fromTurnCount: 1,
|
||||
toTurnCount: 2,
|
||||
cacheScope: "turn:abc",
|
||||
} as const;
|
||||
|
||||
expect(
|
||||
providerQueryKeys.checkpointDiff({
|
||||
...baseInput,
|
||||
ignoreWhitespace: false,
|
||||
}),
|
||||
).not.toEqual(
|
||||
providerQueryKeys.checkpointDiff({
|
||||
...baseInput,
|
||||
ignoreWhitespace: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("checkpointDiffQueryOptions", () => {
|
||||
it("forwards checkpoint range to the provider API", async () => {
|
||||
it("forwards checkpoint range to the provider API by default", async () => {
|
||||
const getTurnDiff = vi.fn().mockResolvedValue({ diff: "patch" });
|
||||
const getFullThreadDiff = vi.fn().mockResolvedValue({ diff: "patch" });
|
||||
mockNativeApi({ getTurnDiff, getFullThreadDiff });
|
||||
@@ -57,6 +80,7 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
threadId,
|
||||
fromTurnCount: 3,
|
||||
toTurnCount: 4,
|
||||
ignoreWhitespace: false,
|
||||
cacheScope: "turn:abc",
|
||||
});
|
||||
|
||||
@@ -67,6 +91,33 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
threadId,
|
||||
fromTurnCount: 3,
|
||||
toTurnCount: 4,
|
||||
ignoreWhitespace: false,
|
||||
});
|
||||
expect(getFullThreadDiff).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("forwards whitespace-hidden checkpoint range to the provider API", async () => {
|
||||
const getTurnDiff = vi.fn().mockResolvedValue({ diff: "patch" });
|
||||
const getFullThreadDiff = vi.fn().mockResolvedValue({ diff: "patch" });
|
||||
mockNativeApi({ getTurnDiff, getFullThreadDiff });
|
||||
|
||||
const options = checkpointDiffQueryOptions({
|
||||
environmentId,
|
||||
threadId,
|
||||
fromTurnCount: 3,
|
||||
toTurnCount: 4,
|
||||
ignoreWhitespace: true,
|
||||
cacheScope: "turn:abc",
|
||||
});
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
await queryClient.fetchQuery(options);
|
||||
|
||||
expect(getTurnDiff).toHaveBeenCalledWith({
|
||||
threadId,
|
||||
fromTurnCount: 3,
|
||||
toTurnCount: 4,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
expect(getFullThreadDiff).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -81,6 +132,7 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
threadId,
|
||||
fromTurnCount: 0,
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: true,
|
||||
cacheScope: "thread:all",
|
||||
});
|
||||
|
||||
@@ -90,6 +142,7 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
expect(getFullThreadDiff).toHaveBeenCalledWith({
|
||||
threadId,
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
expect(getTurnDiff).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -104,6 +157,7 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
threadId,
|
||||
fromTurnCount: 4,
|
||||
toTurnCount: 3,
|
||||
ignoreWhitespace: false,
|
||||
cacheScope: "turn:invalid",
|
||||
});
|
||||
|
||||
@@ -122,6 +176,7 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
threadId,
|
||||
fromTurnCount: 1,
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: false,
|
||||
cacheScope: "turn:abc",
|
||||
});
|
||||
const retry = options.retry;
|
||||
@@ -147,6 +202,7 @@ describe("checkpointDiffQueryOptions", () => {
|
||||
threadId,
|
||||
fromTurnCount: 1,
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: false,
|
||||
cacheScope: "turn:abc",
|
||||
});
|
||||
const retryDelay = options.retryDelay;
|
||||
|
||||
@@ -13,6 +13,7 @@ interface CheckpointDiffQueryInput {
|
||||
threadId: ThreadId | null;
|
||||
fromTurnCount: number | null;
|
||||
toTurnCount: number | null;
|
||||
ignoreWhitespace: boolean;
|
||||
cacheScope?: string | null;
|
||||
enabled?: boolean;
|
||||
}
|
||||
@@ -27,6 +28,7 @@ export const providerQueryKeys = {
|
||||
input.threadId,
|
||||
input.fromTurnCount,
|
||||
input.toTurnCount,
|
||||
input.ignoreWhitespace,
|
||||
input.cacheScope ?? null,
|
||||
] as const,
|
||||
};
|
||||
@@ -36,6 +38,7 @@ function decodeCheckpointDiffRequest(input: CheckpointDiffQueryInput) {
|
||||
return Schema.decodeUnknownOption(OrchestrationGetFullThreadDiffInput)({
|
||||
threadId: input.threadId,
|
||||
toTurnCount: input.toTurnCount,
|
||||
ignoreWhitespace: input.ignoreWhitespace,
|
||||
}).pipe(Option.map((fields) => ({ kind: "fullThreadDiff" as const, input: fields })));
|
||||
}
|
||||
|
||||
@@ -43,6 +46,7 @@ function decodeCheckpointDiffRequest(input: CheckpointDiffQueryInput) {
|
||||
threadId: input.threadId,
|
||||
fromTurnCount: input.fromTurnCount,
|
||||
toTurnCount: input.toTurnCount,
|
||||
ignoreWhitespace: input.ignoreWhitespace,
|
||||
}).pipe(Option.map((fields) => ({ kind: "turnDiff" as const, input: fields })));
|
||||
}
|
||||
|
||||
|
||||
@@ -542,6 +542,7 @@ describe("wsApi", () => {
|
||||
autoOpenPlanSidebar: false,
|
||||
confirmThreadArchive: true,
|
||||
confirmThreadDelete: false,
|
||||
diffIgnoreWhitespace: true,
|
||||
diffWordWrap: true,
|
||||
favorites: [],
|
||||
providerModelPreferences: {},
|
||||
@@ -602,6 +603,7 @@ describe("wsApi", () => {
|
||||
autoOpenPlanSidebar: false,
|
||||
confirmThreadArchive: true,
|
||||
confirmThreadDelete: false,
|
||||
diffIgnoreWhitespace: true,
|
||||
diffWordWrap: true,
|
||||
favorites: [],
|
||||
providerModelPreferences: {},
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ModelSelection,
|
||||
OrchestrationCommand,
|
||||
OrchestrationEvent,
|
||||
OrchestrationGetFullThreadDiffInput,
|
||||
OrchestrationGetTurnDiffInput,
|
||||
OrchestrationLatestTurn,
|
||||
ProjectCreatedPayload,
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
import { ProviderInstanceId } from "./providerInstance.ts";
|
||||
|
||||
const decodeTurnDiffInput = Schema.decodeUnknownEffect(OrchestrationGetTurnDiffInput);
|
||||
const decodeFullThreadDiffInput = Schema.decodeUnknownEffect(OrchestrationGetFullThreadDiffInput);
|
||||
const decodeThreadTurnDiff = Schema.decodeUnknownEffect(ThreadTurnDiff);
|
||||
const decodeProjectCreateCommand = Schema.decodeUnknownEffect(ProjectCreateCommand);
|
||||
const decodeProjectCreatedPayload = Schema.decodeUnknownEffect(ProjectCreatedPayload);
|
||||
@@ -59,6 +61,29 @@ it.effect("parses turn diff input when fromTurnCount <= toTurnCount", () =>
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("parses turn diff input with whitespace ignoring enabled", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeTurnDiffInput({
|
||||
threadId: "thread-1",
|
||||
fromTurnCount: 1,
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
assert.strictEqual(parsed.ignoreWhitespace, true);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("parses full thread diff input with whitespace ignoring enabled", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeFullThreadDiffInput({
|
||||
threadId: "thread-1",
|
||||
toTurnCount: 2,
|
||||
ignoreWhitespace: true,
|
||||
});
|
||||
assert.strictEqual(parsed.ignoreWhitespace, true);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rejects turn diff input when fromTurnCount > toTurnCount", () =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* Effect.exit(
|
||||
|
||||
@@ -1171,7 +1171,10 @@ export const DispatchResult = Schema.Struct({
|
||||
export type DispatchResult = typeof DispatchResult.Type;
|
||||
|
||||
export const OrchestrationGetTurnDiffInput = TurnCountRange.mapFields(
|
||||
Struct.assign({ threadId: ThreadId }),
|
||||
Struct.assign({
|
||||
threadId: ThreadId,
|
||||
ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
|
||||
}),
|
||||
{ unsafePreserveChecks: true },
|
||||
);
|
||||
export type OrchestrationGetTurnDiffInput = typeof OrchestrationGetTurnDiffInput.Type;
|
||||
@@ -1182,6 +1185,7 @@ export type OrchestrationGetTurnDiffResult = typeof OrchestrationGetTurnDiffResu
|
||||
export const OrchestrationGetFullThreadDiffInput = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
toTurnCount: NonNegativeInt,
|
||||
ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
|
||||
});
|
||||
export type OrchestrationGetFullThreadDiffInput = typeof OrchestrationGetFullThreadDiffInput.Type;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
autoOpenPlanSidebar: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
||||
confirmThreadArchive: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
confirmThreadDelete: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
||||
diffIgnoreWhitespace: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
||||
diffWordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
// Model favorites. Historically keyed by provider kind, now
|
||||
// widened to `ProviderInstanceId` so users can favorite a specific model
|
||||
@@ -451,6 +452,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
autoOpenPlanSidebar: Schema.optionalKey(Schema.Boolean),
|
||||
confirmThreadArchive: Schema.optionalKey(Schema.Boolean),
|
||||
confirmThreadDelete: Schema.optionalKey(Schema.Boolean),
|
||||
diffIgnoreWhitespace: Schema.optionalKey(Schema.Boolean),
|
||||
diffWordWrap: Schema.optionalKey(Schema.Boolean),
|
||||
favorites: Schema.optionalKey(
|
||||
Schema.Array(
|
||||
|
||||
Reference in new issue
Block a user