(sessionId: string, name: string)
| 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. |
nothing calls this directly
no test coverage detected