Skip to content

Commit 5dd1acf

Browse files
juliusmarmingecodex
andcommitted
fix(contracts): restore sidebar preview setting
Co-authored-by: codex <codex@users.noreply.github.com>
1 parent 9a56980 commit 5dd1acf

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

packages/contracts/src/settings.test.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,10 @@ import { describe, expect, it } from "vitest";
22
import { Schema } from "effect";
33

44
import { ProviderInstanceId } from "./providerInstance.ts";
5-
import {
6-
MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
7-
MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
8-
SidebarThreadPreviewCount,
9-
DEFAULT_SERVER_SETTINGS,
10-
ServerSettings,
11-
ServerSettingsPatch,
12-
} from "./settings.ts";
5+
import { DEFAULT_SERVER_SETTINGS, ServerSettings, ServerSettingsPatch } from "./settings.ts";
136

147
const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
158
const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
16-
const decodeSidebarThreadPreviewCount = Schema.decodeUnknownSync(SidebarThreadPreviewCount);
17-
18-
describe("SidebarThreadPreviewCount", () => {
19-
it("accepts the configured 1-15 range", () => {
20-
expect(decodeSidebarThreadPreviewCount(MIN_SIDEBAR_THREAD_PREVIEW_COUNT)).toBe(1);
21-
expect(decodeSidebarThreadPreviewCount(MAX_SIDEBAR_THREAD_PREVIEW_COUNT)).toBe(15);
22-
});
23-
24-
it("rejects values outside the configured range", () => {
25-
expect(() => decodeSidebarThreadPreviewCount(MIN_SIDEBAR_THREAD_PREVIEW_COUNT - 1)).toThrow();
26-
expect(() => decodeSidebarThreadPreviewCount(MAX_SIDEBAR_THREAD_PREVIEW_COUNT + 1)).toThrow();
27-
});
28-
});
299

3010
describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
3111
it("defaults to an empty record so legacy configs without the key still decode", () => {

packages/contracts/src/settings.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ export const SidebarProjectGroupingMode = Schema.Literals([
2727
]);
2828
export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type;
2929
export const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
30+
export const MIN_SIDEBAR_THREAD_PREVIEW_COUNT = 1;
31+
export const MAX_SIDEBAR_THREAD_PREVIEW_COUNT = 15;
32+
export const SidebarThreadPreviewCount = Schema.Int.check(
33+
Schema.isBetween({
34+
minimum: MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
35+
maximum: MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
36+
}),
37+
);
38+
export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type;
39+
export const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6;
3040

3141
export const ClientSettingsSchema = Schema.Struct({
3242
autoOpenPlanSidebar: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
@@ -75,6 +85,9 @@ export const ClientSettingsSchema = Schema.Struct({
7585
sidebarThreadSortOrder: SidebarThreadSortOrder.pipe(
7686
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_SORT_ORDER)),
7787
),
88+
sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
89+
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
90+
),
7891
timestampFormat: TimestampFormat.pipe(
7992
Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
8093
),

0 commit comments

Comments
 (0)