File tree Expand file tree Collapse file tree 4 files changed +37
-0
lines changed
packages/opencode/src/cli/cmd/tui Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export type HomeRoute = {
1010export type SessionRoute = {
1111 type : "session"
1212 sessionID : string
13+ initialPrompt ?: PromptInfo
1314}
1415
1516export type Route = HomeRoute | SessionRoute
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Locale } from "@/util/locale"
66import { useSDK } from "@tui/context/sdk"
77import { useRoute } from "@tui/context/route"
88import { useDialog } from "../../ui/dialog"
9+ import type { PromptInfo } from "@tui/component/prompt/history"
910
1011export function DialogForkFromTimeline ( props : { sessionID : string ; onMove : ( messageID : string ) => void } ) {
1112 const sync = useSync ( )
@@ -35,9 +36,21 @@ export function DialogForkFromTimeline(props: { sessionID: string; onMove: (mess
3536 sessionID : props . sessionID ,
3637 messageID : message . id ,
3738 } )
39+ const parts = sync . data . part [ message . id ] ?? [ ]
40+ const initialPrompt = parts . reduce (
41+ ( agg , part ) => {
42+ if ( part . type === "text" ) {
43+ if ( ! part . synthetic ) agg . input += part . text
44+ }
45+ if ( part . type === "file" ) agg . parts . push ( part )
46+ return agg
47+ } ,
48+ { input : "" , parts : [ ] as PromptInfo [ "parts" ] } ,
49+ )
3850 route . navigate ( {
3951 sessionID : forked . data ! . id ,
4052 type : "session" ,
53+ initialPrompt,
4154 } )
4255 dialog . clear ( )
4356 } ,
Original file line number Diff line number Diff line change @@ -80,9 +80,25 @@ export function DialogMessage(props: {
8080 sessionID : props . sessionID ,
8181 messageID : props . messageID ,
8282 } )
83+ const initialPrompt = ( ( ) => {
84+ const msg = message ( )
85+ if ( ! msg ) return undefined
86+ const parts = sync . data . part [ msg . id ]
87+ return parts . reduce (
88+ ( agg , part ) => {
89+ if ( part . type === "text" ) {
90+ if ( ! part . synthetic ) agg . input += part . text
91+ }
92+ if ( part . type === "file" ) agg . parts . push ( part )
93+ return agg
94+ } ,
95+ { input : "" , parts : [ ] as PromptInfo [ "parts" ] } ,
96+ )
97+ } ) ( )
8398 route . navigate ( {
8499 sessionID : result . data ! . id ,
85100 type : "session" ,
101+ initialPrompt,
86102 } )
87103 dialog . clear ( )
88104 } ,
Original file line number Diff line number Diff line change @@ -168,6 +168,13 @@ export function Session() {
168168 const toast = useToast ( )
169169 const sdk = useSDK ( )
170170
171+ // Handle initial prompt from fork
172+ createEffect ( ( ) => {
173+ if ( route . initialPrompt && prompt ) {
174+ prompt . set ( route . initialPrompt )
175+ }
176+ } )
177+
171178 // Auto-navigate to whichever session currently needs permission input
172179 createEffect ( ( ) => {
173180 const currentSession = session ( )
You can’t perform that action at this time.
0 commit comments