Elffuss BraidHub

utopia-ia/elffuss-code public

Stop in the composer keeps focus, is announced, and lets a waiting message go at once

- Focus: «Parando…» set the disabled property on the button that had
  focus, so the browser blurred it and keyboard focus fell to <body> for
  good (Enter, Space and mouse alike). The button now gets aria-disabled
  and stays focusable; activating it while it says «Parando…» does
  nothing, and Enter in the prompt still queues the text as before.
- Announcement: there was no live region, so «Parando…» and the end of
  the stop were never read out (with Enter the focus is on the prompt,
  and the chat log is not live). A visually hidden role=status region in
  the composer says «Parando…» / «Parado.» (en: Stopping… / Stopped.).
- Labels: the button's Send/Stop names were hardcoded Spanish next to the
  localized «Stopping…». They now go through t() (send/stop keys), and
  #btn-send is in applyI18n's title map.
- A message that only waits for another conversation's turn now races
  the lock wait against its stop. When the stop wins, its lock slot is
  still released in order (after the turn ahead), a «(Parado.)» note is
  added, and the button returns to «Enviar» at once instead of showing
  «Parando…» for the whole of the other conversation's turn. stopActive()
  only enters «Parando…» when a turn is running.
- A goal stopped while it lets go is saved as stopped (task in progress
  stopped, pending ones skipped), the same state runGoal reaches when it
  ends. stopActive() saves at once, and the plan in memory still said
  running then, so a reload in that window showed «ejecutando…» forever.

tests/stopqueue.mjs: test 5 checks aria-disabled, focus on the button,
the announcements and that pressing «Parando…» sends nothing; 5b stops
with Space; 6b stops a goal, reloads before it lets go and reads the
saved plan and the card; 7 stops a waiting message while another
conversation generates; 8 runs the labels in English. All 14 new checks
fail on the previous commit and pass on this one.
Changeset3dcd401cd74b071d121a7836347e79a30566c739b15a90d16162ff916df0ce32
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-10 18:11 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-10 18:11 +02:00
Parents2243a41fa822

Browse the files at this changeset

6 files changed

