Skip to content

Mobile SFC buffer: auto-open and pre-fill destination#43

Open
jackinabox86 wants to merge 11 commits into
mainfrom
claude/fervent-newton-MxWme
Open

Mobile SFC buffer: auto-open and pre-fill destination#43
jackinabox86 wants to merge 11 commits into
mainfrom
claude/fervent-newton-MxWme

Conversation

@jackinabox86

Copy link
Copy Markdown
Owner

Summary

Refactors the OPEN_SFC action step to fully automate buffer opening and destination pre-filling on mobile, eliminating the manual user prompt. The navigator no longer hides #container during buffer navigation, preventing APEX layout listener triggers that would cause unwanted stack navigation.

Key Changes

  • OPEN_SFC automation: Replaced manual waitAct prompt with automatic requestTile buffer open, char-by-char destination typing to populate the AddressSelector dropdown, and a final waitAct only for the user to tap the suggestion and complete the flight.

  • Navigator: remove #container hiding: Deleted saveContainerStyles, applyRefreshHide, and restoreContainerStyles calls. #container now stays at its natural position throughout buffer navigation. APXM's overlay already covers APEX, so hiding is redundant and harmful—it triggers APEX's ResizeObserver and CSS transition listeners which interpret the slide-out as a navigation event.

  • Destination pre-fill strategy:

    • Clears any existing input value via native setter
    • Simulates keyboard events (keydown, keypress, input, keyup) char-by-char to trigger APEX's server-side suggestion fetch
    • Waits for the suggestion dropdown to populate (informational only—user taps it themselves)
    • Does NOT click the suggestion programmatically (causes APEX to navigate away from SFC buffer on mobile)
  • showMobileBufferContents() shim: Converted to a no-op function kept for call-site compatibility. Previously made #container visible after off-screen navigation; now unnecessary since the navigator never hides the container.

  • App.tsx cleanup: Removed the useEffect that managed #container display/margin/height when toggling APEX visibility. FloatingReturn is position:fixed in the shadow DOM and overlays correctly without layout changes to the underlying APEX container.

  • Test updates: Updated mobile-buffer-navigator tests to verify #container is NOT hidden and styles are not modified during buffer open/close.

Implementation Details

  • Destination pre-fill uses waitForElement with a 2-second timeout to detect the suggestion dropdown, searching both the autosuggest portal and document.body for matching suggestions.
  • Char-by-char typing includes 30ms delays between keystrokes to allow APEX's async suggestion fetch to complete.
  • Logging and status messages guide the user through the flow: pre-fill status, dropdown readiness, and final instructions for Show APEX interaction.
  • Error handling is graceful—if pre-fill fails, the user is prompted to set the destination manually in Show APEX.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ

claude added 11 commits May 24, 2026 01:38
Previously OPEN_SFC paused and asked the user to open the SFC buffer
manually. Now it:
- Opens the SFC buffer automatically in the background via a new
  openTileSilent context function (no user ACT required to open)
- Pre-fills the destination planet using the AddressSelector with
  autosuggest click, matching the refined-prun desktop flow
- Restores #container visibility via showMobileBufferContents() so
  the buffer is visible in APEX once the user switches views
- Logs a clear instruction and waits for ACT after the automation

BurnActView and RepairActView gain a Show APEX button alongside ACT
when the runner is waiting, so the user can switch to APEX view to
see the pre-filled SFC buffer, take flight, return via FloatingReturn,
and tap ACT to resume.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
The previous attempt added openTileSilent/openBufferSilent to bypass the
waitAct gate in requestBuffer. This failed because openMobileBuffer can't
reliably navigate out of the hidden MTRA buffer without the DOM-settle time
that waitAct provides.

OPEN_SFC now uses requestTile (the same proven path as MTRA_TRANSFER):
user taps ACT once, then the runner opens the SFC buffer automatically.
After the buffer is open, the destination planet is filled automatically
using character-by-character keyboard simulation (matching the pattern
in selectMaterial/cont-utils.ts) and the first autosuggest entry is
clicked. showMobileBufferContents() leaves the buffer visible in APEX.
The final waitAct prompt directs the user to tap Show APEX (already in
the header), take flight, and return to APXM to tap ACT.

Also removes the redundant Show APEX button that was added to the
BurnActView and RepairActView action runner controls — it already exists
in the APXM header on every page.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
…back-navigation

Previous attempt made #container visible before typing (to satisfy WebKit's
focus/keyboard restriction). This allowed keyboard events dispatched to the
AddressSelector input to bubble up into APEX's navigation handlers, causing
the SFC buffer to navigate back to the card list.

