feat: make mode creation preview-only and cache-safe

This commit is contained in:
Miayui
2026-09-20 19:32:03 +08:00
parent bfff1b515c
commit 89707a42e2
28 changed files with 1375 additions and 165 deletions
@@ -21,17 +21,17 @@ def test_console_contains_ai_assistant_surface():
assert 'placeholder="向 AI助手提问或交代工作"' in template
assert 'aria-label="发送消息"' in template
assert 'import "../assistant-chat.css";' in vite_entry
assert 'src="/assistant-chat.js?v=codex-assistant-34"' in html
assert 'src="/assistant-chat.js?v=codex-assistant-35"' in html
def test_codex_assistant_assets_are_versioned_together_in_the_service_worker():
service_worker = (ROOT / "apps/web-console/service-worker.js").read_text(encoding="utf-8")
assert (
'const CACHE_VERSION = "cognitive-agent-pad-v328-nfc-mqtt"'
'const CACHE_VERSION = "cognitive-agent-pad-v329-mode-preview"'
in service_worker
)
assert '"/assistant-chat.css?v=codex-assistant-29"' in service_worker
assert '"/assistant-chat.js?v=codex-assistant-34"' in service_worker
assert '"/assistant-chat.css?v=codex-assistant-30"' in service_worker
assert '"/assistant-chat.js?v=codex-assistant-35"' in service_worker
def test_codex_frontend_uses_one_streaming_endpoint_and_agent_work_events():
@@ -91,7 +91,7 @@ def test_validated_controls_are_mirrored_into_a_compact_assistant_card():
assert "window.CognitiveAgentConsoleV2?.getParsedCanCommands?.(result)" in script
assert "fallbackAssistantControlCommands(result)" in script
assert 'card.className = "assistant-dispatched-controls"' in script
assert 'heading.textContent = "下发控制指令"' in script
assert 'const headingText = previewOnly ? "控制指令预览(未下发)" : "下发控制指令"' in script
assert 'count.className = "assistant-dispatched-controls-count"' in script
assert 'list.className = "assistant-dispatched-controls-list"' in script
assert "value.textContent = assistantControlValue(item)" in script
@@ -186,6 +186,7 @@ def test_codex_request_keeps_trusted_vehicle_context_without_legacy_model_routin
assert "history" not in request_body
assert "provider" not in request_body
assert "reasoning_effort" not in request_body
assert 'const executionMode = modeConfigurationPreview ? "dry_run"' in request_body
def test_starting_a_new_codex_conversation_rotates_the_conversation_id():
@@ -239,7 +240,9 @@ def test_assistant_mode_creation_previews_then_saves_to_the_compact_mode_strip()
assert 'event.payload.orchestration_route === "mode_profile_create_preview"' in assistant
assert "appendModeDraftState(" in assistant
assert "保存为功能模式" in assistant
assert "先试运行" in assistant
assert "重新校验(不下发)" in assistant
assert "创建阶段仅生成并校验控制方案,不会向 CAN 或红外外设发送指令" in assistant
assert 'label = String(action?.target?.name || action?.target?.device || "红外外设")' in assistant
save_flow = assistant.split(
"async function saveModeProfileDraft", 1