@@ -10,7 +10,11 @@ import { AsyncResult } from "effect/reactivity";
1010import { expect , it } from "vite-plus/test" ;
1111
1212import { DraftId , type DraftThreadState , useComposerDraftStore } from "../../composerDraftStore" ;
13- import { terminalContextReference } from "../../lib/composerContextRecords" ;
13+ import {
14+ environmentContextRecord ,
15+ environmentContextReference ,
16+ terminalContextReference ,
17+ } from "../../lib/composerContextRecords" ;
1418import { formatInlineContextReference } from "../../lib/composerContextReferences" ;
1519import type { TerminalContextDraft } from "../../lib/terminalContext" ;
1620import { snapshotComposerSend } from "../ChatView.logic" ;
@@ -35,21 +39,30 @@ it("restores an unsent message after a newer draft without replacing it", () =>
3539 const store = useComposerDraftStore . getState ( ) ;
3640 store . setPrompt ( target , "Newer draft" ) ;
3741 store . addImages ( target , [ image ( "newer" ) ] ) ;
42+ const newerEnvironment = environmentContextRecord ( EnvironmentId . make ( "newer-host" ) , "Newer host" ) ;
43+ const unsentEnvironment = environmentContextRecord (
44+ EnvironmentId . make ( "unsent-host" ) ,
45+ "Unsent host" ,
46+ ) ;
47+ store . setEnvironmentContexts ( target , [ newerEnvironment ] ) ;
48+ const newerPrompt = store . getComposerDraft ( target ) ?. prompt ;
3849 const unsent = snapshotComposerSend ( {
39- prompt : " Unsent message" ,
50+ prompt : ` Unsent message ${ formatInlineContextReference ( environmentContextReference ( unsentEnvironment ) ) } ` ,
4051 images : [ image ( "unsent" ) ] ,
4152 files : [ ] ,
4253 terminalContexts : [ ] ,
4354 sendableTerminalContexts : [ ] ,
4455 previewAnnotations : [ ] ,
4556 reviewComments : [ ] ,
4657 threadContexts : [ ] ,
58+ environmentContexts : [ unsentEnvironment ] ,
4759 } ) ;
4860
4961 restoreComposerDraft ( target , unsent ) ;
5062
5163 const draft = store . getComposerDraft ( target ) ;
52- expect ( draft ?. prompt ) . toBe ( "Newer draft\n\nUnsent message" ) ;
64+ expect ( draft ?. environmentContexts ) . toEqual ( [ newerEnvironment , unsentEnvironment ] ) ;
65+ expect ( draft ?. prompt . trim ( ) ) . toBe ( `${ newerPrompt ?. trimEnd ( ) } \n\n${ unsent . messageText } ` . trim ( ) ) ;
5366 expect ( draft ?. images . map ( ( attachment ) => attachment . id ) ) . toEqual ( [ "newer" , "unsent" ] ) ;
5467} ) ;
5568
@@ -72,6 +85,7 @@ it("leaves a full newer draft untouched when the unsent attachments do not fit",
7285 previewAnnotations : [ ] ,
7386 reviewComments : [ ] ,
7487 threadContexts : [ ] ,
88+ environmentContexts : [ ] ,
7589 } ) ;
7690
7791 expect ( restoreComposerDraft ( target , unsent ) ) . toBe ( false ) ;
@@ -110,6 +124,7 @@ it("points a restored terminal reference at the newer draft's copy of the same s
110124 previewAnnotations : [ ] ,
111125 reviewComments : [ ] ,
112126 threadContexts : [ ] ,
127+ environmentContexts : [ ] ,
113128 } ) ;
114129
115130 expect ( restoreComposerDraft ( target , unsent ) ) . toBe ( true ) ;
0 commit comments