From 86f0b4bd20cdec86dfb5bdb7978d1f6ff4af111a Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Fri, 14 Aug 2026 22:41:54 +0800
Subject: [PATCH] [verified] feat: export performance diagnostics
---
C3.tools/round1-vertical-keyboard-app-focus-fixture-qa.sh | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 173 insertions(+), 1 deletions(-)
diff --git a/C3.tools/round1-vertical-keyboard-app-focus-fixture-qa.sh b/C3.tools/round1-vertical-keyboard-app-focus-fixture-qa.sh
index c25cc9a..8e8ecbd 100755
--- a/C3.tools/round1-vertical-keyboard-app-focus-fixture-qa.sh
+++ b/C3.tools/round1-vertical-keyboard-app-focus-fixture-qa.sh
@@ -14,7 +14,7 @@
REPORT_DIR="$BUILD_REPORT_ROOT"
FIXTURE_APP_COUNT="${ALIGNER_ROUND1_VERTICAL_KEYBOARD_APP_COUNT:-12}"
FIXTURE_WINDOWS_PER_APP="${ALIGNER_ROUND1_VERTICAL_KEYBOARD_WINDOWS_PER_APP:-8}"
-REPORT_WAIT="${ALIGNER_ROUND1_VERTICAL_KEYBOARD_REPORT_WAIT:-6.0}"
+REPORT_WAIT="${ALIGNER_ROUND1_VERTICAL_KEYBOARD_REPORT_WAIT:-12.0}"
APP_PID=""
fail() {
@@ -118,6 +118,45 @@
PY
}
+wait_for_committed_report() {
+ local report="$1"
+ local expected_sequence="$2"
+
+ /usr/bin/python3 - "$report" "$REPORT_WAIT" "$expected_sequence" <<'PY'
+import json
+import sys
+import time
+
+path = sys.argv[1]
+timeout = float(sys.argv[2])
+expected_sequence = [part for part in sys.argv[3].split(",") if part]
+deadline = time.monotonic() + timeout
+last_report = None
+
+while time.monotonic() < deadline:
+ try:
+ with open(path, "r", encoding="utf-8") as file:
+ report = json.load(file)
+ last_report = report
+ root = report.get("rootView", {})
+ if (
+ report.get("snapshotLoaded") is True
+ and root.get("keyboardCommandsApplied") == expected_sequence
+ ):
+ sys.exit(0)
+ except FileNotFoundError:
+ pass
+ except json.JSONDecodeError:
+ pass
+ time.sleep(0.2)
+
+if last_report is not None:
+ print(json.dumps(last_report, indent=2, ensure_ascii=False), file=sys.stderr)
+print(f"vertical keyboard committed report did not reach expected commands within {timeout:.1f}s", file=sys.stderr)
+sys.exit(1)
+PY
+}
+
assert_report() {
local report="$1"
local expected_sequence="$2"
@@ -205,6 +244,11 @@
require("selected" in selected_card.get("visualStates", []), "keyboard-focused selected card must expose selected visual")
require("keyboardFocused" in selected_card.get("visualStates", []), "keyboard-focused selected card must expose keyboardFocused state")
require(selected_card.get("shineVisible") is True, "keyboard-focused selected card must expose shine")
+ require(selected_card.get("titleBarBackgroundColor", {}).get("alpha", 0) > 0.10, "keyboard-focused selected card title bar must expose blue fill")
+ first_selected_column_card = selected_column.get("cards", [])[0]
+ if first_selected_column_card.get("windowID") != selected_card.get("windowID"):
+ require("appLinked" not in first_selected_column_card.get("visualStates", []), "App-linked first card must yield to keyboard-focused window")
+ require(first_selected_column_card.get("titleBarBackgroundColor", {}).get("alpha", 0) <= 0.01, "first card title bar must clear App hover fill while another window has keyboard focus")
header_frame = selected_column.get("headerFrame", {})
clip_frame = selected_column.get("cardsClipFrame", {})
column_frame = selected_column.get("visibleFrame", {})
@@ -230,6 +274,103 @@
"keyboardFocusedWindowID": root.get("keyboardFocusedWindowID"),
"boundaryBounceCount": root.get("boundaryBounceCount"),
"lastBoundaryBounceDirection": root.get("lastBoundaryBounceDirection")
+}, indent=2, ensure_ascii=False))
+PY
+}
+
+assert_window_shortcut_report() {
+ local report="$1"
+ local expected_sequence="$2"
+ local target_app_index="$3"
+ local target_window_index="$4"
+ local expected_code="$5"
+
+ /usr/bin/python3 - \
+ "$report" \
+ "$expected_sequence" \
+ "$target_app_index" \
+ "$target_window_index" \
+ "$expected_code" \
+ "$FIXTURE_APP_COUNT" \
+ "$FIXTURE_WINDOWS_PER_APP" <<'PY'
+import json
+import sys
+
+path = sys.argv[1]
+expected_sequence = [part for part in sys.argv[2].split(",") if part]
+target_app_index = int(sys.argv[3])
+target_window_index = int(sys.argv[4])
+expected_code = sys.argv[5]
+fixture_app_count = int(sys.argv[6])
+fixture_windows_per_app = int(sys.argv[7])
+
+with open(path, "r", encoding="utf-8") as file:
+ report = json.load(file)
+
+def require(condition, message):
+ if not condition:
+ print(message, file=sys.stderr)
+ print(json.dumps(report, indent=2, ensure_ascii=False), file=sys.stderr)
+ sys.exit(1)
+
+root = report.get("rootView", {})
+columns = root.get("waterfallColumns", [])
+require(report.get("snapshotLoaded") is True, "snapshotLoaded must be true")
+require(report.get("appCount") == fixture_app_count, "fixture appCount must match")
+require(root.get("waterfallViewMode") == "verticalColumns", "window shortcut fixture must run in vertical Waterfall")
+require(root.get("keyboardCommandsApplied") == expected_sequence, "two-key window shortcut commands must match")
+require(root.get("appShelfIndexKeyDownCount") == 2, "two-key window shortcut must exercise two physical keyDown events")
+require(root.get("lastAppShelfIndexKeySymbol") == expected_code[-1], "last physical symbol must be the window index key")
+require(root.get("lastWindowIndexKeyCommand") == f"window:{expected_code}", "last window shortcut command must be reported")
+require(root.get("lastWindowIndexKeyCommitCode") == expected_code, "last window shortcut commit code must be reported")
+require(root.get("windowIndexKeyPendingAppGroupIndex") is None, "two-key commit must clear pending App")
+require(root.get("windowIndexKeyPendingAppSymbol") is None, "two-key commit must clear pending App symbol")
+require(target_app_index < len(columns), "target App index must exist")
+target_column = columns[target_app_index]
+cards = target_column.get("cards", [])
+expected_window_count = fixture_app_count * fixture_windows_per_app
+actual_window_count = report.get("windowCount")
+suppressed_window_ids = set(report.get("suppressedActivationWindowIDs", []))
+committed_window_id = root.get("lastCommittedWindowID")
+pre_commit = root.get("lastWindowShortcutPreCommitFilterSnapshot", {})
+window_count_is_valid = (
+ actual_window_count == expected_window_count
+ or (
+ actual_window_count == expected_window_count - 1
+ and committed_window_id in suppressed_window_ids
+ and root.get("lastCommitSource") == "keyboard"
+ )
+)
+require(window_count_is_valid, "fixture windowCount must match or only suppress committed target")
+require(pre_commit.get("phase") == "targetPreCommit", "two-key shortcut must record a pre-commit filter snapshot")
+require(pre_commit.get("targetCode") == expected_code, "pre-commit snapshot must record target shortcut code")
+require(pre_commit.get("targetWindowID") == committed_window_id, "pre-commit target must match committed window ID")
+require(pre_commit.get("matchedWindowIDs") == [committed_window_id], "pre-commit snapshot must match exactly the committed window")
+if target_window_index < len(cards) and cards[target_window_index].get("windowID") == committed_window_id:
+ target_card = cards[target_window_index]
+ require(target_card.get("windowShortcutCode") == expected_code, "target card must expose expected two-character shortcut code")
+ require(target_card.get("primarySpaceLabel") != target_card.get("windowShortcutCode"), "shortcut code must replace the old Space label in the UI meta slot")
+else:
+ current_window_ids = [card.get("windowID") for column in columns for card in column.get("cards", [])]
+ require(committed_window_id in suppressed_window_ids, "committed target may be absent only when suppression records it")
+ require(committed_window_id not in current_window_ids, "suppressed committed target must not remain in current cards")
+require(root.get("lastCommittedAppGroupIndex") == target_app_index, "two-key shortcut must commit target App")
+require(root.get("lastCommittedWindowIndex") == target_window_index, "two-key shortcut must commit target window")
+require(root.get("lastCommitSource") == "keyboard", "two-key shortcut commit must be keyboard sourced")
+if actual_window_count == expected_window_count:
+ require(root.get("selectedAppGroupIndex") == target_app_index, "two-key shortcut must select target App")
+ require(root.get("selectedWindowIndex") == target_window_index, "two-key shortcut must select target window")
+ require(root.get("selectedWindowID") == committed_window_id, "two-key shortcut selection ID must match target window")
+
+for column in columns:
+ for card in column.get("cards", []):
+ code = card.get("windowShortcutCode")
+ require(code != "No Space" and code != "N...", "window shortcut code must not expose the old No Space label")
+
+print(json.dumps({
+ "commands": root.get("keyboardCommandsApplied"),
+ "code": expected_code,
+ "lastCommittedWindowID": root.get("lastCommittedWindowID")
}, indent=2, ensure_ascii=False))
PY
}
@@ -282,6 +423,36 @@
swift "$SCRIPT_DIR/window-logic-qa.swift" --expect-no-quick-switch >&2
}
+run_window_shortcut_case() {
+ local name="window-shortcut"
+ local sequence="physical-index:3,physical-index:6"
+ local expected_sequence="app:3,window:36"
+ local report="$REPORT_DIR/round01-vertical-keyboard-$name-report.json"
+
+ stop_current_aligner
+ rm -f "$report"
+
+ "$APP/Contents/MacOS/Aligner" \
+ --round0-skip-permissions \
+ --round01-open-quick-switch \
+ --round01-waterfall-view-mode=vertical \
+ --round01-fixture-app-count="$FIXTURE_APP_COUNT" \
+ --round01-fixture-windows-per-app="$FIXTURE_WINDOWS_PER_APP" \
+ --round01-disable-screenshot-refresh \
+ --round01-debug-key-sequence="$sequence" \
+ --round01-quick-switch-report="$report" &
+
+ APP_PID=$!
+ wait_for_committed_report "$report" "$expected_sequence"
+ assert_window_shortcut_report "$report" "$expected_sequence" 2 5 "36"
+
+ kill "$APP_PID" 2>/dev/null || true
+ wait "$APP_PID" 2>/dev/null || true
+ APP_PID=""
+ sleep 0.3
+ swift "$SCRIPT_DIR/window-logic-qa.swift" --expect-no-quick-switch >&2
+}
+
if [ "$FIXTURE_APP_COUNT" -lt 12 ]; then
fail "fixture app count must be at least 12"
fi
@@ -305,6 +476,7 @@
run_case "right-wrap-to-first" "$LAST_APP_SYMBOL,right" 0 0 0 0 "none" "false" "false"
run_case "bottom-boundary" "3,down,down,down,down,down,down,down,down,down" 2 2 7 1 "down" "false" "true"
run_case "top-boundary" "4,down,up" 3 3 0 1 "up" "false" "true"
+run_window_shortcut_case
trap - EXIT
cleanup
--
Gitblit v1.9.3