Fix drift sync: per-window verdicts, forgiving class match, event-driven status bar
Three independent defects made the focus state feel flaky and let the OS
status bar disagree with the web UI:
- Status file lagged the web by up to a minute: it rendered only on a 60s
ticker with no hook into state changes. notify() now fans out to multiple
listeners (AddOnChange) and the writer has a coalesced Wake() so drift
reaches the bar as promptly as the browser.
- A brief off-task visit could latch drift for the whole session. Sibling
windows of one app (a browser's reading tab vs its chat tab) share a window
class, but the judge verdict was cached by class alone, so one tab's verdict
poisoned the rest and never re-judged. Cache is now keyed by class + scrubbed
title (judgedWindows) so siblings are judged independently.
- Allowed-class matching was exact equality, so a short token ("brave") never
matched the real WM_CLASS ("Brave-browser") and every window was routed to
the LLM. Matching is now substring-based, and planning surfaces the live
window class with a click-to-add chip so users pick a token that matches.
Also fix the planning checkbox alignment: the global full-width input rule was
stretching the "Enforce focus" checkbox; scope it out for checkboxes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -97,7 +97,11 @@ func main() {
|
||||
if statusPath, err := statusfile.DefaultPath(); err != nil {
|
||||
log.Printf("status file disabled: %v", err)
|
||||
} else {
|
||||
go statusfile.NewWriter(statusPath, ctrl.State).Run(context.Background())
|
||||
writer := statusfile.NewWriter(statusPath, ctrl.State)
|
||||
// Re-render the bar on every state change, not just the coarse tick, so a
|
||||
// drift transition reaches the status bar as fast as it reaches the web UI.
|
||||
ctrl.AddOnChange(writer.Wake)
|
||||
go writer.Run(context.Background())
|
||||
log.Printf("status: writing %s", statusPath)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user