Fix: use setInputValue (native-setter + 'input' event) while the buffer
stays hidden. The console confirmed that APEX's autocomplete fires on the
'input-changed' handler triggered by the 'input' event, so the autocomplete
still runs. Programmatic .click() on the suggestion element works even when
the container is hidden — WebKit only blocks focus and keyboard events on
hidden/off-screen elements, not mouse click dispatches.

Also removes the now-unused focusElement import.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
…arch

setInputValue triggers the autocomplete fetch but not the DOM render of the
dropdown — the keydown/keyup keyboard simulation is required for APEX to
actually show suggestion entries (confirmed: char-by-char → height error
indicates dropdown rendered; setInputValue → no height error, no render).

Suggestion matching now uses text-content search (querySelectorAll li /
[role=option] with textContent.includes) instead of C.AddressSelector.
suggestionContent, whose CSS class name is unknown and returns nothing.
This mirrors how selectMaterial in cont-utils.ts matches entries by the
text of C.ColoredIcon.label, but without depending on a specific class.

Buffer is made visible before typing (same pattern as selectMaterial) to
satisfy WebKit's requirement for focus and keyboard events. Restored to
off-screen after suggestion click, then revealed via showMobileBufferContents.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
…lose

An exception thrown during char-by-char typing or suggestion clicking
was propagating to the step-machine's outer try-catch, which called
stop() → closeMobileBuffer(), closing the SFC buffer before the user
tapped ACT. The destination fill is now best-effort: any exception logs
a warning and the runner proceeds to showMobileBufferContents() and
waitAct() so the buffer stays open for the user to tap Show APEX.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
Two 'star graph initialized' entries suggest APEX navigates to a
destination-picker view when the AddressSelector input is focused.
After focus, we re-query all visible AddressSelector inputs from
document.body so we type into the live picker input, not the stale
SFC-form reference.

Diagnostic console.log calls added at every key milestone so the
exact failure point can be identified from browser console output.
Pre-existing li/option elements are tracked so star-graph nodes are
deprioritized in the suggestion search.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
…n nav

After clicking the address suggestion, restoring #container to
left:-9999px triggered APEX's CSS transition listener which interpreted
the slide-out as a navigation event and rendered the buffer list before
showMobileBufferContents() could restore it. Removing the redundant
restore fixes this — showMobileBufferContents() directly sets the
final visible state.

Also uses C.AddressSelector.suggestion (now confirmed from debug log)
for precise suggestion matching instead of generic li/[role=option].

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
The -9999px/visibility:hidden hiding in openMobileBuffer was redundant
(APXM overlays APEX during all ACT runner steps) and harmful: APEX
watches for CSS transition events on #container and interprets the
slide-out as a navigation, rendering the buffer list instead of the
open buffer.

- openMobileBuffer: drop applyRefreshHide (step 3) and savedStyles
- closeMobileBuffer: drop restoreContainerStyles (nothing to restore)
- showMobileBufferContents: kept as a documented no-op for clarity
- OPEN_SFC: remove visibility manipulation; type destination but do
  not click the suggestion (programmatic clicks navigate away on
  mobile APEX); user taps the suggestion themselves via Show APEX
- Tests updated to match the new no-hide contract

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
Setting marginTop/height on #container when Show APEX was tapped
triggered APEX's layout listeners (ResizeObserver etc.) which
navigated the buffer stack to the buffer list — the root cause of
every 'buffer closed after Show APEX' report.

FloatingReturn is already position:fixed in the shadow DOM so it
overlays APEX correctly with no layout changes to #container needed.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
findBufferForm now matches FormComponent__containerActive only —
buffer-list cards render as Passive and were causing a false positive
that made openMobileBuffer return before the SFC buffer form loaded.

Diagnostic logs added to show whether we reach the SFC buffer form
level and whether the form is still active when waitAct is called.

https://claude.ai/code/session_01TpdDr72qyvk6rC5124r6YJ
…back

When the user taps "Show APEX", the shadow-DOM button receives focus,
causing APEX's AddressSelector input (still focused from our typing) to
fire a blur event. On mobile APEX, this blur closes the suggestion
dropdown and triggers navigation back to the buffer card list.

Fix: explicitly blur the input after typing is complete (and the
suggestion is detected), then sleep 200ms to let APEX settle before
calling waitAct. By the time the user taps Show APEX, no element in
APEX has focus, so no blur-triggered navigation occurs.

Also remove height:0 from :host(.apex-visible) — collapsing the fixed
shadow host height was firing a resize event that APEX used to navigate
to the buffer list (belt-and-suspenders fix alongside the blur fix).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants