Files
DeepTutor/web/tests/ask-user-state.test.ts
Bingxi Zhao (Frank) 6153d8c092 release: v1.4.0 — release notes, version bump, repo hygiene
- Add assets/releases/ver1-4-0.md covering deltas since v1.4.0-beta
  (reasoning_effort normalization, tool-schema fallback, restart-safe
  turn runtime, frontend placeholder hardening, CLI chat REPL config).
- Bump deeptutor/__version__ to 1.4.0.
- Update README Releases section: v1.4.0 at top, install opt-in note
  updated for stable.
- Fix pre-existing pre-commit failures so the v1.4.0 cut runs clean:
  bandit B324 (mark _sha1 as non-security), mypy no-redef in
  document.py / line_doc.py, mypy arg-type/assignment in
  snapshot/adapters.py, mypy assignment + arg-type in
  services/memory/settings.py, mypy func-returns-value on
  set.add idiom in deeptutor_cli/init_wizard.py.
- Apply ruff format / prettier sweep across the repo.
- Remove stale workspace + i18n env example + playwright captures
  already cleaned locally; ignore .playwright-cli/ going forward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 21:09:22 +08:00

79 lines
1.8 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
hasPendingAskUser,
hasPendingAskUserInMessages,
} from "../lib/ask-user-state";
import type { StreamEvent } from "../lib/unified-ws";
function event(
type: StreamEvent["type"],
metadata: Record<string, unknown>,
turnId = "turn-1",
): StreamEvent {
return {
type,
source: "test",
stage: "rephrasing",
content: "",
metadata,
session_id: "session-1",
turn_id: turnId,
seq: 1,
timestamp: 0,
};
}
test("hasPendingAskUser detects unresolved ask_user tool results", () => {
const events = [
event("tool_result", {
tool_call_id: "call-1",
tool_metadata: {
ask_user: {
questions: [{ id: "scope", prompt: "What scope?" }],
},
},
}),
];
assert.equal(hasPendingAskUser(events, "turn-1"), true);
});
test("hasPendingAskUser clears the matching card after ask_user_resolved", () => {
const events = [
event("tool_result", {
tool_call_id: "call-1",
tool_metadata: {
ask_user: { questions: [{ id: "scope", prompt: "Scope?" }] },
},
}),
event("progress", {
ask_user_resolved: true,
ask_user_tool_call_id: "call-1",
}),
];
assert.equal(hasPendingAskUser(events, "turn-1"), false);
});
test("hasPendingAskUserInMessages ignores ask_user cards from other turns", () => {
const messages = [
{
events: [
event(
"tool_result",
{
tool_call_id: "call-old",
tool_metadata: {
ask_user: { questions: [{ id: "q", prompt: "Old?" }] },
},
},
"turn-old",
),
],
},
];
assert.equal(hasPendingAskUserInMessages(messages, "turn-1"), false);
});