Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix: isolate cli provider connection tests

nash_su17068583be23
diff --git a/src/lib/connection-tests.test.ts b/src/lib/connection-tests.test.ts
index fcfb708b..9cf50568 100644
--- a/src/lib/connection-tests.test.ts
+++ b/src/lib/connection-tests.test.ts
@@ -113,4 +113,60 @@ describe("provider connection tests", () => {
expect.objectContaining({ max_tokens: 512 }),
)
})
+
+ it.each([
+ ["Claude Code", "claude-code", "connection", false],
+ ["Claude Code", "claude-code", "connection", undefined],
+ ["Claude Code", "claude-code", "functional", false],
+ ["Claude Code", "claude-code", "functional", undefined],
+ ["Codex CLI", "codex-cli", "connection", false],
+ ["Codex CLI", "codex-cli", "connection", undefined],
+ ["Codex CLI", "codex-cli", "functional", false],
+ ["Codex CLI", "codex-cli", "functional", undefined],
+ ] as const)(
+ "isolates local CLI configuration during %s %s tests",
+ async (_label, provider, kind, initialIsolation) => {
+ streamChatMock.mockImplementationOnce(async (_cfg, _messages, callbacks) => {
+ callbacks.onToken(kind === "functional" ? "LLM_WIKI_TEST_OK" : "OK")
+ callbacks.onDone()
+ })
+ const cfg: LlmConfig = {
+ ...llmConfig,
+ provider,
+ ...(initialIsolation === undefined ? {} : { localCliIsolation: initialIsolation }),
+ }
+
+ const result = kind === "functional"
+ ? await testLlmFunction(cfg)
+ : await testLlmConnection(cfg)
+
+ expect(result.ok).toBe(true)
+ expect(streamChatMock).toHaveBeenCalledWith(
+ expect.objectContaining({ provider, localCliIsolation: true }),
+ expect.any(Array),
+ expect.any(Object),
+ undefined,
+ { max_tokens: LLM_PROVIDER_TEST_MAX_TOKENS, reasoning: { mode: "off" } },
+ )
+ expect(cfg.localCliIsolation).toBe(initialIsolation)
+ },
+ )
+
+ it("does not isolate non-CLI provider connection tests", async () => {
+ streamChatMock.mockImplementationOnce(async (_cfg, _messages, callbacks) => {
+ callbacks.onToken("OK")
+ callbacks.onDone()
+ })
+
+ const result = await testLlmConnection(llmConfig)
+
+ expect(result.ok).toBe(true)
+ expect(streamChatMock).toHaveBeenCalledWith(
+ llmConfig,
+ expect.any(Array),
+ expect.any(Object),
+ undefined,
+ { max_tokens: LLM_PROVIDER_TEST_MAX_TOKENS, reasoning: { mode: "off" } },
+ )
+ })
})
diff --git a/src/lib/connection-tests.ts b/src/lib/connection-tests.ts
index 9760e7fa..d7e6a086 100644
--- a/src/lib/connection-tests.ts
+++ b/src/lib/connection-tests.ts
@@ -9,6 +9,13 @@ export interface ProviderTestResult {
export const LLM_PROVIDER_TEST_MAX_TOKENS = 512
+function configForProviderTest(cfg: LlmConfig): LlmConfig {
+ if (cfg.provider === "claude-code" || cfg.provider === "codex-cli") {
+ return { ...cfg, localCliIsolation: true }
+ }
+ return cfg
+}
+
export async function testEmbeddingConnection(cfg: EmbeddingConfig): Promise<ProviderTestResult> {
if (!cfg.endpoint.trim()) {
return { ok: false, message: "Embedding endpoint is empty." }
@@ -64,11 +71,12 @@ export async function testEmbeddingFunction(cfg: EmbeddingConfig): Promise<Provi
export async function testLlmConnection(cfg: LlmConfig): Promise<ProviderTestResult> {
const started = performance.now()
+ const testCfg = configForProviderTest(cfg)
let content = ""
let errorMessage: string | null = null
await streamChat(
- cfg,
+ testCfg,
[
{ role: "system", content: "You are a connection checker. Reply briefly." },
{ role: "user", content: "Reply with one short word." },
@@ -91,11 +99,12 @@ export async function testLlmConnection(cfg: LlmConfig): Promise<ProviderTestRes
}
export async function testLlmFunction(cfg: LlmConfig): Promise<ProviderTestResult> {
+ const testCfg = configForProviderTest(cfg)
let content = ""
let errorMessage: string | null = null
await streamChat(
- cfg,
+ testCfg,
[
{
role: "system",