mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
Revert "fix(tui): choose project or temp folder for session exports"
This reverts commit 412d93e733.
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
type Accessor,
|
||||
} from "solid-js"
|
||||
import path from "node:path"
|
||||
import { EOL, tmpdir } from "node:os"
|
||||
import { EOL } 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(
|
||||
options.location === "project" ? paths.cwd : tmpdir(),
|
||||
paths.cwd,
|
||||
`session-${crypto.randomUUID()}.${options.format === "markdown" ? "md" : "json"}`,
|
||||
)
|
||||
await writeExport(filepath, content)
|
||||
|
||||
@@ -7,14 +7,12 @@ 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
|
||||
@@ -22,7 +20,7 @@ export type DialogExportOptionsProps = {
|
||||
onCancel?: () => void
|
||||
}
|
||||
|
||||
type Active = ExportFormat | ExportLocation | "thinking" | "tools" | "sanitize" | "copy" | "export"
|
||||
type Active = ExportFormat | "thinking" | "tools" | "sanitize" | "copy" | "export"
|
||||
|
||||
export function DialogExportOptions(props: DialogExportOptionsProps) {
|
||||
const newDesigns = useNewDesigns()
|
||||
@@ -33,13 +31,12 @@ export function DialogExportOptions(props: DialogExportOptionsProps) {
|
||||
)
|
||||
}
|
||||
|
||||
type Row = "format" | "location" | "thinking" | "tools" | "sanitize"
|
||||
type Row = "format" | "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,
|
||||
@@ -50,7 +47,6 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
|
||||
props.onConfirm?.({
|
||||
action,
|
||||
format: store.format,
|
||||
location: store.location,
|
||||
thinking: store.thinking,
|
||||
tools: store.tools,
|
||||
sanitize: store.sanitize,
|
||||
@@ -58,7 +54,6 @@ 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])
|
||||
}
|
||||
|
||||
@@ -71,13 +66,6 @@ function DialogExportOptionsList(props: DialogExportOptionsProps) {
|
||||
footerOverhang: 2,
|
||||
footer: <DialogSelectChoice value={store.format} active={selected() === "format"} />,
|
||||
},
|
||||
{
|
||||
title: "Location",
|
||||
value: "location" as Row,
|
||||
onSelect: () => change("location"),
|
||||
footerOverhang: 2,
|
||||
footer: <DialogSelectChoice value={store.location} active={selected() === "location"} />,
|
||||
},
|
||||
...(store.format === "markdown"
|
||||
? [
|
||||
{
|
||||
@@ -146,7 +134,6 @@ 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,
|
||||
@@ -157,7 +144,6 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
|
||||
props.onConfirm?.({
|
||||
action,
|
||||
format: store.format,
|
||||
location: store.location,
|
||||
thinking: store.thinking,
|
||||
tools: store.tools,
|
||||
sanitize: store.sanitize,
|
||||
@@ -168,10 +154,6 @@ 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)
|
||||
@@ -180,9 +162,7 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
|
||||
|
||||
const move = (offset: number) => {
|
||||
const options: Active[] =
|
||||
store.format === "markdown"
|
||||
? ["markdown", "json", "project", "temp", "thinking", "tools"]
|
||||
: ["markdown", "json", "project", "temp", "sanitize"]
|
||||
store.format === "markdown" ? ["markdown", "json", "thinking", "tools"] : ["markdown", "json", "sanitize"]
|
||||
const order: Active[] = [...options, "copy", "export"]
|
||||
setStore("active", order[(order.indexOf(store.active) + offset + order.length) % order.length])
|
||||
}
|
||||
@@ -206,11 +186,6 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
|
||||
setStore("active", format)
|
||||
}
|
||||
|
||||
const selectLocation = (location: ExportLocation) => {
|
||||
setStore("location", location)
|
||||
setStore("active", location)
|
||||
}
|
||||
|
||||
return (
|
||||
<DialogLayout
|
||||
header={<DialogHeader title="Export session" />}
|
||||
@@ -265,29 +240,6 @@ function LegacyDialogExportOptions(props: DialogExportOptionsProps) {
|
||||
</For>
|
||||
</box>
|
||||
</box>
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text fg={theme.text.base} width={10}>
|
||||
Save to:
|
||||
</text>
|
||||
<box flexDirection="row" gap={1}>
|
||||
<For each={["project", "temp"] as const}>
|
||||
{(location) => (
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
onMouseUp={() => selectLocation(location)}
|
||||
>
|
||||
<text fg={markColor(store.active === location, store.location === location)}>
|
||||
{store.location === location ? "◉" : "○"}
|
||||
</text>
|
||||
<text fg={labelColor(store.active === location)}>{location === "project" ? "Project" : "Temp"}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</box>
|
||||
<Show when={store.format === "markdown"}>
|
||||
<box
|
||||
flexDirection="row"
|
||||
@@ -334,7 +286,6 @@ DialogExportOptions.show = (dialog: DialogContext, defaultThinking: boolean) =>
|
||||
return new Promise<{
|
||||
action: "copy" | "export"
|
||||
format: ExportFormat
|
||||
location: ExportLocation
|
||||
thinking: boolean
|
||||
tools: boolean
|
||||
sanitize: boolean
|
||||
|
||||
@@ -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, 5, 6]) app.mockInput.pressTab()
|
||||
for (const _ of [1, 2, 3, 4]) app.mockInput.pressTab()
|
||||
await app.waitForFrame(() => span("Copy")?.bg.equals(focusedButton()) === true)
|
||||
expect(span("Include tools")?.fg.equals(field())).toBe(true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user