browser_handle_dialog without action answers "Leave site?" with Leave - unsaved input is lost, unlike browser_navigate's safe Stay

Aperta
#90 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
63/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript

Direzione di ricerca

Start by reading the browser_handle_dialog implementation and its tool description, then compare its default action with browser_navigate’s handling of beforeunload dialogs. Reproduce with the supplied local page and check both beforeunload and confirm behavior. Done when an omitted action no longer accepts a destructive dialog by default, with tests covering the chosen behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: 1.30.3 (Windows 11, Chrome stable). Same code on feat/1.32-partitioner (const action = params.action === 'dismiss' ? 'dismiss' : 'accept').

What happens. browser_navigate (since #69) answers "Leave site?" with Stay and asks the agent to get the user's consent before leave_page: true. browser_handle_dialog has the opposite default: with no action it accepts every dialog type, and for beforeunload accept means Leave. So the one tool an agent is told to use when "a dialog is open" silently throws away the user's unsaved work if the agent leaves out action. An armed handle_dialog without action also overrides navigate's Stay.

Repro (local page).

<input id="inp">
<label><input type="checkbox" id="bu"> arm "Leave site?"</label>
<a id="leave" href="other.html">Leave this page</a>
<script>
addEventListener('beforeunload', e => { if (bu.checked) { e.preventDefault(); e.returnValue = ''; } });
</script>
  1. browser_click('#bu'), browser_fill('#inp', 'UNSAVED DRAFT TEXT').
  2. browser_click('#leave') -> ok:false, "the input opened a dialog ... see browser_handle_dialog" (fine).
  3. browser_handle_dialog() (no action) -> {"ok":true,"dialog_type":"beforeunload","action":"accept","note":"The page was left. ..."} - the draft is gone.

The answer is honest, but the default is destructive, and it is the opposite of what browser_navigate does in the same situation. A confirm() handled the same way is also accepted by default (e.g. "Delete this item?").

Expected / suggestion. For beforeunload (and ideally for confirm), make the default dismiss (Stay / Cancel), or require an explicit action and answer an error without it - matching browser_navigate's leave_page consent model. The tool description could then say "Leave only with action: accept, after the user agreed".

Lingua principale
JavaScript
Stelle
52
Fork
17
Merge medio
4g 2h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Agent360dk/browser-mcp

Tutte le issue di Agent360dk/browser-mcp

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.