fix(office-ui): stop progress-row flicker and surface native role replies end to end
Two user-visible defects in company mode, root-caused via project 6666/8888 DB forensics: Progress-row flicker (thinking preview appearing/disappearing): progress entries were broadcast to clients before reaching the persistence buffer, so a tool_call-triggered session_detail snapshot rebuilt from the DB erased freshly streamed entries from the live log. Buffer now fills before the broadcast and session_detail flushes it before reading. Native role transcripts incomplete (thinking only at start, no narration, no final summary — external agents unaffected): - thinking deltas shared one stream id per conversation turn while seq reset per iteration, collapsing all iterations into one entry and silently dropping live thinking from iteration 2 on; now keyed per iteration like assistant deltas - assistant_delta events were mapped to None; company mode now surfaces them as streaming 'assistant' progress entries (rendered as Reply cards, merged like thinking, excluded from inline chat rows) - thinking was persisted one row per token, flooding the 1000-entry cap and evicting interleaved tool history; append_progress now folds streaming deltas per (type, turn, stream) with seq dedup - the terminal company turn was hidden at summary detail and, worse, its id-keyed backfill merge kept the first-inserted intermediate content, so the final reply never reached any channel; terminal turns are now flagged company_final_turn, visible at summary detail, and carry their own ui_message_id so they insert as fresh rows - appendProgressEntry applied its seq guard against unrelated entries when the stream key was absent from the log, killing the first delta of any fresh stream; the guard now only applies within the same stream Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -409,9 +409,31 @@ class NativeRuntimeV2Tests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(metadata["execution_mode"], "company_mode")
|
||||
self.assertTrue(metadata["company_runtime_raw_turn"])
|
||||
self.assertEqual(metadata["role_id"], "chao")
|
||||
self.assertEqual(metadata["ui_message_id"], "runtime-v2-company-assistant:ui-turn:company")
|
||||
# No tool calls ⇒ terminal iteration: flagged as the role's final
|
||||
# reply and given its own UI row id so the id-keyed backfill merge
|
||||
# cannot swallow it into the frozen shared-iteration row.
|
||||
self.assertTrue(metadata["company_final_turn"])
|
||||
self.assertEqual(metadata["ui_message_id"], "runtime-v2-company-assistant-final:ui-turn:company")
|
||||
self.assertNotIn("visible_speaker", metadata)
|
||||
|
||||
await runtime._persist_assistant_turn(
|
||||
task,
|
||||
"中间轮叙述",
|
||||
[{"id": "call-1", "function": "file_read", "arguments": {}}],
|
||||
runtime_session_id="rt_company",
|
||||
turn_id="ui-turn:company:iter:1",
|
||||
conversation_turn_id="ui-turn:company",
|
||||
iteration=1,
|
||||
)
|
||||
|
||||
intermediate_metadata = memory.appended_messages[-1]["kwargs"]["metadata"]
|
||||
self.assertEqual(intermediate_metadata["kind"], "runtime_v2_company_assistant")
|
||||
self.assertNotIn("company_final_turn", intermediate_metadata)
|
||||
self.assertEqual(
|
||||
intermediate_metadata["ui_message_id"],
|
||||
"runtime-v2-company-assistant:ui-turn:company",
|
||||
)
|
||||
|
||||
async def test_task_mode_assistant_turn_with_company_defaults_stays_opc_task_reply(self) -> None:
|
||||
memory = _StubMemoryManager(_StubStore())
|
||||
runtime = NativeRuntimeV2(
|
||||
|
||||
Reference in New Issue
Block a user