modified tests/stopqueue.mjs +160 −5
@@ -169,9 +169,11 @@
169169 await p.fill('#prompt', 'trabajo largo en la pestaña 1');
170170 await p.click('#btn-send');
171171 await p.waitForFunction(() => document.getElementById('btn-send').classList.contains('is-stop'), null, { timeout: 5000 }).catch(() => {});
172-const boton = () => p.evaluate(() => {
172+const boton = (pg = p) => pg.evaluate(() => {
173173 const b = document.getElementById('btn-send');
174- return { stop: b.classList.contains('is-stop'), sending: b.classList.contains('sending'), disabled: b.disabled, title: b.title, aria: b.getAttribute('aria-busy'), texto: b.textContent.trim() };
174+ return { stop: b.classList.contains('is-stop'), sending: b.classList.contains('sending'), disabled: b.disabled, title: b.title, aria: b.getAttribute('aria-busy'), texto: b.textContent.trim(),
175+ ariaDisabled: b.getAttribute('aria-disabled'), label: b.getAttribute('aria-label'), foco: document.activeElement?.id || document.activeElement?.tagName,
176+ anuncio: document.getElementById('send-status')?.textContent ?? null };
175177 });
176178 const enTrabajo = await boton();
177179 // Con tantas pestañas abiertas por los escenarios de arriba, el «+» y las
@@ -198,11 +200,52 @@
198200 await p.click('#btn-send');
199201 await p.waitForFunction(() => document.getElementById('btn-send').classList.contains('is-stop'), null, { timeout: 5000 }).catch(() => {});
200202 await p.click('#btn-send');
203+await p.waitForTimeout(150); // la región viva se escribe en otro tick
201204 const parando = await boton();
202-await p.waitForFunction(() => !document.getElementById('btn-send').disabled && !document.getElementById('btn-send').classList.contains('sending'), null, { timeout: 8000 }).catch(() => {});
205+// Pulsar «Parando…» otra vez, con texto escrito: no hace nada (ni para ni envía).
206+// force: Playwright da por deshabilitado un botón con aria-disabled y, sin
207+// esto, esperaría a que se habilitara para pulsarlo; un usuario sí lo pulsa.
208+// (El texto se pone y se quita por código para no mover el foco, que es lo
209+// que se mide después.)
210+await p.evaluate(() => { document.getElementById('prompt').value = 'no debe salir al pulsar Parando'; });
211+await p.click('#btn-send', { force: true });
212+const trasPulsarParando = await p.evaluate(async () => {
213+ const conv = await import('/js/conversations.js');
214+ const r = { prompt: document.getElementById('prompt').value, cola: conv.getActive().queue.length };
215+ document.getElementById('prompt').value = '';
216+ return r;
217+});
218+await p.waitForFunction(() => !document.getElementById('btn-send').hasAttribute('aria-disabled') && !document.getElementById('btn-send').classList.contains('sending'), null, { timeout: 8000 }).catch(() => {});
219+await p.waitForTimeout(150);
203220 const despues = await boton();
204-ok('5 · justo tras el clic: «Parando…», deshabilitado y con aria-busy', parando.texto === 'Parando…' && parando.disabled && parando.aria === 'true', JSON.stringify(parando));
205-ok('5 · al soltarse el turno vuelve a «Enviar», habilitado y sin aria-busy', !despues.disabled && despues.title === 'Enviar' && despues.aria === null, JSON.stringify(despues));
221+ok('5 · justo tras el clic: «Parando…», aria-disabled y aria-busy, sin disabled', parando.texto === 'Parando…' && parando.ariaDisabled === 'true' && !parando.disabled && parando.aria === 'true', JSON.stringify(parando));
222+ok('5 · …el foco sigue en el botón (antes caía a <body>)', parando.foco === 'btn-send', parando.foco);
223+ok('5 · …y la región viva dice «Parando…»', parando.anuncio === 'Parando…', JSON.stringify(parando.anuncio));
224+ok('5 · pulsar «Parando…» no hace nada: el texto sigue escrito y no entra en la cola', trasPulsarParando.prompt === 'no debe salir al pulsar Parando' && trasPulsarParando.cola === 0, JSON.stringify(trasPulsarParando));
225+ok('5 · al soltarse el turno vuelve a «Enviar», sin aria-disabled ni aria-busy', !despues.disabled && despues.ariaDisabled === null && despues.title === 'Enviar' && despues.aria === null, JSON.stringify(despues));
226+ok('5 · …con el foco todavía en el botón', despues.foco === 'btn-send', despues.foco);
227+ok('5 · …y la región viva dice «Parado.»', despues.anuncio === 'Parado.', JSON.stringify(despues.anuncio));
228+
229+// 5b. Lo mismo con el teclado: Espacio sobre el botón para, y el foco se queda.
230+await p.evaluate(async () => {
231+ const conv = await import('/js/conversations.js');
232+ window.__prov5b = window.__lento({ pasos: 400, paso: 25, tardaEnParar: 800 });
233+ conv.setProvider(window.__prov5b);
234+});
235+await p.fill('#prompt', 'trabajo para parar con el teclado');
236+await p.press('#prompt', 'Enter');
237+// Que el modelo ya esté generando: parado antes, el turno no tendría nada que
238+// soltar y no pasaría por «Parando…».
239+await p.waitForFunction(() => window.__prov5b.llamadas.length >= 1, null, { timeout: 5000 }).catch(() => {});
240+await p.focus('#btn-send');
241+await p.keyboard.press('Space');
242+await p.waitForTimeout(150);
243+const teclaParando = await boton();
244+await p.waitForFunction(() => !document.getElementById('btn-send').classList.contains('sending'), null, { timeout: 8000 }).catch(() => {});
245+await p.waitForTimeout(150);
246+const teclaDespues = await boton();
247+ok('5b · Espacio sobre ■: «Parando…» con el foco en el botón', teclaParando.texto === 'Parando…' && teclaParando.foco === 'btn-send', JSON.stringify(teclaParando));
248+ok('5b · …y al soltarse, «Enviar» con el foco en el botón', teclaDespues.title === 'Enviar' && teclaDespues.foco === 'btn-send', JSON.stringify(teclaDespues));
206249
207250 // 6. Objetivo parado desde la UI: la tarjeta dice «parado» y la tarea ⏹️
208251 await p.evaluate(async () => {
@@ -229,6 +272,118 @@
229272 ok('6 · la tarjeta del objetivo parado dice «parado»', tarjeta.estado === 'parado', JSON.stringify(tarjeta));
230273 ok('6 · tarea en curso ⏹️ parada y la siguiente saltada', tarjeta.parada === 1 && tarjeta.saltada === 1 && tarjeta.icono === '⏹️', JSON.stringify(tarjeta));
231274
275+// 6b. Objetivo parado y recarga ANTES de que se suelte: lo guardado ya dice
276+// «parado» (tarea en curso parada, la pendiente saltada), y tras recargar la
277+// tarjeta no se queda en «ejecutando…» sin que nada se ejecute.
278+await p.evaluate(async () => {
279+ const conv = await import('/js/conversations.js');
280+ window.__prov6b = window.__lento({ pasos: 400, paso: 25, tardaEnParar: 8000, plan: JSON.stringify({ plan: 'dos pasos', tasks: [
281+ { title: 'Uno', description: 'mira el árbol' }, { title: 'Dos', description: 'resume' }] }) });
282+ conv.setProvider(window.__prov6b);
283+ conv.create();
284+});
285+await modoObjetivo();
286+await p.fill('#prompt', 'objetivo que se para y se recarga');
287+await p.click('#btn-send');
288+await p.waitForFunction(() => document.querySelector('.plan-card li.task-in-progress'), null, { timeout: 8000 }).catch(() => {});
289+await modoObjetivo();
290+const r6b = await p.evaluate(async () => {
291+ const conv = await import('/js/conversations.js');
292+ const db = await import('/js/db.js');
293+ const c = conv.getActive();
294+ conv.stopActive();
295+ await window.__dormir(300);
296+ const g = (await db.get('kv', 'conversations')).find(x => x.id === c.id);
297+ return { id: c.id, sigue: c.pumping, plan: g?.plan ? { status: g.plan.status, tasks: g.plan.tasks.map(t => t.status) } : null };
298+});
299+ok('6b · justo tras parar (el objetivo aún se suelta), el plan guardado ya está parado',
300+ r6b.sigue && r6b.plan?.status === 'stopped' && JSON.stringify(r6b.plan.tasks) === '["stopped","skipped"]', JSON.stringify(r6b));
301+// Con trabajo vivo la página pide confirmar antes de irse (beforeunload): se
302+// acepta, como haría quien recarga a propósito.
303+p.once('dialog', d => d.accept().catch(() => {}));
304+await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
305+await p.waitForTimeout(2500);
306+await ayudantes();
307+const tarjeta6b = await p.evaluate(() => {
308+ const c = [...document.querySelectorAll('.plan-card')].at(-1);
309+ return { estado: c?.querySelector('.plan-status')?.textContent, enCurso: c?.querySelectorAll('li.task-in-progress').length };
310+});
311+ok('6b · tras recargar, la tarjeta dice «parado» y no hay tarea en curso', tarjeta6b.estado === 'parado' && tarjeta6b.enCurso === 0, JSON.stringify(tarjeta6b));
312+
313+// 7. Parar un mensaje que solo ESPERA turno (otra conversación genera): no hay
314+// nada que soltar, así que ni «Parando…» durante el turno ajeno: vuelve a
315+// «Enviar» enseguida, con su «(Parado.)» en el chat y anunciado.
316+await p.evaluate(async () => {
317+ const conv = await import('/js/conversations.js');
318+ window.__prov7 = window.__lento({ pasos: 160, paso: 25 });
319+ conv.setProvider(window.__prov7);
320+ const A = conv.create();
321+ window.__A7 = A;
322+ conv.send(A.id, 'A7 genera un buen rato');
323+ await window.__hasta(() => window.__prov7.llamadas.length >= 1);
324+ conv.create(); // B, la activa, en la UI
325+});
326+await p.fill('#prompt', 'B7 espera turno');
327+await p.click('#btn-send');
328+await p.waitForFunction(() => document.getElementById('btn-send').classList.contains('is-stop'), null, { timeout: 5000 }).catch(() => {});
329+await p.click('#btn-send');
330+await p.waitForTimeout(400);
331+const r7 = await p.evaluate(async () => {
332+ const conv = await import('/js/conversations.js');
333+ const B = conv.getActive();
334+ const notas = [...document.querySelectorAll('#chat-log .msg.muted')].map(d => d.textContent);
335+ return { aSigue: window.__A7.pumping, bTrabaja: B.pumping, bParando: !!B.parando, cola: B.queue.length, notas,
336+ llamadas: window.__prov7.llamadas };
337+});
338+const boton7 = await boton();
339+ok('7 · A sigue generando mientras tanto', r7.aSigue, JSON.stringify(r7));
340+ok('7 · B ya no trabaja ni está «Parando…», y su cola está vacía', !r7.bTrabaja && !r7.bParando && r7.cola === 0, JSON.stringify(r7));
341+ok('7 · el botón de B vuelve a «Enviar» sin esperar a A', boton7.title === 'Enviar' && !boton7.sending && boton7.ariaDisabled === null, JSON.stringify(boton7));
342+ok('7 · el chat de B dice «(Parado.)» y la región viva «Parado.»', r7.notas.includes('(Parado.)') && boton7.anuncio === 'Parado.', JSON.stringify({ notas: r7.notas, anuncio: boton7.anuncio }));
343+ok('7 · el modelo nunca recibió el mensaje de B', !r7.llamadas.some(t => t.includes('B7')), JSON.stringify(r7.llamadas));
344+const r7b = await p.evaluate(async () => {
345+ await window.__hasta(() => !window.__A7.pumping, 800);
346+ return { respondio: window.__A7.agent.history.at(-1)?.role === 'assistant', llamadas: window.__prov7.llamadas.length };
347+});
348+ok('7 · A termina con su respuesta, y nadie más llamó al modelo', r7b.respondio && r7b.llamadas === 1, JSON.stringify(r7b));
349+
350+// 8. En inglés el botón no mezcla idiomas: Send / Stop / Stopping…
351+{
352+ const ctxEn = await b.newContext({ locale: 'en-US' });
353+ await ctxEn.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
354+ const pe = await ctxEn.newPage({ viewport: { width: 1300, height: 900 } });
355+ pe.on('pageerror', e => errs.push(e.message.slice(0, 160)));
356+ await pe.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
357+ await pe.waitForTimeout(1500);
358+ const inicial = await boton(pe);
359+ await pe.evaluate(async () => {
360+ window.__dormir = ms => new Promise(r => setTimeout(r, ms));
361+ const conv = await import('/js/conversations.js');
362+ conv.setProvider({ name: 'lento-en', chat: async (h, s, cb, signal) => {
363+ for (let i = 0; i < 400; i++) {
364+ if (signal?.aborted) { await window.__dormir(600); throw new DOMException('Stopped', 'AbortError'); }
365+ cb('·'); await window.__dormir(25);
366+ }
367+ return 'done';
368+ } });
369+ });
370+ await pe.fill('#prompt', 'long job');
371+ await pe.click('#btn-send');
372+ await pe.waitForFunction(() => document.getElementById('btn-send').classList.contains('is-stop'), null, { timeout: 5000 }).catch(() => {});
373+ const trabajando = await boton(pe);
374+ await pe.click('#btn-send');
375+ await pe.waitForTimeout(150);
376+ const parandoEn = await boton(pe);
377+ await pe.waitForFunction(() => !document.getElementById('btn-send').classList.contains('sending'), null, { timeout: 8000 }).catch(() => {});
378+ await pe.waitForTimeout(150);
379+ const finEn = await boton(pe);
380+ ok('8 · en inglés: Send → Stop → Stopping… → Send',
381+ inicial.title === 'Send' && trabajando.label === 'Stop' && parandoEn.label === 'Stopping…' && finEn.label === 'Send',
382+ JSON.stringify([inicial.title, trabajando.label, parandoEn.label, finEn.label]));
383+ ok('8 · …y la región viva anuncia en inglés', parandoEn.anuncio === 'Stopping…' && finEn.anuncio === 'Stopped.', JSON.stringify([parandoEn.anuncio, finEn.anuncio]));
384+ await ctxEn.close();
385+}
386+
232387 console.log('\n errores JS:', errs[0] || 'ninguno');
233388 console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ PARAR DESDE LA CONVERSACIÓN OK — cola, cerrojo, recarga y botón');
234389 await b.close();
modified web/css/code.css +2 −0
@@ -421,6 +421,8 @@
421421 apagado y sin el spinner (en un botón más ancho saldría ovalado). */
422422 #btn-send.is-stopping { background: #7a2a2d; color: #f3d6d7; cursor: progress; font-size: .78rem; white-space: nowrap; }
423423 #btn-send.is-stopping::after { display: none; }
424+/* Solo para lectores de pantalla (la región viva del envío). */
425+.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
424426
425427 #composer #prompt { flex: 1; min-width: 0; }
426428
modified web/index.html +1 −0
@@ -145,6 +145,7 @@
145145 </div>
146146 <button type="submit" id="btn-send" title="Enviar"></button>
147147 </form>
148+ <div id="send-status" class="sr-only" role="status" aria-live="polite"></div>
148149 </div>
149150 </section>
150151 </main>
modified web/js/conversations.js +46 −8
@@ -65,17 +65,18 @@
6565 //
6666 // `parando` cubre el rato entre el clic y el final real del turno (un modelo
6767 // lento tarda en soltar la generación): la UI lo enseña como «Parando…» en vez
68-// de dejar un ■ que parece no hacer caso.
68+// de dejar un ■ que parece no hacer caso. Sin turno en marcha no hay nada que
69+// soltar, y se dice ya que está parado.
6970 export function stopActive() {
7071 const c = getActive();
7172 if (!c || (!c.pumping && !c.queue.length)) return false;
7273 c.stopped = true;
73- c.parando = true;
74+ c.parando = c.pumping;
7475 try { c.aborter?.abort(); } catch { /* */ }
7576 try { c.agent.stop(); } catch { /* */ }
7677 c.queue.length = 0;
7778 persistConv(c).catch(e => console.warn('[elffuss] no se pudo guardar la cola vaciada', e));
78- onChange('stopping', c.id, true);
79+ onChange('stopping', c.id, c.parando);
7980 return true;
8081 }
8182
@@ -115,11 +116,27 @@
115116 const i = all.findIndex(c => c.id === conv.id);
116117 const rec = {
117118 id: conv.id, title: titleFor(conv), history: conv.agent.history.slice(-HIST_CAP),
118- queue: conv.queue, plan: conv.plan || null, createdAt: conv.createdAt, updatedAt: conv.updatedAt,
119+ queue: conv.queue, plan: planParaGuardar(conv), createdAt: conv.createdAt, updatedAt: conv.updatedAt,
119120 };
120121 if (i >= 0) all[i] = rec; else all.push(rec);
121122 await db.set('kv', 'conversations', all).catch(() => {});
122123 }
124+// El plan de un objetivo PARADO que aún se está soltando se guarda ya como
125+// parado: stopActive() guarda en el acto (para que recargar no repita nada), y
126+// en ese momento el plan en memoria todavía dice «ejecutando», con su tarea en
127+// curso. Recargando antes de que el objetivo terminase de soltarse, la tarjeta
128+// decía «ejecutando…» para siempre sin que nada se ejecutara. Es lo mismo que
129+// runGoal deja al terminar: la tarea en curso parada y las pendientes saltadas.
130+function planParaGuardar(conv) {
131+ const plan = conv.plan || null;
132+ if (!plan || !conv.stopped || (plan.status !== 'planning' && plan.status !== 'running')) return plan;
133+ return {
134+ ...plan, status: 'stopped',
135+ tasks: (plan.tasks || []).map(t => ({
136+ ...t, status: t.status === 'in-progress' ? 'stopped' : t.status === 'pending' ? 'skipped' : t.status,
137+ })),
138+ };
139+}
123140 function persistMeta() {
124141 try { localStorage.setItem(TABS_KEY, JSON.stringify(openTabIds)); } catch { /* lleno */ }
125142 try { localStorage.setItem(ACTIVE_KEY, activeId || ''); } catch { /* lleno */ }
@@ -267,6 +284,16 @@
267284 pump(conv);
268285 }
269286
287+// true cuando le toca el turno; false si la parada llega antes.
288+function turnoOParada(turno, signal) {
289+ if (signal.aborted) return Promise.resolve(false);
290+ return new Promise(resolve => {
291+ const alParar = () => resolve(false);
292+ signal.addEventListener('abort', alParar, { once: true });
293+ turno.then(() => { signal.removeEventListener('abort', alParar); resolve(true); });
294+ });
295+}
296+
270297 // Cada turno lleva su propia parada (conv.aborter), creada ANTES de esperar el
271298 // cerrojo: parar mientras espera turno lo cancela sin llegar a llamar al
272299 // modelo. Antes la parada solo alcanzaba al turno que ya estaba generando, así
@@ -301,10 +328,21 @@
301328 const myTurn = inferenceLock;
302329 let release;
303330 inferenceLock = new Promise(r => { release = r; });
304- await myTurn; // espera su turno de inferencia (un solo modelo cargado, no admite 2 generate() a la vez)
331+ // Espera su turno de inferencia (un solo modelo cargado, no admite 2
332+ // generate() a la vez)… o la parada, lo que llegue antes. Parar un mensaje
333+ // que solo espera turno no tiene nada que soltar: antes el botón se quedaba
334+ // en «Parando…» todo lo que durase el turno de OTRA conversación. Su hueco
335+ // en el cerrojo se suelta igualmente en orden, cuando lo suelte el de
336+ // delante, para que nadie se cuele por detrás mientras aquel sigue.
337+ const tengoTurno = await turnoOParada(myTurn, signal);
338+ if (!tengoTurno) myTurn.then(release);
305339 try {
306- // Parado (o quitado de la cola) mientras esperaba: ni se llama al modelo.
307- if (!signal.aborted && conv.queue[0] === item) {
340+ // Parado (o quitado de la cola) mientras esperaba: ni se llama al modelo,
341+ // y se dice en el chat como cualquier otro turno parado.
342+ if (signal.aborted && !tengoTurno) {
343+ try { onChange('event', conv.id, { type: 'aborted', text: '(Parado.)' }); } catch (e) { console.error('[elffuss] fallo pintando un evento de chat', e); }
344+ }
345+ if (tengoTurno && !signal.aborted && conv.queue[0] === item) {
308346 // un fallo aquí (del modelo, de una tool, o del propio repintado en
309347 // main.js) NUNCA debe dejar la conversación "pumping" para siempre —
310348 // eso bloquearía sus futuros mensajes Y al cerebro CEO (isBusy()).
@@ -340,7 +378,7 @@
340378 console.error('[elffuss] fallo procesando el turno', e);
341379 telemetry.reportError('pump: ' + (e?.message || e), { stack: e?.stack || '' });
342380 try { onChange('event', conv.id, { type: 'error', text: 'Error interno: ' + (e?.message || e) }); } catch { /* ya está registrado arriba */ }
343- } finally { release(); }
381+ } finally { if (tengoTurno) release(); }
344382 if (conv.aborter === aborter) conv.aborter = null;
345383 if (conv.queue[0] === item) conv.queue.shift();
346384 conv.updatedAt = Date.now();
modified web/js/i18n.js +7 −1
@@ -111,6 +111,9 @@
111111 planFailed: "con fallos",
112112 planStopped: "parado",
113113 stopping: "Parando…",
114+ stopped: "Parado.",
115+ send: "Enviar",
116+ stop: "Parar",
114117 stModelLoadingAI: "Cargando el modelo IA…",
115118 termCapsBridge: "🔌 Bridge local: node/npm/python reales",
116119 termCapsNoBridge: "shell del proyecto · node/npm/python → Bridge local (⚙ Ajustes)",
@@ -226,6 +229,9 @@
226229 planFailed: "with failures",
227230 planStopped: "stopped",
228231 stopping: "Stopping…",
232+ stopped: "Stopped.",
233+ send: "Send",
234+ stop: "Stop",
229235 stModelLoadingAI: "Loading the AI model…",
230236 termCapsBridge: "🔌 Local bridge: real node/npm/python",
231237 termCapsNoBridge: "project shell · node/npm/python → Local bridge (⚙ Settings)",
@@ -271,7 +277,7 @@
271277 '#term-close': 'tTermClose', '#term-resize': 'tTermResize', '#ctx-meter': 'tCtx',
272278 '#btn-plus': 'tPlus', '#btn-autoedit': 'tAutoedit', '#btn-goal': 'tGoal',
273279 '#btn-hardwork': 'tHardwork',
274- '#code-flip': 'tFlip', '#btn-slash': 'tSlash',
280+ '#code-flip': 'tFlip', '#btn-slash': 'tSlash', '#btn-send': 'send',
275281 };
276282 for (const [sel, key] of Object.entries(titles)) set(sel, 'title', key);
277283 }
modified web/js/main.js +26 −7
@@ -263,7 +263,7 @@
263263 else { activeThinking?.remove(); activeThinking = null; }
264264 return;
265265 }
266- if (kind === 'stopping') { paintSendButton(); return; }
266+ if (kind === 'stopping') { paintSendButton(); anunciarEnvio(payload ? t('stopping') : t('stopped')); return; }
267267 if (kind === 'event') {
268268 const ev = payload;
269269 if (ev.type === 'token') activeThinking?.tick(ev.text);
@@ -1181,8 +1181,11 @@
11811181 $('composer').addEventListener('submit', e => {
11821182 e.preventDefault();
11831183 // Mientras el agente trabaja, el mismo botón PARA en vez de enviar. Si ya se
1184- // está parando, lo que se escriba va a la cola y sale en cuanto termine.
1184+ // está parando, lo que se escriba con Enter va a la cola y sale en cuanto
1185+ // termine; pulsar el propio botón, que dice «Parando…» y está aria-disabled,
1186+ // no hace nada (requestSubmit() desde el cuadro de texto llega sin submitter).
11851187 const active = conv.getActive();
1188+ if (active?.parando && e.submitter?.id === 'btn-send') return;
11861189 if (active && active.pumping && !active.parando) { conv.stopActive(); return; }
11871190 const text = $('prompt').value.trim();
11881191 if (!text) return;
@@ -1199,18 +1202,34 @@
11991202 const active = conv.getActive();
12001203 const busy = !!active?.pumping;
12011204 // «Parando…»: ya se pulsó ■ y el turno aún se está soltando (un modelo lento
1202- // tarda en dejar la generación). Deshabilitado y con aria-busy: antes el ■
1203- // seguía igual tras el clic y parecía que no había hecho caso.
1205+ // tarda en dejar la generación). Antes el ■ seguía igual tras el clic y
1206+ // parecía que no había hecho caso. Se marca con aria-disabled y NO con
1207+ // disabled: deshabilitar el botón que tiene el foco lo saca del foco, el
1208+ // teclado caía a <body> y ya no volvía.
12041209 const parando = busy && !!active?.parando;
12051210 b.classList.toggle('sending', busy);
12061211 b.classList.toggle('is-stop', busy && !parando);
12071212 b.classList.toggle('is-stopping', parando);
1208- b.disabled = parando;
1209- if (parando) b.setAttribute('aria-busy', 'true'); else b.removeAttribute('aria-busy');
1213+ if (parando) { b.setAttribute('aria-disabled', 'true'); b.setAttribute('aria-busy', 'true'); }
1214+ else { b.removeAttribute('aria-disabled'); b.removeAttribute('aria-busy'); }
12101215 b.innerHTML = parando ? escapeHtml(t('stopping')) : busy ? STOP_ICON : UI.send;
1211- b.title = parando ? t('stopping') : busy ? 'Parar' : 'Enviar';
1216+ b.title = parando ? t('stopping') : busy ? t('stop') : t('send');
12121217 b.setAttribute('aria-label', b.title);
12131218 }
1219+// La parada se anuncia en una región viva: el botón solo lo dice en su
1220+// etiqueta, y parando con Enter el foco está en el cuadro de texto, así que el
1221+// cambio no se oía; el «(Parado.)» del chat tampoco, porque el chat no es una
1222+// región viva. Se vacía y se escribe en otro tick para que el mismo texto dos
1223+// veces seguidas se vuelva a leer, y un anuncio que llega antes de escribirse
1224+// el anterior lo sustituye.
1225+let anuncioPendiente = null;
1226+function anunciarEnvio(texto) {
1227+ const r = document.getElementById('send-status');
1228+ if (!r) return;
1229+ clearTimeout(anuncioPendiente);
1230+ r.textContent = '';
1231+ anuncioPendiente = setTimeout(() => { r.textContent = texto; }, 50);
1232+}
12141233 $('model-select').addEventListener('change', e => changeModel(e.target.value));
12151234 // móvil: conmutar chat ↔ editor
12161235 $('code-flip').addEventListener('click', () => {