mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 07:00:26 +08:00
* fix(session): delete a message's own turn and refuse active-turn deletion Resolve the owning turn via `turns.assistant_message_id` for assistant rows and the user row's `metadata.turn_id`, falling back to the last turn created at or before the user row for legacy data. The previous `created_at >=` match selected the *next* turn, because a turn row is always written before its user row (`begin_turn` -> `add_message`); deleting a completed turn's message could therefore destroy a later `waiting_input` turn's record while its task still held the session lease. Refuse the delete whenever the resolved turn is in `ACTIVE_TURN_STATUSES` (queued/running/waiting_input) instead of only "running"; the API answers 409 with "running or waiting for input". * fix(chat): resubscribe a parked turn on load so its ask_user card survives a reload A `waiting_input` turn keeps the session lease while it waits, and its ask_user card exists only in the live event stream: no assistant row is persisted until the turn settles. Loading a session only resubscribed "running" turns, and through `sendThroughRunner`, whose retry gate drops a non-streaming session -- so after a reload the card was unreachable while the turn kept waiting, and the conversation could neither be answered nor used. Parked turns now subscribe through the client's durable command queue (sent once the socket opens), once per turn per tab. The replayed stream rebuilds the card so it can be answered. * test(chat): align the loader-gate assertion with the parked-turn resubscribe The source-shape assertion pinned the previous loader line (`if (loadedStatus === "running" && (activeTurn?.turn_id || activeTurn?.id))`). The parked-turn resubscribe extracts `activeTurnId` first and adds a `waiting_input` branch, so update the assertion to the new gate and cover the parked branch's status check as well.