feat(sessions): add explicit per-session title locks (#2072)

* feat(sessions): add explicit per-session title locks

* fix(sessions): preserve title locks across rename entry points
This commit is contained in:
Ananovo
2026-10-28 12:14:48 +08:00
committed by GitHub
parent 328ddb0ee3
commit 577ab7546b
37 changed files with 787 additions and 99 deletions
@@ -31,6 +31,14 @@ function params(item: unknown, turnId = 'turn') { return { threadId: 'thread', t
function history(...items: unknown[]) { return { turns: [{ id: 'turn', status: 'completed', items }] }; }
describe('shared Codex titles', () => {
it('keeps a user lock on live tool completions and historical title projection', async () => {
const f = fixture()
f.update(metadata => ({ ...metadata, titleLocked: true }))
await f.projection.notification('item/completed', params(titleItem('locked', 'Agent')))
await f.projection.history(history(titleItem('old-locked', 'Historical')))
expect(f.metadata()).toMatchObject({ name: 'Manual name', titleLocked: true })
})
it('renames via metadata.name so a spawn name does not hide change_title', async () => {
const f = fixture();
const item = titleItem('title', ' Remote title ');
+1 -1
View File
@@ -63,7 +63,7 @@ export class SharedCodexProjection {
private applyDisplayRename(title: string, revision: number): void {
this.session.updateMetadata(metadata => {
if (revision !== this.titleRevision) return metadata;
if (revision !== this.titleRevision || metadata.titleLocked) return metadata;
const normalized = normalizeSessionDisplayTitle(title);
if (!normalized || metadata.name?.trim() === normalized) return metadata;
return { ...metadata, name: normalized };