diff --git a/packages/tui/src/routes/session/index.tsx b/packages/tui/src/routes/session/index.tsx
index 33bd34340ec..8a6e07b8ebc 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"
@@ -1376,7 +1376,7 @@ export function Session(props: {
}
const filepath = path.join(
- paths.cwd,
+ options.location === "project" ? paths.cwd : tmpdir(),
`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..e219edd0569 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
@@ -20,7 +22,7 @@ export type DialogExportOptionsProps = {
onCancel?: () => void
}
-type Active = ExportFormat | "thinking" | "tools" | "sanitize" | "copy" | "export"
+type Active = ExportFormat | ExportLocation | "thinking" | "tools" | "sanitize" | "copy" | "export"
export function DialogExportOptions(props: DialogExportOptionsProps) {
const newDesigns = useNewDesigns()
@@ -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"
? [
{
@@ -134,6 +146,7 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
const labelColor = (active: boolean) => (active ? theme.text.formfield.focused : theme.text.formfield.base)
const [store, setStore] = createStore({
format: "markdown" as ExportFormat,
+ location: "project" as ExportLocation,
thinking: props.defaultThinking,
tools: true,
sanitize: false,
@@ -144,6 +157,7 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
props.onConfirm?.({
action,
format: store.format,
+ location: store.location,
thinking: store.thinking,
tools: store.tools,
sanitize: store.sanitize,
@@ -154,6 +168,10 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
setStore("format", store.active)
return
}
+ if (store.active === "project" || store.active === "temp") {
+ setStore("location", store.active)
+ return
+ }
if (store.active === "thinking") setStore("thinking", !store.thinking)
if (store.active === "tools") setStore("tools", !store.tools)
if (store.active === "sanitize") setStore("sanitize", !store.sanitize)
@@ -162,7 +180,9 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
const move = (offset: number) => {
const options: Active[] =
- store.format === "markdown" ? ["markdown", "json", "thinking", "tools"] : ["markdown", "json", "sanitize"]
+ store.format === "markdown"
+ ? ["markdown", "json", "project", "temp", "thinking", "tools"]
+ : ["markdown", "json", "project", "temp", "sanitize"]
const order: Active[] = [...options, "copy", "export"]
setStore("active", order[(order.indexOf(store.active) + offset + order.length) % order.length])
}
@@ -186,6 +206,11 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
setStore("active", format)
}
+ const selectLocation = (location: ExportLocation) => {
+ setStore("location", location)
+ setStore("active", location)
+ }
+
return (
}
@@ -240,6 +265,29 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
+
+
+ Save to:
+
+
+
+ {(location) => (
+ selectLocation(location)}
+ >
+
+ {store.location === location ? "◉" : "○"}
+
+ {location === "project" ? "Project" : "Temp"}
+
+ )}
+
+
+
return new Promise<{
action: "copy" | "export"
format: ExportFormat
+ location: ExportLocation
thinking: boolean
tools: boolean
sanitize: boolean
diff --git a/packages/tui/test/component/dialog-export-options.test.tsx b/packages/tui/test/component/dialog-export-options.test.tsx
index bc07120af37..489ac4cb22a 100644
--- a/packages/tui/test/component/dialog-export-options.test.tsx
+++ b/packages/tui/test/component/dialog-export-options.test.tsx
@@ -55,7 +55,7 @@ test("tab and shift+tab move a visible focus through the export options", async
expect(span("Include thinking")?.fg.equals(field())).toBe(true)
expect(span("Copy")?.bg.equals(focusedButton())).toBe(false)
- for (const _ of [1, 2, 3, 4]) app.mockInput.pressTab()
+ for (const _ of [1, 2, 3, 4, 5, 6]) app.mockInput.pressTab()
await app.waitForFrame(() => span("Copy")?.bg.equals(focusedButton()) === true)
expect(span("Include tools")?.fg.equals(field())).toBe(true)