Expose storage usage and safe persisted age or size retention
This commit is contained in:
@@ -107,6 +107,12 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
go runs.sizeLoop()
|
||||
}
|
||||
}
|
||||
var storage *storageManager
|
||||
if runs != nil {
|
||||
storage = newStorageManager(runs)
|
||||
runs.schedulerWG.Add(1)
|
||||
go storage.loop(ctx)
|
||||
}
|
||||
// chat_sessions lists the operator's own recorded sessions. Prefer an
|
||||
// injected registry; otherwise derive it from the store. With neither, the
|
||||
// handler fails closed to an empty list.
|
||||
@@ -244,7 +250,27 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
}(request)
|
||||
continue
|
||||
}
|
||||
if handleChat(connCtx, request, options.Chat, hub, registry, clientID, write) {
|
||||
// Prevent a new operator workspace admission racing a worktree
|
||||
// removal. Ordinary reads/prompts do not wait for storage scans.
|
||||
admission := storage != nil && (request.Type == protocol.ChatCreate || request.Type == protocol.ChatAdopt)
|
||||
if admission {
|
||||
storage.workspaceMu.RLock()
|
||||
}
|
||||
handledChat := handleChat(connCtx, request, options.Chat, hub, registry, clientID, write)
|
||||
if admission {
|
||||
storage.workspaceMu.RUnlock()
|
||||
}
|
||||
if handledChat {
|
||||
continue
|
||||
}
|
||||
if isStorageRequest(request.Type) {
|
||||
if storage == nil {
|
||||
_ = write(protocol.Message{Type: protocol.Error, ID: request.ID, Error: "storage management unavailable: no execution store"})
|
||||
} else {
|
||||
// Disk/Git inventory must never stall chat permissions/prompts
|
||||
// arriving on this same persistent connection.
|
||||
storage.dispatch(connCtx, request, write)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if handleDirectoryListing(request, write) {
|
||||
|
||||
Reference in New Issue
Block a user