mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
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:
@@ -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 ');
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user