fix(web): unify mode previews and label window positions

This commit is contained in:
Miayui
2026-09-22 14:17:50 +08:00
parent 2b365b3922
commit f4ab5f4867
12 changed files with 176 additions and 51 deletions
+5 -5
View File
@@ -1071,7 +1071,7 @@ operations:
) as response:
extension_styles = response.read().decode("utf-8").replace("\r\n", "\n")
with self.opener.open(
f"{self.base_url}/assistant-chat.js?v=codex-assistant-40-seat-rows", timeout=3
f"{self.base_url}/assistant-chat.js?v=codex-assistant-41-unified-preview", timeout=3
) as response:
assistant_script = response.read().decode("utf-8")
with self.opener.open(
@@ -1156,7 +1156,7 @@ operations:
self.assertIn('id="assistantTranscript"', template)
self.assertIn('import "../assistant-chat.css";', vite_entry)
self.assertIn(
f'src="{runtime_url("assistant-chat.js", "/assistant-chat.js?v=codex-assistant-40-seat-rows")}"',
f'src="{runtime_url("assistant-chat.js", "/assistant-chat.js?v=codex-assistant-41-unified-preview")}"',
html,
)
self.assertIn('import "../energy-monitor.css";', vite_entry)
@@ -1472,13 +1472,13 @@ operations:
self.assertIn(f'/{runtime_assets[asset_name]}', service_worker)
else:
self.assertIn(
'const CACHE_VERSION = "cognitive-agent-pad-v337-seat-rows"',
'const CACHE_VERSION = "cognitive-agent-pad-v338-unified-preview"',
service_worker,
)
self.assertIn('/console-v2.css?v=delivery-state-69', service_worker)
self.assertIn('/console-v2.js?v=local-first-79-cinema-status', service_worker)
self.assertIn('/assistant-chat.css?v=codex-assistant-30', service_worker)
self.assertIn('/assistant-chat.js?v=codex-assistant-40-seat-rows', service_worker)
self.assertIn('/assistant-chat.css?v=codex-assistant-31-unified-preview', service_worker)
self.assertIn('/assistant-chat.js?v=codex-assistant-41-unified-preview', service_worker)
self.assertIn('/energy-monitor.css?v=energy-monitor-5-dialog-size', service_worker)
self.assertIn('/energy-monitor.js?v=energy-monitor-5-performance', service_worker)
self.assertIn('"/app.js?v=dual-seat-148-seat-preset"', service_worker)
@@ -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-40-seat-rows"' in html
assert 'src="/assistant-chat.js?v=codex-assistant-41-unified-preview"' 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-v337-seat-rows"'
'const CACHE_VERSION = "cognitive-agent-pad-v338-unified-preview"'
in service_worker
)
assert '"/assistant-chat.css?v=codex-assistant-30"' in service_worker
assert '"/assistant-chat.js?v=codex-assistant-40-seat-rows"' in service_worker
assert '"/assistant-chat.css?v=codex-assistant-31-unified-preview"' in service_worker
assert '"/assistant-chat.js?v=codex-assistant-41-unified-preview"' in service_worker
def test_codex_frontend_uses_one_streaming_endpoint_and_agent_work_events():
@@ -91,7 +91,8 @@ 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 'const headingText = previewOnly ? "控制指令预览(未下发)" : "下发控制指令"' in script
assert 'const headingText = mergedResult.mode_profile_draft?.name' in script
assert '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
+53 -1
View File
@@ -204,7 +204,7 @@ def test_default_bundle_rows_show_each_passenger_action_separately(render_rows):
assert [(row["label"], row["value"]) for row in rows] == [
("空调电源", "开启"),
("主驾车窗", "完全关闭(目标开度 0%)"),
("左前车窗(主驾)", "完全关闭(目标开度 0%)"),
("副驾座椅通风", "开启 · 1档"),
("副驾靠背位置", "45%"),
("副驾腿托位置", "35%"),
@@ -227,3 +227,55 @@ def test_cinema_draft_shows_all_four_axes_and_ventilation(render_rows):
("副驾腿托位置", "53%"),
("副驾座椅通风", "关闭"),
]
def test_collapsible_preview_keeps_all_actions_and_identifies_each_window():
node = shutil.which("node")
assert node
source = (ROOT / "apps/web-console/assistant-chat.js").read_text(encoding="utf-8")
start = source.index(" const assistantControlLabels =")
end = source.index(" function focusLatestDispatchedControls", start)
actions = [
action("seat.set_longitudinal_position", {"position_pct": 51}, "passenger"),
action("seat.set_cushion_tilt", {"position_pct": 30}, "passenger"),
action("seat.set_backrest_recline", {"position_pct": 44}, "passenger"),
action("seat.set_legrest_height", {"position_pct": 53}, "passenger"),
action("seat.set_ventilation", {"state": "off"}, "passenger"),
*(action("window.set_position", {"position_pct": value}, zone)
for zone, value in [("front_left", 0), ("front_right", 50),
("rear_left", 100), ("rear_right", 0)]),
action("climate.set_power", {"state": "on"}, "vehicle"),
action("ambient_light.set_power", {"state": "on"}, "vehicle"),
]
payload = {
"execution_mode": "dry_run", "mode_profile_draft": {"name": "浪漫影院模式"},
"actions": actions,
# IDs can collide across domains, and seat display projections may be absent.
"validated_control_commands": [{
"operation": {**operation, "id": "shared-operation-id"},
"actual_command": f"command-{index}",
} for index, operation in enumerate(actions[5:])],
}
script = "const window = {};\n" + source[start:end] + "\n" + r'''
const payload = JSON.parse(require('node:fs').readFileSync(0, 'utf8'));
const show = (value) => assistantDispatchedCommands(value).map(item => ({
label: item.category, value: assistantControlValue(item), command: item.command,
}));
const preview = show(payload);
delete payload.validated_control_commands;
console.log(JSON.stringify({preview, withoutProjections: show(payload)}));
'''
output = subprocess.run([node, "-e", script], input=json.dumps(payload),
check=True, capture_output=True, text=True, encoding="utf-8")
results = json.loads(output.stdout)
for rows in (results["preview"], results["withoutProjections"]):
assert len(rows) == len(actions)
assert [row["value"] for row in rows[:5]] == ["51%", "30%", "44%", "53%", "关闭"]
assert [(row["label"], row["value"]) for row in rows[5:9]] == [
("左前车窗(主驾)", "0%(完全关闭)"), ("右前车窗(副驾)", "50%"),
("左后车窗", "100%(完全打开)"), ("右后车窗", "0%(完全关闭)"),
]
assert [row["label"] for row in rows[-2:]] == ["空调电源", "氛围灯"]
assert [row["command"] for row in results["preview"][5:]] == [
f"command-{index}" for index in range(6)
]
@@ -37,11 +37,11 @@ def test_energy_monitor_assets_are_versioned_and_cached() -> None:
assert f'"{asset}"' in service_worker
assert 'import "../energy-monitor.css";' in vite_entry
assert "/energy-monitor.js?v=energy-monitor-5-performance" in html
assert html.index("/assistant-chat.js?v=codex-assistant-40-seat-rows") < html.index(
assert html.index("/assistant-chat.js?v=codex-assistant-41-unified-preview") < html.index(
"/energy-monitor.js?v=energy-monitor-5-performance"
)
assert (
'const CACHE_VERSION = "cognitive-agent-pad-v337-seat-rows"'
'const CACHE_VERSION = "cognitive-agent-pad-v338-unified-preview"'
in service_worker
)
@@ -99,5 +99,5 @@ def test_performance_assets_have_a_new_cache_generation() -> None:
):
assert asset in html
assert f'"{asset}"' in worker
assert 'const CACHE_VERSION = "cognitive-agent-pad-v337-seat-rows"' in worker
assert 'const CACHE_VERSION = "cognitive-agent-pad-v338-unified-preview"' in worker
assert '"/codepen-glass-theme.css?v=creative-cloud-6-performance"' in worker
+1 -1
View File
@@ -54,7 +54,7 @@ def test_theme_asset_versions_are_consistent_with_the_pwa_shell() -> None:
assert source_asset in main
assert f'"{cached_asset}"' in service_worker
assert 'import "./styles/design-system.css"' in main
assert 'const CACHE_VERSION = "cognitive-agent-pad-v337-seat-rows"' in service_worker
assert 'const CACHE_VERSION = "cognitive-agent-pad-v338-unified-preview"' in service_worker
def test_reference_glass_theme_covers_the_complete_workspace() -> None:
+1 -1
View File
@@ -31,7 +31,7 @@ def test_vue_vite_application_is_the_primary_frontend_entry() -> None:
assert package["scripts"]["build"] == "vite build"
assert 'import vue from "@vitejs/plugin-vue"' in vite
assert 'outDir: outputRoot' in vite
assert 'const CACHE_VERSION = "cognitive-agent-pad-v337-seat-rows"' in service_worker
assert 'const CACHE_VERSION = "cognitive-agent-pad-v338-unified-preview"' in service_worker
assert 'createHash("sha256")' in vite
assert 'runtime-assets.json' in vite
assert 'rewriteRuntimeReferences' in vite