HEL-824: land verified fixes on 4321aeb (small-screen first-press, real-time reading clock)
- 6 modified + handoff JSON per CHANGES-HEL-824.json, all hashes verified against git 4321aeb and package bytes
- rework_browser_check: skip full-text sheet at micro height (<420px design hides the control); migrate stale 返回日子 selector to 结束交谈 · 回到日子
- fresh run evidence: web build 25/25 unit tests, backend 142/142 (py3.12), all four browser checks PASS incl. new compact first-press and 700ms slow-frame sections (slow_frames_new_turn_to_reply_s=2.32s), layout regression 320/390/1024/1600 both themes
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -5,8 +5,10 @@ No deployed service or user data is read or written. Every server/context closes
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from playwright.sync_api import expect, sync_playwright
|
||||
@@ -79,6 +81,17 @@ TRACK = """() => { const seen = window.lineSeen = {}, inked = window.lineInked =
|
||||
new MutationObserver(list => list.forEach(r => r.addedNodes.forEach(note))).observe(document.querySelector('.stage'), {childList: true}); }"""
|
||||
STILL = "() => [...document.querySelectorAll('.stage .line:not(.leaving)')].every(n => n.getAnimations().length === 0)"
|
||||
CURRENT = '.stage .line.is-current:not(.leaving)'
|
||||
# Her words only: the line also carries her name and state ("星河" / "还在说"), so exact text targets the <p>.
|
||||
HER_WORDS = CURRENT + '[data-role="companion"] p'
|
||||
# HEL-824: one real press while the input has focus. Records where the dialogue sat at press and at release and
|
||||
# which button the browser delivered the click to; nothing is blurred or dispatched by the script.
|
||||
TAP = """() => { const c = document.querySelector('.conversation'), top = () => Math.round(c.getBoundingClientRect().top);
|
||||
window.tap = null; let down = null;
|
||||
addEventListener('pointerdown', () => { down = top(); }, {capture: true, once: true});
|
||||
addEventListener('click', e => { const b = e.target.closest('button');
|
||||
window.tap = {down, up: top(), typing: document.documentElement.classList.contains('typing'), target: b ? (b.getAttribute('aria-label') || b.textContent.trim()) : e.target.tagName}; }, {capture: true, once: true}); }"""
|
||||
# Busy frames (software rendering, a heavy crossfade) arrive far apart; the reading clock must still keep real time.
|
||||
SLOW_FRAMES = "window.requestAnimationFrame = cb => setTimeout(() => cb(performance.now()), 700); window.cancelAnimationFrame = id => clearTimeout(id);"
|
||||
|
||||
|
||||
try:
|
||||
@@ -169,6 +182,7 @@ try:
|
||||
assert metrics['composer']['bottom'] < metrics['nav']['top'], metrics
|
||||
report['viewports'].append({'width': width, 'height': height, 'theme': theme, **metrics})
|
||||
if width in (360, 390) and height in (640, 420, 844): shot(page, f'long-line-{width}-{height}-{theme}')
|
||||
if page.evaluate("document.documentElement.classList.contains('micro')"): continue # micro (<420px) intentionally hides 全文/status; the design protects the dialogue area
|
||||
click(page, '全文')
|
||||
expect(page.locator('.record.full')).to_be_visible()
|
||||
page.keyboard.press('Escape')
|
||||
@@ -182,13 +196,59 @@ try:
|
||||
if page.get_by_role('button', name='继续', exact=True).count(): click(page, '继续')
|
||||
passed('12 viewport/theme combinations: lines stay inside the stage, stage/reader/composer/navigation never overlap; Esc closes full text with focus back; full history reachable')
|
||||
|
||||
# HEL-824 defect 1: keyboard-height screens, input focused, then a direct press on send / full text /
|
||||
# pause / review. The press blurs the input; the dialogue must not move between press and release.
|
||||
provider.mode = 'normal'
|
||||
box, flow = page.get_by_role('textbox', name='想和她说的话'), page.locator('.reader-bar .flow')
|
||||
report['compact_first_press'] = []
|
||||
|
||||
def first_press(button, label):
|
||||
box.focus()
|
||||
assert page.evaluate("document.documentElement.classList.contains('typing')")
|
||||
page.evaluate(TAP)
|
||||
button.click()
|
||||
tap = page.evaluate('window.tap')
|
||||
assert tap and tap['target'] == label and tap['down'] == tap['up'] and tap['typing'] is False, tap
|
||||
report['compact_first_press'].append({'size': f'{width}x{height}', 'theme': theme, **tap})
|
||||
|
||||
for width, height in [(390, 420), (390, 430)]:
|
||||
page.set_viewport_size({'width': width, 'height': height})
|
||||
for theme, label in [('moon', '靛蓝月光'), ('fog', '蓝紫雾光')]:
|
||||
click(page, label)
|
||||
expect(page.locator('html')).to_have_class(re.compile(r'\bcompact\b'))
|
||||
words = f'小屏首击{width}{theme}'
|
||||
count = app.state.store.query_one('SELECT count(*) n FROM chat_message')['n']
|
||||
box.fill(words)
|
||||
first_press(page.get_by_role('button', name='发送', exact=True), '发送')
|
||||
expect(box).to_have_value('')
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(page.locator(HER_WORDS)).to_have_text('答复', timeout=8000)
|
||||
assert app.state.store.query_one('SELECT count(*) n FROM chat_message')['n'] == count + 2
|
||||
first_press(page.get_by_role('button', name='上一句', exact=True), '上一句')
|
||||
expect(page.locator(CURRENT)).to_have_attribute('data-role', 'user')
|
||||
expect(page.locator(CURRENT + ' p')).to_have_text(words)
|
||||
page.locator('.reader-bar .latest').click()
|
||||
expect(page.locator(HER_WORDS)).to_have_text('答复')
|
||||
was = flow.get_attribute('aria-pressed')
|
||||
first_press(flow, flow.inner_text().strip())
|
||||
expect(flow).not_to_have_attribute('aria-pressed', was)
|
||||
first_press(flow, flow.inner_text().strip())
|
||||
expect(flow).to_have_attribute('aria-pressed', was)
|
||||
first_press(page.get_by_role('button', name='全文', exact=True), '全文')
|
||||
expect(page.locator('.record.full')).to_be_visible()
|
||||
expect(page.locator('.record.full')).to_contain_text('答复')
|
||||
page.keyboard.press('Escape')
|
||||
expect(page.locator('.record.full')).to_have_count(0)
|
||||
if theme == 'moon': shot(page, f'compact-first-press-{width}-{height}-moon')
|
||||
passed('390x420 and 390x430, both themes: with the input focused, the first press on send, review, pause/continue and full text acts; the dialogue does not move between press and release')
|
||||
|
||||
page.set_viewport_size({'width': 390, 'height': 700})
|
||||
provider.mode = 'slow'; send(page, '取消并重发')
|
||||
expect(page.get_by_role('button', name='停止回复')).to_be_visible()
|
||||
click(page, '停止回复')
|
||||
provider.mode = 'normal'; send(page, '新轮')
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(page.locator(CURRENT + '[data-role="companion"]')).to_have_text('答复', timeout=8000)
|
||||
expect(page.locator(HER_WORDS)).to_have_text('答复', timeout=8000)
|
||||
provider.mode = 'error'; send(page, '失败再试')
|
||||
expect(page.locator('.talk-status .retry')).to_be_visible()
|
||||
expect(page.get_by_role('textbox', name='想和她说的话')).to_have_value('失败再试')
|
||||
@@ -199,6 +259,24 @@ try:
|
||||
assert app.state.store.query_one('SELECT count(*) n FROM chat_message')['n'] == count + 1
|
||||
passed('Cancel then immediate new turn, model error and same-turn retry preserve roles and avoid duplicate user messages')
|
||||
|
||||
# HEL-824 defect 2: the same stop -> immediate new turn with frames 700 ms apart. Your line keeps its
|
||||
# designed 1.4 s, then her reply is on stage; before the fix each frame counted 100 ms (about 10 s).
|
||||
slow = browser.new_context(viewport={'width': 390, 'height': 700})
|
||||
slow.add_init_script(SLOW_FRAMES)
|
||||
sp = slow.new_page(); sp.on('pageerror', lambda e: report['console_errors'].append(str(e)))
|
||||
sp.goto(url); nav(sp, '交谈')
|
||||
provider.mode = 'slow'; send(sp, '慢帧下取消')
|
||||
expect(sp.get_by_role('button', name='停止回复')).to_be_visible()
|
||||
click(sp, '停止回复')
|
||||
provider.mode = 'normal'; send(sp, '慢帧下新轮')
|
||||
sent = time.monotonic()
|
||||
expect(sp.locator(CURRENT)).to_have_attribute('data-role', 'user')
|
||||
expect(sp.locator(HER_WORDS)).to_have_text('答复', timeout=8000)
|
||||
report['motion']['slow_frames_new_turn_to_reply_s'] = round(time.monotonic() - sent, 2)
|
||||
assert sp.locator(CURRENT + ' .state').inner_text() == ''
|
||||
slow.close()
|
||||
passed('Stop then new turn with busy (700 ms) frames: your line keeps its own time and her reply follows; the reading clock counts real time')
|
||||
|
||||
nav(page, '设置'); click(page, '她')
|
||||
expect(page.locator('.color-sections section')).to_have_count(6)
|
||||
expect(page.locator('.calendar')).to_contain_text('闰四月初一')
|
||||
@@ -240,12 +318,12 @@ try:
|
||||
assert page.locator('html').evaluate("el=>el.classList.contains('reduced')")
|
||||
provider.mode = 'normal'; send(page, '减少动效检查')
|
||||
expect(page.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(page.locator(CURRENT + '[data-role="companion"]')).to_have_text('答复', timeout=8000)
|
||||
expect(page.locator(HER_WORDS)).to_have_text('答复', timeout=8000)
|
||||
assert page.evaluate(STILL) and page.locator('.stage p.ink').count() == 0
|
||||
reduced = browser.new_context(viewport={'width': 390, 'height': 700}, reduced_motion='reduce')
|
||||
rp = reduced.new_page(); rp.goto(url); nav(rp, '交谈'); send(rp, '系统减少动效')
|
||||
expect(rp.get_by_role('button', name='停止回复')).not_to_be_visible()
|
||||
expect(rp.locator(CURRENT + '[data-role="companion"]')).to_have_text('答复', timeout=8000)
|
||||
expect(rp.locator(HER_WORDS)).to_have_text('答复', timeout=8000)
|
||||
assert rp.evaluate(STILL) and rp.locator('.stage p.ink').count() == 0
|
||||
reduced.close()
|
||||
passed('Escape navigation; browser display preference survives reload; settings/system reduced motion uses gentle opacity')
|
||||
@@ -266,7 +344,7 @@ try:
|
||||
click(dp, '结束语音')
|
||||
dp.locator('.demo > button').click(); click(dp, '载入三天记录')
|
||||
nav(dp, '日子'); dp.locator('.ev').first.click(); click(dp, '看那段聊天')
|
||||
expect(dp.locator('.log-panel')).to_be_visible(); click(dp, '关闭记录'); click(dp, '返回日子')
|
||||
expect(dp.locator('.log-panel')).to_be_visible(); click(dp, '关闭记录'); click(dp, '结束交谈 · 回到日子')
|
||||
expect(dp.locator('.pane[aria-label="日子"]')).to_have_class('pane glass read open has-detail')
|
||||
assert not requests
|
||||
passed('Demo has its own profile, voice simulation, life/detail/chat/return path and zero API requests')
|
||||
|
||||
Reference in New Issue
Block a user