This commit is contained in:
2026-06-22 08:55:57 +08:00
parent dbb87823e8
commit 6ade6e8fa9
325 changed files with 41131 additions and 855 deletions
+12
View File
@@ -42,8 +42,13 @@ type workspaceService struct {
clones CloneScheduler
dataDir string
fetchTimout time.Duration
indexHook IndexBuildHook
}
// SetIndexBuildHook injects the code-index enqueue callback (app wiring). On Sync
// the workspace marks prior runs stale and enqueues a fresh build at new HEAD.
func (s *workspaceService) SetIndexBuildHook(h IndexBuildHook) { s.indexHook = h }
// NewWorkspaceService 构造 WorkspaceService 实现。
func NewWorkspaceService(
repo Repository,
@@ -281,6 +286,13 @@ func (s *workspaceService) Sync(ctx context.Context, c Caller, wsID uuid.UUID) (
return nil, err
}
s.audit(writeCtx, &c.UserID, "workspace.sync", "workspace", wsID.String(), nil)
// Best-effort: re-index the main worktree at the new HEAD. The hook marks
// prior runs stale then enqueues a build (coalesced on commit). Never blocks.
if s.indexHook != nil {
if herr := s.indexHook(writeCtx, wsID, nil, ""); herr != nil {
s.audit(writeCtx, &c.UserID, "workspace.index_enqueue_failed", "workspace", wsID.String(), map[string]any{"err": herr.Error()})
}
}
return updated, nil
}