MCPcopy Create free account
hub / github.com/tiann/hapi / renameSession

Method renameSession

hub/src/sync/sessionCache.ts:487–513  ·  view source on GitHub ↗
(sessionId: string, name: string)

Source from the content-addressed store, hash-verified

485 }
486
487 async renameSession(sessionId: string, name: string): Promise<void> {
488 const session = this.sessions.get(sessionId)
489 if (!session) {
490 throw new Error('Session not found')
491 }
492
493 const currentMetadata = session.metadata ?? { path: '', host: '' }
494 const newMetadata = { ...currentMetadata, name }
495
496 const result = this.store.sessions.updateSessionMetadata(
497 sessionId,
498 newMetadata,
499 session.metadataVersion,
500 session.namespace,
501 { touchUpdatedAt: false }
502 )
503
504 if (result.result === 'error') {
505 throw new Error('Failed to update session metadata')
506 }
507
508 if (result.result === 'version-mismatch') {
509 throw new Error('Session was modified concurrently. Please try again.')
510 }
511
512 this.refreshSession(sessionId)
513 }
514
515 /**
516 * Clear archive-related metadata on an archived session so it can be resumed.

Callers

nothing calls this directly

Calls 3

refreshSessionMethod · 0.95
getMethod · 0.80
updateSessionMetadataMethod · 0.80

Tested by

no test coverage detected