Skip to content

Commit 057a5c8

Browse files
t3dotggclaude
andcommitted
test(claude): cover all new dispatch branches per review
Table-driven emission of every silent subtype, task_updated, prompt_suggestion, high-priority notification (asserts exactly one warning row), and all three session_state_changed mappings. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 45251ac commit 057a5c8

1 file changed

Lines changed: 58 additions & 3 deletions

File tree

‎apps/server/src/provider/Layers/ClaudeAdapter.test.ts‎

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,8 +1726,9 @@ describe("ClaudeAdapterLive", () => {
17261726
runtimeMode: "full-access",
17271727
});
17281728

1729-
// Undeclared wire-only roster snapshot + typed UX-internal subtypes:
1730-
// all consumed silently, none may surface as unknown-subtype warnings.
1729+
// Undeclared wire-only roster snapshot + every typed UX-internal
1730+
// subtype and top-level type consumed silently: none may surface as
1731+
// unknown-subtype warnings.
17311732
for (const message of [
17321733
{
17331734
type: "system",
@@ -1736,7 +1737,21 @@ describe("ClaudeAdapterLive", () => {
17361737
session_id: "session",
17371738
uuid: "roster",
17381739
},
1740+
{
1741+
type: "system",
1742+
subtype: "task_updated",
1743+
task_id: "t1",
1744+
patch: { status: "running" },
1745+
session_id: "session",
1746+
uuid: "tu",
1747+
},
17391748
{ type: "system", subtype: "commands_changed", session_id: "session", uuid: "cc" },
1749+
{ type: "system", subtype: "model_refusal_fallback", session_id: "session", uuid: "mrf" },
1750+
{ type: "system", subtype: "local_command_output", session_id: "session", uuid: "lco" },
1751+
{ type: "system", subtype: "plugin_install", session_id: "session", uuid: "pi" },
1752+
{ type: "system", subtype: "memory_recall", session_id: "session", uuid: "mr" },
1753+
{ type: "system", subtype: "elicitation_complete", session_id: "session", uuid: "ec" },
1754+
{ type: "prompt_suggestion", suggestion: "try this", session_id: "session", uuid: "ps" },
17401755
{
17411756
type: "system",
17421757
subtype: "notification",
@@ -1749,6 +1764,30 @@ describe("ClaudeAdapterLive", () => {
17491764
]) {
17501765
harness.query.emit(message as unknown as SDKMessage);
17511766
}
1767+
// High-priority notifications DO surface as a warning row.
1768+
harness.query.emit({
1769+
type: "system",
1770+
subtype: "notification",
1771+
key: "limit",
1772+
text: "context window nearly full",
1773+
priority: "high",
1774+
session_id: "session",
1775+
uuid: "notif-high",
1776+
} as unknown as SDKMessage);
1777+
// session_state_changed maps to the matching session states.
1778+
for (const [state, uuid] of [
1779+
["running", "ssc-run"],
1780+
["requires_action", "ssc-req"],
1781+
["idle", "ssc-idle"],
1782+
]) {
1783+
harness.query.emit({
1784+
type: "system",
1785+
subtype: "session_state_changed",
1786+
state,
1787+
session_id: "session",
1788+
uuid,
1789+
} as unknown as SDKMessage);
1790+
}
17521791
// api_retry maps to a session heartbeat, not a warning row.
17531792
harness.query.emit({
17541793
type: "system",
@@ -1765,10 +1804,26 @@ describe("ClaudeAdapterLive", () => {
17651804
yield* Effect.yieldNow;
17661805

17671806
const warnings = runtimeEvents.filter((event) => event.type === "runtime.warning");
1807+
// Exactly one warning: the high-priority notification. Nothing else.
17681808
assert.deepEqual(
17691809
warnings.map((event) => event.payload.message),
1770-
[],
1810+
["context window nearly full"],
17711811
);
1812+
const sessionStates = runtimeEvents
1813+
.filter((event) => event.type === "session.state.changed")
1814+
.map((event) =>
1815+
event.type === "session.state.changed"
1816+
? `${event.payload.state}:${event.payload.reason ?? ""}`
1817+
: "",
1818+
)
1819+
.filter(
1820+
(entry) => entry.startsWith("running:session_state") || entry.includes("session_state"),
1821+
);
1822+
assert.deepEqual(sessionStates, [
1823+
"running:session_state:running",
1824+
"waiting:session_state:requires_action",
1825+
"ready:session_state:idle",
1826+
]);
17721827
const heartbeat = runtimeEvents.find(
17731828
(event) =>
17741829
event.type === "session.state.changed" &&

0 commit comments

Comments
 (0)