feat(04-01): integrate notifications and focus mode into daemon
- Notifier + FocusTimer fields in Daemon, initialized in NewDaemon - processHookEvent notifies on Working -> Needs Input only (D-01) - Focus mode suppresses notifications when active (D-05) - FocusArgs in protocol, "focus" handler in daemon - CLI "vmux focus <minutes>" command - Tests for all notification transitions and focus handler
This commit is contained in:
16
hook.go
16
hook.go
@@ -70,8 +70,24 @@ func (d *Daemon) processHookEvent(event HookEvent) {
|
||||
return
|
||||
}
|
||||
|
||||
// Read PrevState BEFORE UpdateFromHook overwrites it
|
||||
d.registry.mu.RLock()
|
||||
prevState := ""
|
||||
if ts, ok := d.registry.sessions[event.SessionID]; ok {
|
||||
prevState = ts.PrevState
|
||||
}
|
||||
d.registry.mu.RUnlock()
|
||||
|
||||
d.registry.UpdateFromHook(event.SessionID, state, waitType, event.Cwd)
|
||||
|
||||
// Notify only on Working -> Needs Input transition (D-01)
|
||||
if state == "Needs Input" && prevState == "Working" && !d.focus.IsActive() {
|
||||
d.registry.mu.RLock()
|
||||
info := d.registry.sessions[event.SessionID].Info
|
||||
d.registry.mu.RUnlock()
|
||||
d.notifier.Notify("vmux: "+shortName(info), "Session needs input ("+waitType+")")
|
||||
}
|
||||
|
||||
d.mu.Lock()
|
||||
d.lastHookTime = time.Now()
|
||||
d.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user