fix: start system default sync channels by default
Create and restart paths enable IsSystemDefault channels; SyncPage auto-starts after save. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -73,7 +73,7 @@ func (s *FileStore) EnsureSystemDefaultChannel(opts DefaultChannelOpts) (Channel
|
||||
ch := Channel{
|
||||
TenantID: opts.TenantID,
|
||||
Name: name,
|
||||
Enabled: false, // 默认同步通道供 agent push 落点;不启本地 outbox 轮询
|
||||
Enabled: true, // 默认运行中:可收 agent push,并预热 remote
|
||||
Direction: DirLocalToRemote,
|
||||
ConflictPolicy: PolicyLWWSource,
|
||||
IsSystemDefault: true,
|
||||
@@ -107,3 +107,22 @@ func ResolveOnlineDBID(explicit, channelID string) string {
|
||||
}
|
||||
return strings.TrimSpace(channelID)
|
||||
}
|
||||
|
||||
// EnsureAndStartSystemDefaultChannel 创建/复用公司默认同步通道,并确保处于运行中(Enabled + runner)。
|
||||
func (m *Manager) EnsureAndStartSystemDefaultChannel(opts DefaultChannelOpts) (Channel, error) {
|
||||
if m == nil || m.store == nil {
|
||||
return Channel{}, fmt.Errorf("dbsync not enabled")
|
||||
}
|
||||
ch, err := m.store.EnsureSystemDefaultChannel(opts)
|
||||
if err != nil {
|
||||
return Channel{}, err
|
||||
}
|
||||
if err := m.StartChannel(ch.ID); err != nil {
|
||||
return ch, fmt.Errorf("start default channel: %w", err)
|
||||
}
|
||||
if updated, err := m.store.GetChannel(ch.ID); err == nil {
|
||||
return *updated, nil
|
||||
}
|
||||
ch.Enabled = true
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ func (m *Manager) StartAll(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
for _, ch := range list {
|
||||
if ch.Enabled {
|
||||
// 公司默认同步通道默认运行中(即使历史记录曾为 Enabled=false)
|
||||
if ch.Enabled || ch.IsSystemDefault {
|
||||
_ = m.StartChannel(ch.ID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user