Mercurial
view infinite_canvas/dictation_policy_test.sh @ 281:c57149ad216e default tip
Copilot-Session: f68442b1-fa8f-46a0-9689-81710613bbd4
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 18 Aug 2026 22:18:15 -0700 |
| parents | 49e9e591c9bb |
| children |
line wrap: on
line source
#!/usr/bin/env bash set -euo pipefail native_source="$1" main_source="$2" dev_ui_source="$3" require_pattern() { local pattern="$1" local file="$2" local message="$3" if ! grep -Eq "$pattern" "$file"; then echo "$message" >&2 exit 1 fi } require_pattern \ 'CefRequestContext::CreateContext' \ "$native_source" \ "Dictation must use an isolated CEF request context." require_pattern \ 'view_->is_dictation_transport' \ "$native_source" \ "Microphone permission must be scoped to the hidden dictation transport." require_pattern \ 'http://127\.0\.0\.1:8090' \ "$native_source" \ "Microphone permission must be scoped to the loopback dictation origin." require_pattern \ 'OnShowPermissionPrompt' \ "$native_source" \ "The hidden Chrome-style permission prompt must be handled natively." require_pattern \ 'CEF_PERMISSION_TYPE_MIC_STREAM' \ "$native_source" \ "The native prompt handler must identify microphone requests." require_pattern \ 'CEF_PERMISSION_RESULT_ACCEPT' \ "$native_source" \ "The native prompt handler must accept loopback microphone access." require_pattern \ 'requests_other_media' \ "$native_source" \ "The native permission handler must reject non-audio media requests." require_pattern \ 'callback->Continue\(audio\)' \ "$native_source" \ "The native permission handler must grant loopback audio directly." if grep -Eq 'AppendSwitch\("(enable-media-stream|use-fake-ui-for-media-stream)"' \ "$native_source"; then echo "Global media auto-grant switches are forbidden." >&2 exit 1 fi require_pattern \ 'Canvas_App_Ensure_Dictation_Entity' \ "$main_source" \ "Dictation must create a retained canvas entity." require_pattern \ 'CANVAS_ENTITY_TEXT_AREA' \ "$main_source" \ "Dictation must use the wrapping text-area entity." require_pattern \ 'Canvas_Text_Area_Set_Content' \ "$main_source" \ "Live transcripts must update the retained text area." require_pattern \ '"Dictation"' \ "$main_source" \ "The live transcript entity must expose a draggable Dictation header." submit_source="$( sed -n \ '/static boolean Canvas_App_Submit_Dictation(void)/,/^}/p' \ "$main_source" )" if grep -Eq 'dictation_entity_id = 0' <<<"$submit_source" || ! grep -Eq 'Canvas_App_Sync_Dictation_Entity' <<<"$submit_source"; then echo "Submission must clear and reuse the one Dictation scratchpad." >&2 exit 1 fi if grep -Eq 'Set_Dictation_Active' <<<"$submit_source"; then echo "Sending a thought must keep live microphone capture active." >&2 exit 1 fi if grep -Eq 'Canvas_App_Draw_Dictation_Overlay' "$main_source"; then echo "Dictation must not also render a screen-space popup." >&2 exit 1 fi indicator_source="$( sed -n \ '/static void Canvas_App_Draw_Listening_Indicator(void)/,/^}/p' \ "$main_source" )" for pattern in \ 'if \(!g_app->dictation_listening\) return' \ 'GetScreenHeight\(\) - 28\.0f' \ 'g_app->theme\.danger' \ 'g_app->theme\.text_muted' \ '"Listening"'; do if ! grep -Eq "$pattern" <<<"$indicator_source"; then echo "Dictation must show a theme-aware bottom-left listening indicator." >&2 exit 1 fi done input_source="$( sed -n \ '/static void Canvas_App_Update_Dictation_Overlay_Input(void)/,/^}/p' \ "$main_source" )" if ! grep -Eq 'IsKeyPressed\(KEY_ENTER\)' <<<"$input_source"; then echo "Dictation overlay must submit from Enter." >&2 exit 1 fi if ! grep -Eq 'Canvas_Web_Surface_Commit_Dictation' <<<"$input_source"; then echo "Enter must commit the utterance without stopping the microphone." >&2 exit 1 fi if ! grep -Eq 'dictation_listening.*IsKeyPressed\(KEY_BACKSPACE\)' \ <<<"$input_source"; then echo "Backspace must clear active dictation without stopping capture." >&2 exit 1 fi entity_source="$( sed -n \ '/static void Canvas_App_Sync_Dictation_Entity(void)/,/^}/p' \ "$main_source" )" if ! grep -Eq "dictation_partial\\[0\\]" <<<"$entity_source" || ! grep -Eq 'TRUE : FALSE' <<<"$entity_source"; then echo "In-progress dictation text must use the muted theme color." >&2 exit 1 fi require_pattern \ 'EnsureDictationView\(p_surface\);' \ "$native_source" \ "Native dictation transport must be prewarmed before the M hotkey." require_pattern \ 'Canvas_Web_Surface_Set_Dictation_Active' \ "$main_source" \ "Dictation must use deterministic start and stop commands." active_source="$( sed -n \ '/static void Canvas_App_Set_Dictation_Active(boolean active)/,/^}/p' \ "$main_source" )" if grep -Eq "dictation_(partial|transcript)\\[0\\] = '\\\\0'" \ <<<"$active_source"; then echo "Resuming dictation must preserve the existing scratchpad text." >&2 exit 1 fi require_pattern \ 'p_ui->collapsed' \ "$dev_ui_source" \ "Developer controls must expose a persistent collapsed state." require_pattern \ 'DEV_PANEL_COLLAPSED' \ "$dev_ui_source" \ "Collapsed developer controls must retain a visible restore button." final_source="$( sed -n \ '/CANVAS_DICTATION_EVENT_FINAL/,/if (!g_app->dictation_overlay_visible/p' \ "$main_source" )" if ! grep -Eq 'dictation_send_pending' <<<"$final_source"; then echo "Final dictation must wait for explicit Enter submission." >&2 exit 1 fi