Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion internal/app/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

tea "github.com/charmbracelet/bubbletea"

"neo-code/internal/checkpoint"
"neo-code/internal/config"
configstate "neo-code/internal/config/state"
agentcontext "neo-code/internal/context"
Expand Down Expand Up @@ -230,8 +231,37 @@ func BuildGatewayServerDeps(ctx context.Context, opts BootstrapOptions) (Runtime
))
}

// Checkpoint 基础设施:影子仓库 + SQLite checkpoint 存储
// 复用 sessionStore 的 *sql.DB 连接,避免 Windows 上多连接文件锁定。
sessionDB := sessionStore.DB()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionStore.DB() is still nil until the store has performed its first ensureDB-backed operation, and BuildGatewayServerDeps has not touched the store yet. On a fresh startup this leaves checkpointStore unset, so checkpoint wiring/repair never runs and the whole feature is silently disabled. Please open the DB explicitly here or fall back to constructing the checkpoint store from DatabasePath(...).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/code 修复

Copy link
Copy Markdown

@fennoai fennoai Bot May 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复 internal/app/bootstrap.go 冷启动时 sessionStore.DB() 仍为 nil 导致 checkpoint store 未初始化的问题。

本次修改:

  • BuildGatewayServerDeps 现在会默认按 session.DatabasePath(...) 构造 checkpoint store,避免冷启动时整条 checkpoint 链路被静默跳过。
  • 如果 session store 已经打开了 SQLite 连接,仍然优先复用这条连接,保持原有的共享连接路径。
  • 新增回归测试 TestBuildGatewayServerDepsInitializesCheckpointStoreOnFreshStartup,验证 fresh startup 下 runtime 的 ListCheckpoints 能正常工作。

验证:

  • go test ./internal/app -run 'TestBuildGatewayServerDepsInitializesCheckpointStoreOnFreshStartup|TestBuildRuntimeUsesWorkdirOverride'

代码已推送到当前工作分支,并同步创建了 fork 侧 PR:https://github.com/phantom5099/neo-code/pull/70

View job run

var checkpointStore *checkpoint.SQLiteCheckpointStore
if sessionDB != nil {
checkpointStore = checkpoint.NewSQLiteCheckpointStoreWithDB(sessionDB)
}
if gitAvail, _ := checkpoint.CheckGitAvailability(ctx); gitAvail {
projectDir := agentsession.HashWorkspaceRoot(cfg.Workdir)
shadowDir := filepath.Join(sharedDeps.ConfigManager.BaseDir(), "projects", projectDir)
shadowRepo := checkpoint.NewShadowRepo(shadowDir, cfg.Workdir)
if err := shadowRepo.Init(ctx); err != nil {
log.Printf("checkpoint shadow repo init warning: %v", err)
} else if checkpointStore != nil {
runtimeSvc.SetCheckpointDependencies(checkpointStore, shadowRepo)
}
} else if checkpointStore != nil {
// 降级模式:git 不可用时仍可创建 session-only checkpoint
runtimeSvc.SetCheckpointDependencies(checkpointStore, nil)
}
// 启动时修复残留的 creating 状态 checkpoint
if checkpointStore != nil {
if repaired, err := checkpointStore.RepairCreatingCheckpoints(ctx); err != nil {
log.Printf("checkpoint repair warning: %v", err)
} else if repaired > 0 {
log.Printf("checkpoint repair: fixed %d stale checkpoints", repaired)
}
}

runtimeImpl := agentruntime.Runtime(runtimeSvc)
closeFns := []func() error{toolsCleanup, sessionStore.Close}
closeFns := []func() error{toolsCleanup, checkpointStore.Close, sessionStore.Close}

needCleanup = false

Expand Down
Loading
Loading