fix: handle Comet permission prompts and prevent browser resize#13
Closed
OneStepAt4time wants to merge 12 commits into
Closed
fix: handle Comet permission prompts and prevent browser resize#13OneStepAt4time wants to merge 12 commits into
OneStepAt4time wants to merge 12 commits into
Conversation
- Detect Comet action/permission prompts (awaiting_action status) via @container/banner CSS selector in status polling - Add comet_approve_action tool to click primary or cancel buttons on permission prompts - comet_wait now breaks out of polling when awaiting_action is detected, reporting the prompt text and available actions - Fix browser window resize by making Emulation.setDeviceMetricsOverride opt-in (overrideViewport config, default false) - Use dynamic viewport via Page.getLayoutMetrics() for screenshots instead of hardcoded config values - Add connectPromise guard to deduplicate concurrent ensureConnected() calls (race condition fix) - Add askInProgress mutex to prevent concurrent comet_ask corruption - Fix comet_mode read-mode to only navigate if not already on home page - Lower prose-filter question threshold from <100 to <20 chars - Improve buildSubmitPromptScript: focus input before submit, verify input was cleared - Add response truncation marker at 8000 chars with guidance to use comet_get_page_content - Fix .gitignore tools/ pattern to /tools/ (root-level only) - Add .claude/worktrees/ to .gitignore - Add ACTION_BANNER selector to selector types, v145, and main selectors - Add AwaitingAction to AgentState enum
…1.2.0 - tools.md: add comet_approve_action (14th tool), awaiting_action status, actionPrompt/actionButtons fields, action approval common pattern - README.md: update tool count 13→14, add comet_approve_action to session tools and agent workflows - CHANGELOG.md: add [1.2.0] entry with all new features and fixes - configuration.md: add COMET_OVERRIDE_VIEWPORT env var and config option
…vior The comet_ask docs still described the pre-v1.1.1 polling loop behavior (timeout, stall detection, response stabilization). The handler actually returns immediately after submission. Also: - Remove stale timeout parameter from docs - Add concurrency guard documentation - Fix TOC duplicate numbering (15, 15, 16 → 15, 16, 17) - Add missing env vars to Connection Lifecycle config table - Add comet_mode query retry count (5 attempts)
…erns - Update Common Patterns to reflect ask-then-wait two-call pattern - Remove timeout parameter from comet_ask examples - Add awaiting_action to poll completion statuses - Fix comet_wait description (no longer says "after comet_ask times out") - Remove stale timeout comparison in comet_wait notes
- Remove unused AgentState enum (Thinking, Searching, Responding, Error never produced by status detection; 'working' was missing) - Remove dead AgentStatus interface (never imported outside its test) - Promote RawAgentStatus to canonical AgentStatus with AgentStatusValue union type: 'idle' | 'working' | 'completed' | 'awaiting_action' - Remove dead timeout parameter from comet_ask Zod schema (accepted but never read by handler — silently did nothing) - Update types.test.ts with proper AgentStatus, AgentStatusValue, and overrideViewport coverage
- parseAgentStatus: validate all fields with defaults instead of raw cast, prevents TypeError crashes when status.steps/status.response are undefined - comet_switch_tab: return clear error when no tabId or title provided instead of showing "title containing undefined" - comet_ask: add z.string().min(1) to reject empty prompts - comet_wait: guard timeout=0 falling through nullish coalescing - comet_get_page_content: guard maxLength=0 falling through nullish coalescing
- Add "no criteria provided" response to comet_switch_tab docs - Document status parsing hardening, empty prompt rejection, boundary value guards, and type cleanup in CHANGELOG - Document removal of dead AgentState/AgentStatus types and timeout param
…aring Root cause: item.click() silently failed because Comet's typeahead menu items use React onMouseDown handlers, not onClick. The fix invokes onMouseDown directly via React fiber props (__reactProps$) with dispatchEvent(mousedown) as fallback. Also replaces page reload (which didn't clear Lexical editor state) with select-all + delete + backspace clearing before typing / to open the typeahead menu.
Mode read path had two bugs: (1) existing Lexical editor text caused the / character to append instead of triggering the typeahead, and (2) no Escape/Backspace between retries left / characters accumulating. Fixed by adding editor clearing before the loop and Escape+Backspace between retries. Also adds integration tests for comet_approve_action (5 tests), bringing all 14 tools to full coverage (336 tests).
… approach Update AGENTS.md, architecture.md, contributing.md, and integration.md to reflect the 14th tool (comet_approve_action). Also update the architecture mode switching section to document the React onMouseDown approach and Lexical editor clearing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
awaiting_actionstatus) — previously reported ascompletedwhen Comet was waiting for user confirmationcomet_approve_actiontool (14th tool) to click primary or cancel buttons on permission promptsCOMET_OVERRIDE_VIEWPORTenv var, defaultfalse)ensureConnected()deduplication, concurrentcomet_askmutexcomet_moderead-mode navigating away from active conversationsPage.getLayoutMetrics()instead of hardcoded config valuesChanges
Permission prompt handling
src/ui/action.ts(NEW): Script to click action buttons on Comet permission bannerssrc/ui/status.ts: Detect@container/bannerelements, reportawaiting_actionstatus withactionPromptandactionButtonsfieldssrc/server.ts: Newcomet_approve_actiontool;comet_waitbreaks onawaiting_actionstateBrowser resize fix
src/cdp/client.ts:setDeviceMetricsOverrideonly whenoverrideViewport: true; newgetViewportClip()usesPage.getLayoutMetrics()src/config.ts:overrideViewport: falsedefault,COMET_OVERRIDE_VIEWPORTenv varsrc/types.ts:overrideViewportfield onCometConfigRace condition & edge case fixes
connectPromiseguard deduplicates concurrentensureConnected()callsaskInProgressmutex prevents concurrentcomet_askcorruptioncomet_moderead-mode only navigates if not already on home page<100to<20charsbuildSubmitPromptScriptfocuses input before submit, verifies input clearedcomet_get_page_contentTest plan
action.test.tswith 11 tests for action button scriptawaiting_action,actionPrompt,actionButtonsACTION_BANNERawaiting_actionstatuscomet_approve_actionclicks correct button