Merge pull request #707 from cpdata/feat/auto-pull-config

Reviewed by dave (beads crew worker)
This commit is contained in:
Steve Yegge
2025-12-22 20:17:54 -08:00
committed by GitHub
9 changed files with 133 additions and 17 deletions

View File

@@ -300,6 +300,7 @@ type StatusResponse struct {
// Daemon configuration
AutoCommit bool `json:"auto_commit"` // Whether auto-commit is enabled
AutoPush bool `json:"auto_push"` // Whether auto-push is enabled
AutoPull bool `json:"auto_pull"` // Whether auto-pull is enabled (periodic remote sync)
LocalMode bool `json:"local_mode"` // Whether running in local-only mode (no git)
SyncInterval string `json:"sync_interval"` // Sync interval (e.g., "5s")
DaemonMode string `json:"daemon_mode"` // Sync mode: "poll" or "events"

View File

@@ -57,6 +57,7 @@ type Server struct {
// Daemon configuration (set via SetConfig after creation)
autoCommit bool
autoPush bool
autoPull bool
localMode bool
syncInterval string
daemonMode string
@@ -159,11 +160,12 @@ func (s *Server) MutationChan() <-chan MutationEvent {
}
// SetConfig sets the daemon configuration for status reporting
func (s *Server) SetConfig(autoCommit, autoPush, localMode bool, syncInterval, daemonMode string) {
func (s *Server) SetConfig(autoCommit, autoPush, autoPull, localMode bool, syncInterval, daemonMode string) {
s.mu.Lock()
defer s.mu.Unlock()
s.autoCommit = autoCommit
s.autoPush = autoPush
s.autoPull = autoPull
s.localMode = localMode
s.syncInterval = syncInterval
s.daemonMode = daemonMode

View File

@@ -280,6 +280,7 @@ func (s *Server) handleStatus(_ *Request) Response {
s.mu.RLock()
autoCommit := s.autoCommit
autoPush := s.autoPush
autoPull := s.autoPull
localMode := s.localMode
syncInterval := s.syncInterval
daemonMode := s.daemonMode
@@ -297,6 +298,7 @@ func (s *Server) handleStatus(_ *Request) Response {
ExclusiveLockHolder: lockHolder,
AutoCommit: autoCommit,
AutoPush: autoPush,
AutoPull: autoPull,
LocalMode: localMode,
SyncInterval: syncInterval,
DaemonMode: daemonMode,

View File

@@ -97,7 +97,7 @@ func TestStatusEndpointWithConfig(t *testing.T) {
server := NewServer(socketPath, store, tmpDir, dbPath)
// Set config before starting
server.SetConfig(true, true, false, "10s", "events")
server.SetConfig(true, true, true, false, "10s", "events")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -155,7 +155,7 @@ func TestStatusEndpointLocalMode(t *testing.T) {
server := NewServer(socketPath, store, tmpDir, dbPath)
// Set config for local mode
server.SetConfig(false, false, true, "5s", "poll")
server.SetConfig(false, false, false, true, "5s", "poll")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -284,7 +284,7 @@ func TestSetConfigConcurrency(t *testing.T) {
done := make(chan bool)
for i := 0; i < 10; i++ {
go func(n int) {
server.SetConfig(n%2 == 0, n%3 == 0, n%4 == 0, "5s", "events")
server.SetConfig(n%2 == 0, n%3 == 0, n%5 == 0, n%4 == 0, "5s", "events")
done <- true
}(i)
}