@@ -7,20 +7,22 @@ import { createStore } from "solid-js/store"
77import { createMemo , createSignal , For , Show } from "solid-js"
88
99export type ExportFormat = "markdown" | "json"
10+ export type ExportLocation = "project" | "temp"
1011
1112export type DialogExportOptionsProps = {
1213 defaultThinking : boolean
1314 onConfirm ?: ( options : {
1415 action : "copy" | "export"
1516 format : ExportFormat
17+ location : ExportLocation
1618 thinking : boolean
1719 tools : boolean
1820 sanitize : boolean
1921 } ) => void
2022 onCancel ?: ( ) => void
2123}
2224
23- type Active = ExportFormat | "thinking" | "tools" | "sanitize" | "copy" | "export"
25+ type Active = ExportFormat | ExportLocation | "thinking" | "tools" | "sanitize" | "copy" | "export"
2426
2527export function DialogExportOptions ( props : DialogExportOptionsProps ) {
2628 const newDesigns = useNewDesigns ( )
@@ -31,12 +33,13 @@ export function DialogExportOptions(props: DialogExportOptionsProps) {
3133 )
3234}
3335
34- type Row = "format" | "thinking" | "tools" | "sanitize"
36+ type Row = "format" | "location" | " thinking" | "tools" | "sanitize"
3537
3638/** Export options as a list of values, under the "new-designs" experiment: ↑/↓ moves, ←/→ or space changes. */
3739function DialogExportOptionsList ( props : DialogExportOptionsProps ) {
3840 const [ store , setStore ] = createStore ( {
3941 format : "markdown" as ExportFormat ,
42+ location : "project" as ExportLocation ,
4043 thinking : props . defaultThinking ,
4144 tools : true ,
4245 sanitize : false ,
@@ -47,13 +50,15 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
4750 props . onConfirm ?.( {
4851 action,
4952 format : store . format ,
53+ location : store . location ,
5054 thinking : store . thinking ,
5155 tools : store . tools ,
5256 sanitize : store . sanitize ,
5357 } )
5458
5559 const change = ( row : Row ) => {
5660 if ( row === "format" ) return setStore ( "format" , store . format === "markdown" ? "json" : "markdown" )
61+ if ( row === "location" ) return setStore ( "location" , store . location === "project" ? "temp" : "project" )
5762 setStore ( row , ! store [ row ] )
5863 }
5964
@@ -66,6 +71,13 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
6671 footerOverhang : 2 ,
6772 footer : < DialogSelectChoice value = { store . format } active = { selected ( ) === "format" } /> ,
6873 } ,
74+ {
75+ title : "Location" ,
76+ value : "location" as Row ,
77+ onSelect : ( ) => change ( "location" ) ,
78+ footerOverhang : 2 ,
79+ footer : < DialogSelectChoice value = { store . location } active = { selected ( ) === "location" } /> ,
80+ } ,
6981 ...( store . format === "markdown"
7082 ? [
7183 {
@@ -134,6 +146,7 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
134146 const labelColor = ( active : boolean ) => ( active ? theme . text . formfield . focused : theme . text . formfield . base )
135147 const [ store , setStore ] = createStore ( {
136148 format : "markdown" as ExportFormat ,
149+ location : "project" as ExportLocation ,
137150 thinking : props . defaultThinking ,
138151 tools : true ,
139152 sanitize : false ,
@@ -144,6 +157,7 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
144157 props . onConfirm ?.( {
145158 action,
146159 format : store . format ,
160+ location : store . location ,
147161 thinking : store . thinking ,
148162 tools : store . tools ,
149163 sanitize : store . sanitize ,
@@ -154,6 +168,10 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
154168 setStore ( "format" , store . active )
155169 return
156170 }
171+ if ( store . active === "project" || store . active === "temp" ) {
172+ setStore ( "location" , store . active )
173+ return
174+ }
157175 if ( store . active === "thinking" ) setStore ( "thinking" , ! store . thinking )
158176 if ( store . active === "tools" ) setStore ( "tools" , ! store . tools )
159177 if ( store . active === "sanitize" ) setStore ( "sanitize" , ! store . sanitize )
@@ -162,7 +180,9 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
162180
163181 const move = ( offset : number ) => {
164182 const options : Active [ ] =
165- store . format === "markdown" ? [ "markdown" , "json" , "thinking" , "tools" ] : [ "markdown" , "json" , "sanitize" ]
183+ store . format === "markdown"
184+ ? [ "markdown" , "json" , "project" , "temp" , "thinking" , "tools" ]
185+ : [ "markdown" , "json" , "project" , "temp" , "sanitize" ]
166186 const order : Active [ ] = [ ...options , "copy" , "export" ]
167187 setStore ( "active" , order [ ( order . indexOf ( store . active ) + offset + order . length ) % order . length ] )
168188 }
@@ -186,6 +206,11 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
186206 setStore ( "active" , format )
187207 }
188208
209+ const selectLocation = ( location : ExportLocation ) => {
210+ setStore ( "location" , location )
211+ setStore ( "active" , location )
212+ }
213+
189214 return (
190215 < DialogLayout
191216 header = { < DialogHeader title = "Export session" /> }
@@ -240,6 +265,29 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
240265 </ For >
241266 </ box >
242267 </ box >
268+ < box flexDirection = "row" gap = { 1 } >
269+ < text fg = { theme . text . base } width = { 10 } >
270+ Save to:
271+ </ text >
272+ < box flexDirection = "row" gap = { 1 } >
273+ < For each = { [ "project" , "temp" ] as const } >
274+ { ( location ) => (
275+ < box
276+ flexDirection = "row"
277+ gap = { 1 }
278+ paddingLeft = { 1 }
279+ paddingRight = { 1 }
280+ onMouseUp = { ( ) => selectLocation ( location ) }
281+ >
282+ < text fg = { markColor ( store . active === location , store . location === location ) } >
283+ { store . location === location ? "◉" : "○" }
284+ </ text >
285+ < text fg = { labelColor ( store . active === location ) } > { location === "project" ? "Project" : "Temp" } </ text >
286+ </ box >
287+ ) }
288+ </ For >
289+ </ box >
290+ </ box >
243291 < Show when = { store . format === "markdown" } >
244292 < box
245293 flexDirection = "row"
@@ -286,6 +334,7 @@ DialogExportOptions.show = (dialog: DialogContext, defaultThinking: boolean) =>
286334 return new Promise < {
287335 action : "copy" | "export"
288336 format : ExportFormat
337+ location : ExportLocation
289338 thinking : boolean
290339 tools : boolean
291340 sanitize : boolean
0 commit comments