import { describe, expect, it } from 'bun:test'; import { isPlaceholderOpenCodeTitle } from './opencode-sessions'; // OpenCode names a session `New session - ` until it has titled it from the conversation, which it // does asynchronously. The strings below are real ones observed on 1.18.16 — both the placeholder and // the good title it was replaced by. describe('isPlaceholderOpenCodeTitle', () => { it('recognises the placeholder OpenCode uses before it has titled a session', () => { expect(isPlaceholderOpenCodeTitle('New session - 2026-08-10T15:44:17.178Z')).toBe(true); expect(isPlaceholderOpenCodeTitle('New session - 2026-08-10T12:41:02.757Z')).toBe(true); }); it('treats an absent or empty title as unnamed too', () => { expect(isPlaceholderOpenCodeTitle(undefined)).toBe(true); expect(isPlaceholderOpenCodeTitle('')).toBe(true); expect(isPlaceholderOpenCodeTitle(' ')).toBe(true); }); it('keeps a real title, including one that merely mentions a session', () => { // The title OpenCode actually gave a turn of ours, and the reason this is a pattern match rather // than a `startsWith('New session')`: a genuine title is allowed to begin with those words. expect(isPlaceholderOpenCodeTitle('Single color in oc-red2.png')).toBe(false); expect(isPlaceholderOpenCodeTitle('New session handling in the runner')).toBe(false); expect(isPlaceholderOpenCodeTitle('New session - what should it be called?')).toBe(false); }); });