Snapshot task worktrees to hidden refs as agents work
This commit is contained in:
@@ -51,6 +51,9 @@ type Manager struct {
|
||||
deliverMu sync.Mutex
|
||||
capMu sync.Mutex
|
||||
|
||||
snapMu sync.Mutex
|
||||
snaps map[string]*snapState
|
||||
|
||||
bad *badLines
|
||||
watchStop chan struct{}
|
||||
}
|
||||
@@ -85,6 +88,7 @@ func New(st *store.Store, limits Limits, worktreeRoot string) *Manager {
|
||||
live: map[string]*live{},
|
||||
rateLimits: map[api.AgentSessionVendor]map[string]any{},
|
||||
merges: map[string]string{},
|
||||
snaps: map[string]*snapState{},
|
||||
bad: newBadLines(),
|
||||
watchStop: make(chan struct{}),
|
||||
}
|
||||
@@ -565,6 +569,7 @@ func (m *Manager) ensureLive(ctx context.Context, sess api.AgentSession, task ap
|
||||
Hooks: map[string][]claude.HookMatcher{
|
||||
"UserPromptSubmit": {{Func: remindGuidance}},
|
||||
"Stop": {{Func: m.bounceProseQuestion(l)}},
|
||||
"PostToolUse": {{Func: m.snapshotAfterTool(l)}},
|
||||
},
|
||||
OnBadLine: func(line []byte, reason string) { m.recordBadLine(l, line, reason) },
|
||||
}
|
||||
@@ -588,6 +593,7 @@ func (m *Manager) ensureLive(ctx context.Context, sess api.AgentSession, task ap
|
||||
|
||||
m.live[sess.Id] = l
|
||||
go m.pump(l)
|
||||
go m.snapshotTimer(l)
|
||||
return l, nil
|
||||
}
|
||||
|
||||
@@ -712,6 +718,7 @@ func (m *Manager) handle(ctx context.Context, l *live, ev claude.Event) error {
|
||||
if sha != "" {
|
||||
payload["commit"] = sha
|
||||
}
|
||||
m.snapshotSoon(l, api.SnapshotTriggerTurnEnd)
|
||||
switch {
|
||||
case handoff:
|
||||
payload["handoff"] = true
|
||||
|
||||
Reference in New Issue
Block a user