diff --git a/packages/tui/src/routes/session/index.tsx b/packages/tui/src/routes/session/index.tsx
index 8f04fb09387..09a7bea6de9 100644
--- a/packages/tui/src/routes/session/index.tsx
+++ b/packages/tui/src/routes/session/index.tsx
@@ -13,7 +13,7 @@ import {
type Accessor,
} from "solid-js"
import path from "node:path"
-import { EOL } from "node:os"
+import { EOL, tmpdir } from "node:os"
import { mkdir, writeFile } from "node:fs/promises"
import { useRoute, useRouteData } from "../../context/route"
import { createStore } from "solid-js/store"
@@ -1378,7 +1378,7 @@ export function Session(props: {
}
const filepath = path.join(
- paths.cwd,
+ options.location === "temp" ? tmpdir() : paths.cwd,
`session-${crypto.randomUUID()}.${options.format === "markdown" ? "md" : "json"}`,
)
await writeExport(filepath, content)
diff --git a/packages/tui/src/ui/dialog-export-options.tsx b/packages/tui/src/ui/dialog-export-options.tsx
index 014e76b7bb5..7b4cb36a3f1 100644
--- a/packages/tui/src/ui/dialog-export-options.tsx
+++ b/packages/tui/src/ui/dialog-export-options.tsx
@@ -7,12 +7,14 @@ import { createStore } from "solid-js/store"
import { createMemo, createSignal, For, Show } from "solid-js"
export type ExportFormat = "markdown" | "json"
+export type ExportLocation = "project" | "temp"
export type DialogExportOptionsProps = {
defaultThinking: boolean
onConfirm?: (options: {
action: "copy" | "export"
format: ExportFormat
+ location?: ExportLocation
thinking: boolean
tools: boolean
sanitize: boolean
@@ -31,12 +33,13 @@ export function DialogExportOptions(props: DialogExportOptionsProps) {
)
}
-type Row = "format" | "thinking" | "tools" | "sanitize"
+type Row = "format" | "location" | "thinking" | "tools" | "sanitize"
/** Export options as a list of values, under the "new-designs" experiment: ↑/↓ moves, ←/→ or space changes. */
function DialogExportOptionsList(props: DialogExportOptionsProps) {
const [store, setStore] = createStore({
format: "markdown" as ExportFormat,
+ location: "project" as ExportLocation,
thinking: props.defaultThinking,
tools: true,
sanitize: false,
@@ -47,6 +50,7 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
props.onConfirm?.({
action,
format: store.format,
+ location: store.location,
thinking: store.thinking,
tools: store.tools,
sanitize: store.sanitize,
@@ -54,6 +58,7 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
const change = (row: Row) => {
if (row === "format") return setStore("format", store.format === "markdown" ? "json" : "markdown")
+ if (row === "location") return setStore("location", store.location === "project" ? "temp" : "project")
setStore(row, !store[row])
}
@@ -66,6 +71,13 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
footerOverhang: 2,
footer: ,
},
+ {
+ title: "Location",
+ value: "location" as Row,
+ onSelect: () => change("location"),
+ footerOverhang: 2,
+ footer: ,
+ },
...(store.format === "markdown"
? [
{
@@ -286,6 +298,7 @@ DialogExportOptions.show = (dialog: DialogContext, defaultThinking: boolean) =>
return new Promise<{
action: "copy" | "export"
format: ExportFormat
+ location?: ExportLocation
thinking: boolean
tools: boolean
sanitize: boolean