fix(send_message): pick active composer when ghost frames exist#169
Open
longXboy wants to merge 1 commit into
Open
fix(send_message): pick active composer when ghost frames exist#169longXboy wants to merge 1 commit into
longXboy wants to merge 1 commit into
Conversation
WeChat's accessibility tree can contain multiple edit+send pairs: the live main-window composer plus stale "ghost" frames left behind by chats previously detached into separate windows. The old depth-first "take the first pair" logic grabbed the wrong (ghost) composer, whose input never received text and whose Send button stayed DISABLED forever, causing the plan to loop and ultimately fail with "No action selected". Collect every candidate edit+send pair and rank them so the genuinely active composer wins: 1. editable currently FOCUSED (strongest signal) 2. Send button NOT disabled (composer already has text) 3. pair under the main "Weixin" frame (not a ghost/detached frame) DFS order breaks any remaining ties. This makes 'wx messages send' reliable even when stale frames are present, removing the need to restart the container to clear ghost windows.
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.
Problem
wx messages sendintermittently fails withNo action selected, most reliably reproduced when sending to a chat after another chat had been detached into a separate window.WeChat's accessibility tree can contain multiple
edit+Send(S)button pairs:The previous
find_edit_send_pairdid a depth-first walk and returned the first pair it found. When a ghost frame appeared earlier in the tree, it grabbed that ghost composer — whose input never receives the typed text and whoseSend(S)button staysDISABLEDforever. The plan then loops and eventually bails out withNo action selected.The practical workaround until now was to restart the container (
wx down && wx up) to clear the stale windows, which also drops automation state.Fix
Instead of "take the first pair", collect every candidate
edit+sendpair and rank them so the genuinely active composer wins:DFS order breaks any remaining ties. Frame-context is tracked during recursion: once we descend into the
framenamedWeixin, everything below it is flaggedin_main_frame, so ghost frames outside it are naturally deprioritized.Result
wx messages sendnow selects the correct composer even when stale ghost frames are present in the a11y tree — verified by sending to a private chat that previously failed withNo action selected. This removes the need to restart the container to clear ghost windows.Changes
packages/agent-server-rust/src/plans/send_message.rsfind_edit_near_send/ first-matchfind_edit_send_pair) withcollect_edit_send_pairs+ scored selection infind_edit_and_send_button.node_has_statehelper andComposerPairstruct (tracksin_main_frame).Testing
cargo buildpasses (no new warnings/errors).Message sent successfully!, message confirmed delivered.