@@ -690,22 +690,60 @@ func TestSessionExport_AiderVirtualPathStreamsOnlySelectedRun(t *testing.T) {
690690 require .NoError (t , os .WriteFile (
691691 history , []byte ("ignored preamble\n " + run0 + run1 + run2 ), 0o600 ,
692692 ))
693+ rawID , ok := parser .AiderRawIDAt (history , 1 )
694+ require .True (t , ok , "run 1 raw ID" )
693695
694- seedSessionWithOpts (t , dataDir , "s- aider" , "repo" ,
696+ seedSessionWithOpts (t , dataDir , "aider:" + rawID , "repo" ,
695697 func (s * db.Session ) {
696698 s .Agent = string (parser .AgentAider )
697699 vp := parser .AiderVirtualPath (history , 1 )
698700 s .FilePath = & vp
699701 })
700702
701703 out , err := executeCommand (newRootCommand (),
702- "session" , "export" , "s- aider" )
704+ "session" , "export" , "aider:" + rawID )
703705 require .NoError (t , err )
704706 assert .Equal (t , run1 , out )
705707 assert .NotContains (t , out , "first prompt" )
706708 assert .NotContains (t , out , "third prompt" )
707709}
708710
711+ func TestSessionExport_AiderStaleIndexReResolvesBySessionID (t * testing.T ) {
712+ dataDir := t .TempDir ()
713+ t .Setenv ("AGENTSVIEW_DATA_DIR" , dataDir )
714+
715+ repo := filepath .Join (t .TempDir (), "repo" )
716+ require .NoError (t , os .MkdirAll (repo , 0o755 ))
717+ history := filepath .Join (repo , parser .AiderHistoryFileName ())
718+ run0 := "# aider chat started at 2026-06-09 14:01:00\n " +
719+ "#### first prompt\n answer one\n "
720+ run1 := "# aider chat started at 2026-06-09 15:30:00\n " +
721+ "#### second prompt\n answer two\n "
722+ require .NoError (t , os .WriteFile (history , []byte (run0 + run1 ), 0o600 ))
723+ rawID , ok := parser .AiderRawIDAt (history , 1 )
724+ require .True (t , ok , "run 1 raw ID" )
725+
726+ seedSessionWithOpts (t , dataDir , "aider:" + rawID , "repo" ,
727+ func (s * db.Session ) {
728+ s .Agent = string (parser .AgentAider )
729+ vp := parser .AiderVirtualPath (history , 1 )
730+ s .FilePath = & vp
731+ })
732+
733+ inserted := "# aider chat started at 2026-06-09 13:00:00\n " +
734+ "#### inserted prompt\n inserted answer\n "
735+ require .NoError (t , os .WriteFile (
736+ history , []byte (inserted + run0 + run1 ), 0o600 ,
737+ ))
738+
739+ out , err := executeCommand (newRootCommand (),
740+ "session" , "export" , "aider:" + rawID )
741+ require .NoError (t , err )
742+ assert .Equal (t , run1 , out )
743+ assert .NotContains (t , out , "inserted prompt" )
744+ assert .NotContains (t , out , "first prompt" )
745+ }
746+
709747func TestSessionExport_FailsWhenSourceMissing (t * testing.T ) {
710748 dataDir := t .TempDir ()
711749 t .Setenv ("AGENTSVIEW_DATA_DIR" , dataDir )
0 commit comments