@@ -2,7 +2,12 @@ import { PrimaryConnectionTarget } from "@t3tools/client-runtime/connection";
22import * as Option from "effect/Option" ;
33import type { EnvironmentPresentation } from "../../state/environments" ;
44import type { ServerProvider } from "@t3tools/contracts" ;
5- import { scopeProjectRef } from "@t3tools/client-runtime/environment" ;
5+ import {
6+ scopedThreadKey ,
7+ scopeProjectRef ,
8+ scopeThreadRef ,
9+ } from "@t3tools/client-runtime/environment" ;
10+ import { createModelSelection } from "@t3tools/shared/model" ;
611import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings" ;
712import {
813 EnvironmentId ,
@@ -15,6 +20,8 @@ import { expect, it, vi } from "vite-plus/test";
1520import { act , render } from "../../../test/render" ;
1621import { DraftId , useComposerDraftStore } from "../../composerDraftStore" ;
1722import { useDraftEnvironmentRouting } from "./useDraftEnvironmentRouting" ;
23+ import { appAtomRegistry } from "../../rpc/atomRegistry" ;
24+ import { draftFanoutSelectionsAtom } from "./chatViewSend" ;
1825
1926const resources = vi . hoisted ( ( ) => ( {
2027 refreshSelection : vi . fn < ( ids : readonly EnvironmentId [ ] ) => Promise < EnvironmentId | null > > ( ) ,
@@ -134,6 +141,18 @@ function Harness({
134141
135142it ( "refreshes a stored automatic choice before sending an unsent draft" , async ( ) => {
136143 const { a, b, draftId, input, store } = setup ( ) ;
144+ const selections = [ "model-a" , "model-b" ] . map ( ( model ) =>
145+ createModelSelection ( ProviderInstanceId . make ( "codex" ) , model ) ,
146+ ) ;
147+ const threadId = input . draftThread ! . threadId ;
148+ const destinationSelections = draftFanoutSelectionsAtom (
149+ scopedThreadKey ( scopeThreadRef ( b , threadId ) ) ,
150+ ) ;
151+ appAtomRegistry . set ( destinationSelections , null ) ;
152+ appAtomRegistry . set (
153+ draftFanoutSelectionsAtom ( scopedThreadKey ( scopeThreadRef ( a , threadId ) ) ) ,
154+ selections ,
155+ ) ;
137156 store . setDraftThreadContext ( draftId , {
138157 branch : "main" ,
139158 envMode : "worktree" ,
@@ -152,6 +171,7 @@ it("refreshes a stored automatic choice before sending an unsent draft", async (
152171 envMode : "worktree" ,
153172 } ) ;
154173 expect ( store . getComposerDraft ( draftId ) ?. prompt ) . toBe ( "Keep this prompt" ) ;
174+ expect ( appAtomRegistry . get ( destinationSelections ) ) . toEqual ( selections ) ;
155175} ) ;
156176
157177it . each ( [ "manual" , "attachments" , "promoted" ] as const ) (
0 commit comments