session

package
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignMaintainer

func AssignMaintainer(ctx context.Context, sessionID, nameID int64) error

AssignMaintainer assigns a maintainer (ai_names.id) to a session (sessions.id). Uses UPSERT — replaces any existing assignment for that session.

func CreateOrGetSessionID

func CreateOrGetSessionID(ctx context.Context) (sessionID int64, err error)

CreateOrGetSessionID 获取或创建当前 context.ProjectRoot 的会话ID。 委托给 CreateOrGetSessionIDByPath。

func CreateOrGetSessionIDByPath added in v0.8.8

func CreateOrGetSessionIDByPath(ctx context.Context, projectPath string) (sessionID int64, err error)

CreateOrGetSessionIDByPath 获取或创建指定项目路径对应的会话ID。 如果该路径尚未有 session 行则自动创建。

func GetCurrentSessionID

func GetCurrentSessionID(ctx context.Context) (sessionID int64)

GetCurrentSessionID 获取当前会话ID(线程安全,仅初始化一次)

func RemoveProject added in v0.8.8

func RemoveProject(ctx context.Context, sessionID int64) error

RemoveProject removes a session (project) by ID. Deletes all associated data (session_names, memories, messages, notes, chimeins) before deleting the session itself. Returns an error if the session does not exist.

func ResetSessionID

func ResetSessionID()

ResetSessionID clears the cached session ID so the next call to GetCurrentSessionID will re-resolve against the current database. Intended for tests that switch database paths.

func UpdateProjectPath

func UpdateProjectPath(ctx context.Context, sessionID int64, newPath string) error

UpdateProjectPath updates the project_path for a given session. Returns an error if the session does not exist or the path is empty.

Types

type ProjectRow

type ProjectRow struct {
	ID           int64
	ProjectPath  string
	CreatedAt    string
	MaintainerCN string // e.g. "玻尔" or empty
	MaintainerEN string // e.g. "Bohr" or empty
	MaintainerID int64  // ai_names.id, 0 if none
}

ProjectRow represents a row from the sessions table.

func GetProjectInfo added in v0.8.8

func GetProjectInfo(ctx context.Context, projectPath string) ProjectRow

func ListProjects

func ListProjects(ctx context.Context) ([]ProjectRow, error)

ListProjects returns all sessions with their maintainer, ordered by ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL