88 type ScheduledTask ,
99 ThreadId ,
1010} from "@t3tools/contracts" ;
11- import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/models" ;
1211import { afterEach , describe , expect , it , vi } from "vite-plus/test" ;
1312
1413import type {
@@ -24,9 +23,6 @@ import {
2423 matchesScheduledTaskScope ,
2524 scheduleFromDraft ,
2625 taskToDraft ,
27- changeDraftProject ,
28- moveDraftToThread ,
29- scheduledTaskDestinationThreads ,
3026 unbindDraftFromThread ,
3127} from "./scheduledTasksSettings.logic" ;
3228
@@ -177,97 +173,17 @@ describe("editing scheduled task branch settings", () => {
177173} ) ;
178174
179175describe ( "scheduled task destination" , ( ) => {
180- const rootBound = taskToDraft ( {
181- ...legacyTask ,
182- threadId : ThreadId . make ( "thread:bound" ) ,
183- workspaceStrategy : { type : "root" } ,
184- } ) ;
185-
186- it ( "moves to a thread and takes on its project" , ( ) => {
187- const moved = moveDraftToThread ( rootBound , {
188- id : ThreadId . make ( "thread:elsewhere" ) ,
189- projectId : ProjectId . make ( "project:elsewhere" ) ,
190- } ) ;
191- expect ( moved ) . toMatchObject ( { threadId : "thread:elsewhere" , projectId : "project:elsewhere" } ) ;
192- const fromNewThreads = { ...rootBound , threadId : "" , threadMode : "new_thread" as const } ;
193- expect (
194- moveDraftToThread ( fromNewThreads , {
195- id : ThreadId . make ( "thread:elsewhere" ) ,
196- projectId : ProjectId . make ( "project:elsewhere" ) ,
197- } ) . threadMode ,
198- ) . toBe ( "continue" ) ;
199- } ) ;
200-
201176 it ( "unbinding leaves the shared checkout for a new worktree from the remote" , ( ) => {
202- expect ( unbindDraftFromThread ( rootBound ) ) . toMatchObject ( {
203- threadId : "" ,
204- workspaceMode : "worktree" ,
205- startFromOrigin : true ,
206- } ) ;
207- } ) ;
208-
209- it ( "unbinding keeps a workspace that was chosen for new threads" , ( ) => {
210- const checkout = taskToDraft ( {
177+ const rootBound = taskToDraft ( {
211178 ...legacyTask ,
212179 threadId : ThreadId . make ( "thread:bound" ) ,
213- workspaceStrategy : { type : "existing_worktree" , worktreePath : "/work/checkout " } ,
180+ workspaceStrategy : { type : "root " } ,
214181 } ) ;
215- expect ( unbindDraftFromThread ( checkout ) ) . toEqual ( { ...checkout , threadId : "" } ) ;
216- } ) ;
217-
218- it ( "leaves an unbound draft's project-checkout workspace alone" , ( ) => {
219- const unbound = { ...rootBound , threadId : "" } ;
220- expect ( unbindDraftFromThread ( unbound ) ) . toBe ( unbound ) ;
221- } ) ;
222-
223- it ( "changing the project clears a binding the new project cannot hold" , ( ) => {
224- expect ( changeDraftProject ( rootBound , ProjectId . make ( "project:new" ) ) ) . toMatchObject ( {
225- projectId : "project:new" ,
182+ expect ( unbindDraftFromThread ( rootBound ) ) . toMatchObject ( {
226183 threadId : "" ,
227184 workspaceMode : "worktree" ,
185+ startFromOrigin : true ,
228186 } ) ;
229- expect ( changeDraftProject ( rootBound , rootBound . projectId ) ) . toBe ( rootBound ) ;
230- } ) ;
231-
232- it ( "offers open top-level threads of the project, newest first, without the current one" , ( ) => {
233- const projectId = ProjectId . make ( "project:wanted" ) ;
234- const thread = ( id : string , overrides : object = { } ) =>
235- ( {
236- id : ThreadId . make ( id ) ,
237- environmentId : laptopId ,
238- projectId,
239- title : id ,
240- archivedAt : null ,
241- updatedAt : "2026-11-01T00:00:00.000Z" ,
242- lineage : { relationshipToParent : null , parentThreadId : null , rootThreadId : id } ,
243- ...overrides ,
244- } ) as unknown as EnvironmentThreadShell ;
245- const threads = [
246- thread ( "older" ) ,
247- thread ( "newer docs" , { updatedAt : "2026-11-02T00:00:00.000Z" } ) ,
248- thread ( "current" ) ,
249- thread ( "archived" , { archivedAt : "2026-11-01T00:00:00.000Z" } ) ,
250- thread ( "subagent" , {
251- lineage : {
252- relationshipToParent : "subagent" ,
253- parentThreadId : "older" ,
254- rootThreadId : "older" ,
255- } ,
256- } ) ,
257- thread ( "other project" , { projectId : ProjectId . make ( "project:other" ) } ) ,
258- thread ( "other environment" , { environmentId : serverId } ) ,
259- ] ;
260- const target = {
261- environmentId : laptopId ,
262- projectId,
263- currentThreadId : ThreadId . make ( "current" ) ,
264- } ;
265- expect (
266- scheduledTaskDestinationThreads ( threads , { ...target , query : "" } ) . map ( ( { id } ) => id ) ,
267- ) . toEqual ( [ "newer docs" , "older" ] ) ;
268- expect (
269- scheduledTaskDestinationThreads ( threads , { ...target , query : " DOCS" } ) . map ( ( { id } ) => id ) ,
270- ) . toEqual ( [ "newer docs" ] ) ;
271187 } ) ;
272188} ) ;
273189
0 commit comments