import { expect,test } from 'bun:test'; import { resolveSessionIdentity,resumeHint } from './identity.js';
test('uses session name and tmux',()=>{const x=resolveSessionIdentity(5,{readProc:()=>null,readSessionState:()=>({sessionId:'abcdefgh',name:'run',cwd:'/x/.worktrees/slug',tmux:'work:1'}),findWorkspace:()=>null,hostname:()=> 'host'});expect(x).toMatchObject({name:'run',terminal:'tmux:work',workspace:null})});
test('synthesizes absent state',()=>{const x=resolveSessionIdentity(5,{readProc:()=>null,readSessionState:()=>null,findWorkspace:()=>null,hostname:()=> 'h'});expect(x.sessionId).toBe('unknown-5')});
test('labels an unresolved session honestly instead of using the home directory name',()=>{const x=resolveSessionIdentity(5,{readProc:()=>null,readSessionState:()=>({cwd:'/home/user'}),findWorkspace:()=>null,hostname:()=> 'h'});expect(x).toMatchObject({name:'unresolved session',nameSource:'unresolved'})});
test('resumeHint renders a copy-pasteable resume command for a normal session',()=>{const i={sessionId:'13d7cf00-aaaa-bbbb-cccc-dddddddddddd',name:'memory-organizer',nameSource:'session-name' as const,terminal:null,workspace:null,cwd:'/home/user/Projects/press-zone',host:'h'};expect(resumeHint(i)).toBe('resume: cd /home/user/Projects/press-zone && claude --resume 13d7cf00-aaaa-bbbb-cccc-dddddddddddd')});
test('resumeHint degrades honestly instead of inventing a session id',()=>{const i={sessionId:'unknown-99',name:'unresolved session',nameSource:'unresolved' as const,terminal:null,workspace:null,cwd:'/home/user/Projects/press-zone',host:'h'};const hint=resumeHint(i);expect(hint).toBe('directory: /home/user/Projects/press-zone');expect(hint).not.toContain('--resume')});
