Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/lib/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import {
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import TOML from "@iarna/toml";
import { AI_GATEWAY_OPENAI_URL, AI_GATEWAY_URL } from "@/lib/const.js";
import {
AI_GATEWAY_OPENAI_URL,
AI_GATEWAY_URL,
CLAUDE_AUTO_COMPACT_WINDOW,
CLAUDE_AUTOCOMPACT_PCT,
} from "@/lib/const.js";

export type Tool =
| "claude-code"
Expand Down Expand Up @@ -93,6 +98,8 @@ const CLAUDE_K = {
sonnet: atob("QU5USFJPUElDX0RFRkFVTFRfU09OTkVUX01PREVM"),
haiku: atob("QU5USFJPUElDX0RFRkFVTFRfSEFJS1VfTU9ERUw="),
agentTeams: atob("Q0xBVURFX0NPREVfRVhQRVJJTUVOVEFMX0FHRU5UX1RFQU1T"),
autoCompactWindow: atob("Q0xBVURFX0NPREVfQVVUT19DT01QQUNUX1dJTkRPVw=="),
autoCompactPct: atob("Q0xBVURFX0FVVE9DT01QQUNUX1BDVF9PVkVSUklERQ=="),
};

const CODEX_K = {
Expand Down Expand Up @@ -395,6 +402,8 @@ export function configureClaudeCode(creds: Credentials): ConfigureResult[] {
[CLAUDE_K.sonnet]: model,
[CLAUDE_K.haiku]: model,
[CLAUDE_K.agentTeams]: "1",
[CLAUDE_K.autoCompactWindow]: CLAUDE_AUTO_COMPACT_WINDOW,
[CLAUDE_K.autoCompactPct]: CLAUDE_AUTOCOMPACT_PCT,
},
});

Expand Down
6 changes: 6 additions & 0 deletions src/lib/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export const SSO_URL = `${BASE_URL}/sso-wrapper`;
export const AI_GATEWAY_URL = `${BASE_URL}/gateway`;
export const AI_GATEWAY_OPENAI_URL = `${AI_GATEWAY_URL}/v1`;

// Self-hosted gateway model has a 196608-token window. Telling Claude Code
// to treat that as its effective window and to fire auto-compaction at 85%
// of it (≈167K) keeps compaction well below the hard limit.
export const CLAUDE_AUTO_COMPACT_WINDOW = "196608";
export const CLAUDE_AUTOCOMPACT_PCT = "85";

export const VERSION: string = pkg.version;

export const HELP_HINT = "Run `codev --help` to see all commands.";
Expand Down
22 changes: 18 additions & 4 deletions tests/UpdateApp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function allFrames(frames: string[]): string {
return frames.join("\n");
}

// Windows CI is 2-3× slower than Linux/macOS and vi.waitFor's default ~1s
// timeout isn't enough for the full UpdateApp render pipeline (detect →
// updating → TaskList settle → parent setPhase → render Happy coding).
// 10s matches the slack we give Ink renders elsewhere (see tests/
// InstallApp.test.tsx#waitForFrame).
const WAIT_OPTS = { timeout: 10_000, interval: 50 } as const;

afterEach(() => {
cleanup();
});
Expand All @@ -70,7 +77,10 @@ describe("UpdateApp", () => {
);

const { frames } = render(<UpdateApp />);
await vi.waitFor(() => expect(allFrames(frames)).toContain("Happy coding"));
await vi.waitFor(
() => expect(allFrames(frames)).toContain("Happy coding"),
WAIT_OPTS,
);

const history = allFrames(frames);
expect(history).toContain("Updated opencode-ai");
Expand All @@ -86,7 +96,10 @@ describe("UpdateApp", () => {
const existsSpy = vi.mocked(fs.existsSync).mockReturnValue(false);

const { frames } = render(<UpdateApp />);
await vi.waitFor(() => expect(allFrames(frames)).toContain("Happy coding"));
await vi.waitFor(
() => expect(allFrames(frames)).toContain("Happy coding"),
WAIT_OPTS,
);

const history = allFrames(frames);
expect(history).toContain("Nothing to update");
Expand All @@ -109,8 +122,9 @@ describe("UpdateApp", () => {
);

const { frames } = render(<UpdateApp />);
await vi.waitFor(() =>
expect(allFrames(frames)).toContain("Failed to update opencode-ai"),
await vi.waitFor(
() => expect(allFrames(frames)).toContain("Failed to update opencode-ai"),
WAIT_OPTS,
);

const history = allFrames(frames);
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/configure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ describe("configureClaudeCode", () => {
ANTHROPIC_DEFAULT_SONNET_MODEL: "chosen-model",
ANTHROPIC_DEFAULT_HAIKU_MODEL: "chosen-model",
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: "1",
CLAUDE_CODE_AUTO_COMPACT_WINDOW: "196608",
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE: "85",
});
});

Expand Down
Loading