@@ -7,8 +7,10 @@ import { SessionTable, MessageTable, PartTable } from "../../session/session.sql
77import { InstanceRef } from "@/effect/instance-ref"
88import { ShareNext } from "@/share/share-next"
99import { EOL } from "os"
10+ import path from "path"
1011import { AppFileSystem } from "@opencode-ai/core/filesystem"
1112import { Effect , Schema } from "effect"
13+ import type { InstanceContext } from "@/project/instance-context"
1214
1315const decodeMessageInfo = Schema . decodeUnknownSync ( MessageV2 . Info )
1416const decodePart = Schema . decodeUnknownSync ( MessageV2 . Part )
@@ -89,11 +91,11 @@ export const ImportCommand = effectCmd({
8991 handler : Effect . fn ( "Cli.import" ) ( function * ( args ) {
9092 const ctx = yield * InstanceRef
9193 if ( ! ctx ) return yield * Effect . die ( "InstanceRef not provided" )
92- return yield * runImport ( args . file , ctx . project . id )
94+ return yield * runImport ( args . file , ctx )
9395 } ) ,
9496} )
9597
96- const runImport = Effect . fn ( "Cli.import.body" ) ( function * ( file : string , projectID : string ) {
98+ const runImport = Effect . fn ( "Cli.import.body" ) ( function * ( file : string , ctx : InstanceContext ) {
9799 const share = yield * ShareNext . Service
98100 const fs = yield * AppFileSystem . Service
99101
@@ -168,14 +170,19 @@ const runImport = Effect.fn("Cli.import.body")(function* (file: string, projectI
168170
169171 const info = Schema . decodeUnknownSync ( Session . Info ) ( {
170172 ...exportData . info ,
171- projectID,
173+ projectID : ctx . project . id ,
174+ directory : ctx . directory ,
175+ path : path . relative ( path . resolve ( ctx . worktree ) , ctx . directory ) . replaceAll ( "\\" , "/" ) ,
172176 } ) as Session . Info
173177 const row = Session . toRow ( info )
174178 Database . use ( ( db ) =>
175179 db
176180 . insert ( SessionTable )
177181 . values ( row )
178- . onConflictDoUpdate ( { target : SessionTable . id , set : { project_id : row . project_id } } )
182+ . onConflictDoUpdate ( {
183+ target : SessionTable . id ,
184+ set : { project_id : row . project_id , directory : row . directory , path : row . path } ,
185+ } )
179186 . run ( ) ,
180187 )
181188
0 commit comments