MCPcopy Index your code
hub / github.com/Noumena-Network/code / saveWorktreeState

Function saveWorktreeState

src/utils/sessionStorage.ts:3069–3100  ·  view source on GitHub ↗
(
  worktreeSession: PersistedWorktreeSession | null,
)

Source from the content-addressed store, hash-verified

3067 * so --resume knows not to cd back into it.
3068 */
3069export function saveWorktreeState(
3070 worktreeSession: PersistedWorktreeSession | null,
3071): void {
3072 // Strip ephemeral fields (creationDurationMs, usedSparsePaths) that callers
3073 // may pass via full WorktreeSession objects — TypeScript structural typing
3074 // allows this, but we don't want them serialized to the transcript.
3075 const stripped: PersistedWorktreeSession | null = worktreeSession
3076 ? {
3077 originalCwd: worktreeSession.originalCwd,
3078 worktreePath: worktreeSession.worktreePath,
3079 worktreeName: worktreeSession.worktreeName,
3080 worktreeBranch: worktreeSession.worktreeBranch,
3081 originalBranch: worktreeSession.originalBranch,
3082 originalHeadCommit: worktreeSession.originalHeadCommit,
3083 sessionId: worktreeSession.sessionId,
3084 tmuxSessionName: worktreeSession.tmuxSessionName,
3085 hookBased: worktreeSession.hookBased,
3086 }
3087 : null
3088 const project = getProject()
3089 project.currentSessionWorktree = stripped
3090 // Write eagerly when the file already exists (mid-session enter/exit).
3091 // For --worktree startup, sessionFile is null — materializeSessionFile
3092 // will write it on the first message via reAppendSessionMetadata.
3093 if (project.sessionFile) {
3094 appendEntryToFile(project.sessionFile, {
3095 type: 'worktree-state',
3096 worktreeSession: stripped,
3097 sessionId: getSessionId(),
3098 })
3099 }
3100}
3101
3102/**
3103 * Extracts the session ID from a log.

Callers 4

restoreWorktreeForResumeFunction · 0.70
setupFunction · 0.50
clearConversationFunction · 0.50

Calls 3

getProjectFunction · 0.85
appendEntryToFileFunction · 0.85
getSessionIdFunction · 0.85

Tested by

no test coverage detected