test(klient): add real-server smoke coverage#1713
Conversation
Add transport and persisted-session smoke scripts for HTTP, WebSocket, and scoped service calls. Type-check all examples and document remote-server usage and side effects.
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 553b56ec4c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| assert.equal(matches.length, 1, `expected cwd must identify exactly one session; found ${String(matches.length)}`); | ||
| return matches[0]; | ||
| } | ||
| return sessions[0]; |
There was a problem hiding this comment.
Require a real cold session for the history probe
When neither KIMI_SMOKE_EXPECT_SESSION_ID nor KIMI_SMOKE_EXPECT_CWD is set, this falls back to sessions[0]; ISessionIndex.list is recency-sorted and includes currently live sessions, so on an active server the "cold" metadata read can hit a live scope and pass without exercising the persisted cold-session regression this smoke is meant to catch. Please require an explicit target or otherwise avoid treating an arbitrary indexed session as cold.
Useful? React with 👍 / 👎.
| }); | ||
| const listenErrors: unknown[] = []; | ||
| const errorSubscription = ws.onDidListenError((error) => listenErrors.push(error)); | ||
| const subscription = ws.listen('events', resolveEvent); |
There was a problem hiding this comment.
Filter the WebSocket smoke event by session
The core events stream is process-wide, but this handler resolves the smoke's eventReceived promise on the first event from any session. On a shared or active real server, an unrelated event can arrive within the 5s window and make this check pass even if the profile update for the owned smoke session is never delivered over WebSocket, so the subscription coverage becomes a false positive.
Useful? React with 👍 / 👎.
Related Issue
No linked issue. The Klient package had unit coverage for its transports but no repeatable smoke checks against a real kap-server, especially for persisted sessions across the v1-to-v2 engine transition.
Problem
Klient examples mostly printed responses without assertions and were not included in package type checking. This made it difficult to verify HTTP and WebSocket behavior across core, session, and agent scopes, or to distinguish an actually missing session from a persisted cold session that the v2 dispatcher cannot materialize.
What changed
typecheckcommand.Checklist
gen-changesetsskill, or this PR needs no changeset. Tests/examples-only change; no release bump is needed.gen-docsskill, or this PR needs no doc update. Package README usage was updated; user documentation is unaffected.Verification
pnpm --filter @moonshot-ai/klient testpnpm --filter @moonshot-ai/klient typecheckpnpm --filter @moonshot-ai/klient buildpnpm exec oxlint --type-aware examples/smoke.ts examples/session-history-smoke.ts examples/inspect-init.tssession.not_foundthrough the v2 session scope while workspace and v1 projections remained intact.