Settings sat 7px further in than the Dashboard/Giám sát rows above it — its
QSS gave it a 6px side margin where those rows start at the rail edge. At the
collapsed 54px width that put its icon near the middle of the rail, which is
what "thu gọn menu lại ra giữa" was describing. Icon and label now start on
the same x as the rows, open and collapsed, in both themes.
The help panel's transcript is rendered HTML, so switching language re-labelled
the chrome but left the greeting — and the "AI Assistant" speaker label — in
whatever language the panel was built in. retranslate() now rewrites the
greeting (matched by identity, so a real reply is never touched) and re-renders.
The sparkle is #FDBE59, sampled from the audit page's own render. Its CSS says
.spark{color:#0F9B8A}, but the glyph is the ✨ emoji and a colour emoji ignores
CSS colour, so the page has always drawn a gold star.
Behind all three: MainWindow does not style itself — run() calls
app.setStyleSheet — so 12 of 13 checkers were measuring a window with no
padding, margins or borders. Every QSS-driven layout bug was invisible to them,
and an unstyled window reported an icon drift that does not exist. Added
_apply_theme() and wired it through.
Two checker repairs that followed:
· check_no_hscroll flagged the 9pt dialogs on sizeHintForColumn(0), which
returns 182px at 9pt, 11pt and 14pt alike. Nothing was clipped. It now
compares the painted text against the width actually on screen, and fails
on a squeezed list (24 combos) where the old test passed.
· the checkers print Vietnamese and died mid-report on a cp932 console.
New: check_rail_align (icons hold one line, both themes, both states) and
check_help_i18n (transcript follows the language). Both verified to fail
without their fix.
15/15 checkers pass. check_nav and check_design_parity segfault in Qt teardown
roughly one run in three — pre-existing, after the verdict prints, and it
happens with or without the theme change.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
"""The help panel must follow a language switch — transcript included.
|
|
|
|
retranslate() re-labelled the chrome but not the rendered HTML transcript, so
|
|
the greeting and the "AI Assistant" speaker label stayed in the language the
|
|
panel happened to be built in.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(REPO.parent))
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
|
|
from capture_screens import ( # noqa: E402
|
|
_apply_theme, _freeze_schedulers, _isolate_home, _load_fonts)
|
|
|
|
|
|
def main() -> int:
|
|
sandbox = _isolate_home()
|
|
from PySide6.QtWidgets import QApplication
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8") # ja/vi text on a cp932 console
|
|
app = QApplication([])
|
|
_load_fonts()
|
|
_freeze_schedulers()
|
|
_apply_theme(app)
|
|
|
|
from cowork_local.config import CONFIG_DIR
|
|
assert str(sandbox) in str(CONFIG_DIR), f"isolation failed: {CONFIG_DIR}"
|
|
|
|
from seed_demo_data import seed
|
|
seed()
|
|
|
|
from cowork_local.app import MainWindow
|
|
from cowork_local.config import AppConfig
|
|
from cowork_local.i18n import set_language
|
|
from cowork_local.state import AppContext
|
|
|
|
set_language("vi")
|
|
win = MainWindow(AppContext(AppConfig.load()), user_name="local")
|
|
win.resize(1400, 900)
|
|
win.show()
|
|
app.processEvents()
|
|
|
|
panel = win.help_agent
|
|
fails = []
|
|
for lang in ("en", "ja", "vi"):
|
|
win._set_language(lang) if hasattr(win, "_set_language") else set_language(lang)
|
|
if not hasattr(win, "_set_language"):
|
|
panel.retranslate()
|
|
app.processEvents()
|
|
|
|
# The panel greets by the signed-in name, not the placeholder.
|
|
want = panel._greeting()
|
|
shown = re.sub("<[^>]+>", " ", panel.log.toHtml())
|
|
shown = " ".join(shown.split())
|
|
# compare on the stable half of the sentence, the name is substituted
|
|
probe = " ".join(want.split())[:28]
|
|
state = "ok" if probe and probe in shown else "MISSING"
|
|
print(f"{lang}: title={panel.title.text()!r} greeting={state}")
|
|
if state != "ok":
|
|
print(f" muon: {probe!r}")
|
|
print(f" thay: {shown[:160]!r}")
|
|
if state != "ok":
|
|
fails.append(f"{lang}: transcript still shows another language")
|
|
|
|
print()
|
|
print("PASS panel follows the language" if not fails
|
|
else "\n".join(f"FAIL {f}" for f in fails))
|
|
sys.stdout.flush()
|
|
os._exit(1 if fails else 0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|