fix(sync): keep session renames stable (#2043)

* fix(sync): keep session renames stable

* fix(sync): clarify rename mirror flow

* fix(sync): clarify archive comment

---------

Co-authored-by: bashrusakh <bashrusakh@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
Leonid
2026-07-11 15:19:24 +03:00
committed by GitHub
co-authored by bashrusakh Bohdan Triapitsyn
parent 9bfc5bf0be
commit d5745aaac9
9 changed files with 234 additions and 43 deletions
+12 -2
View File
@@ -161,9 +161,9 @@ export function getSessionLastAssistantModel(sessionId: string): { providerID: s
}
}
function updateLiveSession(session: Session, directory?: string): void {
function updateLiveSession(session: Session, directory?: string): boolean {
const stores = _childStores
if (!stores) return
if (!stores) return false
const candidates = directory
? [[directory, stores.getChild(directory)] as const]
@@ -178,8 +178,17 @@ function updateLiveSession(session: Session, directory?: string): void {
const next = [...current]
next[index] = mergeSessionDirectoryMetadata(session, current[index])
store.setState({ session: next })
return true
}
return false
}
export function mirrorSessionIntoLiveStores(session: Session, directory?: string): void {
if (directory && updateLiveSession(session, directory)) {
return
}
updateLiveSession(session)
}
function dir() {
@@ -624,6 +633,7 @@ export async function updateSessionTitle(sessionId: string, title: string): Prom
const sessionDirectory = getSessionDirectory(sessionId)
const session = await opencodeClient.updateSession(sessionId, { title }, sessionDirectory)
useGlobalSessionsStore.getState().upsertSession(session)
mirrorSessionIntoLiveStores(session, sessionDirectory)
}
export async function shareSession(sessionId: string): Promise<Session | null> {