@@ -34,6 +34,7 @@ afterEach(() => {
3434 cleanup ( ) ;
3535 vi . unstubAllGlobals ( ) ;
3636 vi . restoreAllMocks ( ) ;
37+ localStorage . clear ( ) ;
3738} ) ;
3839
3940const agent = ( config : Config = DEFAULT_CONFIG ) =>
@@ -49,10 +50,35 @@ const agent = (config: Config = DEFAULT_CONFIG) =>
4950// browser drops it, so the focus tests also check for no `disabled`.
5051
5152/** Applies the plugin to a stand-in context; sign-in runs until killed. */
52- function applied ( { loggedIn = true } = { } ) {
53+ function applied ( {
54+ loggedIn = true ,
55+ files = { } ,
56+ } : {
57+ loggedIn ?: boolean ;
58+ files ?: Record < string , string > ;
59+ } = { } ) {
5360 let type : AgentType < Config > | undefined ;
54- const spawn = vi . fn ( async ( _id : string , options : HostProcessOptions = { } ) => {
61+ const spawn = vi . fn ( async ( id : string , options : HostProcessOptions = { } ) => {
5562 const args = ( options . args ?? [ ] ) . join ( " " ) ;
63+ if ( id === "workspace" || id === "read" ) {
64+ const file = files [ args ] ;
65+ queueMicrotask ( ( ) =>
66+ id === "workspace"
67+ ? options . onStdout ?.( "/Users/me/.buzz\n" )
68+ : file === undefined
69+ ? options . onStderr ?.( `base64: ${ args } : No such file or directory` )
70+ : options . onStdout ?.( btoa ( file ) ) ,
71+ ) ;
72+ const code = id === "read" && file === undefined ? 1 : 0 ;
73+ return {
74+ write : async ( ) => undefined ,
75+ end : async ( ) => undefined ,
76+ kill : async ( ) => undefined ,
77+ exited : new Promise < number > ( ( resolve ) =>
78+ setTimeout ( ( ) => resolve ( code ) , 0 ) ,
79+ ) ,
80+ } ;
81+ }
5682 let kill : ( ) => void = ( ) => undefined ;
5783 const exited = new Promise < number | null > ( ( resolve ) => {
5884 if ( args === "auth login" ) kill = ( ) => resolve ( null ) ;
@@ -90,7 +116,7 @@ function applied({ loggedIn = true } = {}) {
90116 apply ( ctx as never ) ;
91117 return { type, spawn } ;
92118}
93- function installed ( options ?: { loggedIn ?: boolean } ) {
119+ function installed ( options ?: Parameters < typeof applied > [ 0 ] ) {
94120 const { type, spawn } = applied ( options ) ;
95121 if ( ! type ) throw new Error ( "no type registered" ) ;
96122 return { type, spawn } ;
@@ -219,6 +245,60 @@ it("keeps Save focused while saving, and lets a failed save be retried", async (
219245 await waitFor ( ( ) => expect ( screen . queryByRole ( "alert" ) ) . toBeNull ( ) ) ;
220246} ) ;
221247
248+ it ( "lists saved conversations and shows one's transcript, or that it is gone" , async ( ) => {
249+ const thread = `channel/${ "e" . repeat ( 64 ) } ` ;
250+ localStorage . setItem (
251+ "buzz.claude-code.sessions.v1" ,
252+ JSON . stringify ( {
253+ [ agent ( ) . pubkey ] : {
254+ channel : { id : "deleted" , seen : 0 , at : 1 } ,
255+ [ thread ] : { id : "kept" , seen : 0 , at : 2 } ,
256+ } ,
257+ } ) ,
258+ ) ;
259+ const transcript = [
260+ JSON . stringify ( {
261+ type : "user" ,
262+ uuid : "u1" ,
263+ timestamp : "2026-10-09T10:00:00Z" ,
264+ message : {
265+ content :
266+ "<buzz-event>\nEvent ID: e\nContent: what changed?\nTags: []\n</buzz-event>" ,
267+ } ,
268+ } ) ,
269+ JSON . stringify ( {
270+ type : "assistant" ,
271+ uuid : "u2" ,
272+ timestamp : "2026-10-09T10:00:05Z" ,
273+ message : { content : [ { type : "text" , text : "Two files." } ] } ,
274+ } ) ,
275+ ] . join ( "\n" ) ;
276+ const Claude = tab (
277+ installed ( { files : { "./-Users-me--buzz/kept.jsonl" : transcript } } ) . type ,
278+ 0 ,
279+ ) ;
280+ render ( < Claude agent = { agent ( ) } save = { vi . fn ( ) } /> ) ;
281+ const user = userEvent . setup ( ) ;
282+ const rows = screen . getAllByRole ( "listitem" ) ;
283+ expect ( rows . map ( ( row ) => row . textContent ) ) . toEqual ( [
284+ expect . stringContaining ( "channel · thread eeeeeeee" ) ,
285+ expect . stringContaining ( "channel · channel" ) ,
286+ ] ) ;
287+ const viewButton = ( index : number ) =>
288+ screen . getAllByRole ( "button" , { name : "View transcript" } ) [
289+ index
290+ ] as HTMLElement ;
291+ await user . click ( viewButton ( 0 ) ) ;
292+ expect ( await screen . findByText ( "what changed?" ) ) . toBeVisible ( ) ;
293+ expect ( screen . getByText ( "Two files." ) ) . toBeVisible ( ) ;
294+ await user . click ( screen . getByRole ( "button" , { name : "Back" } ) ) ;
295+ await user . click ( viewButton ( 1 ) ) ;
296+ expect (
297+ await screen . findByText ( / n o t r a n s c r i p t f o r t h i s c o n v e r s a t i o n / ) ,
298+ ) . toBeVisible ( ) ;
299+ expect ( screen . queryByRole ( "alert" ) ) . toBeNull ( ) ;
300+ } ) ;
301+
222302it ( "starts a new agent from a model and instructions, keeping the rest" , async ( ) => {
223303 const Create = installed ( ) . type . Create ;
224304 if ( ! Create ) throw new Error ( "no create view" ) ;
0 commit comments