Skip to content

The agent that grows with you

feat(desktop): export, import, rename and delete a board from the switcher

Brooklyn Nicholson72cf8d1fac47
diff --git a/apps/desktop/src/plugins/kanban/api.ts b/apps/desktop/src/plugins/kanban/api.ts
index 6b006b1ef26..39951e87b79 100644
--- a/apps/desktop/src/plugins/kanban/api.ts
+++ b/apps/desktop/src/plugins/kanban/api.ts
@@ -21,6 +21,8 @@ import {
// Native completion notification.
import { bindCompletionNotify, type CompletionEvent, onKanbanEventsFrame } from './completion-notify'
import type {
+ BoardExportResult,
+ BoardImportResult,
BoardMeta,
BoardsResponse,
KanbanBoard,
@@ -37,6 +39,7 @@ type Rest = <T>(path: string, opts?: PluginRestOptions) => Promise<T>
type Socket = (path: string, onMessage: (data: unknown) => void) => () => void
let rest: null | Rest = null
+let os: null | PluginOs = null
/** Selected board slug ('' = the server's current board). Persisted. */
export const $boardSlug = atom<string>('')
@@ -99,6 +102,7 @@ export function bindApi(
notifyDoors?: { os?: PluginOs; t?: PluginTranslate }
): () => void {
rest = r
+ os = notifyDoors?.os ?? null
bindCompletionNotify(r, notifyDoors?.t, notifyDoors?.os)
const unsubs: Array<() => void> = []
@@ -127,9 +131,14 @@ export function bindApi(
unsubs.forEach(unsub => unsub())
close?.()
rest = null
+ os = null
}
}
+/** The plugin's OS door, for components too deep to be handed `ctx`. Null
+ * before `bindApi` and after unload. */
+export const pluginOs = (): null | PluginOs => os
+
function call<T>(path: string, opts?: PluginRestOptions): Promise<T> {
return rest ? rest<T>(path, opts) : Promise.reject(new Error('kanban api not ready'))
}
@@ -257,6 +266,23 @@ export const estimateNew = (title: string, body: string) =>
export const updateBoard = (slug: string, patch: Record<string, unknown>) =>
call<{ board: BoardMeta }>(`/boards/${encodeURIComponent(slug)}`, { method: 'PATCH', body: patch })
+/** Archive a board to `boards/_archived/` — recoverable, and the backend
+ * refuses to touch `default`. (`?delete=true` hard-deletes; no caller yet.) */
+export const deleteBoard = (slug: string) =>
+ call<{ result: { action: string; new_path: string }; current: string }>(
+ `/boards/${encodeURIComponent(slug)}`,
+ { method: 'DELETE' }
+ )
+
+// Board transfer exchanges filesystem paths, not bytes — the picker runs on
+// the machine hosting the backend, so the backend reads and writes the file.
+
+export const exportBoard = (slug: string, output: string) =>
+ call<BoardExportResult>(`/boards/${encodeURIComponent(slug)}/export`, { method: 'POST', body: { output } })
+
+export const importBoard = (archive: string) =>
+ call<BoardImportResult>('/boards/import', { method: 'POST', body: { archive } })
+
export const nudgeDispatcher = () => call<{ spawned?: unknown[] }>(withBoard('/dispatch'), { method: 'POST', body: {} })
export const saveOrchestration = (patch: Record<string, unknown>) =>
diff --git a/apps/desktop/src/plugins/kanban/board-switcher.tsx b/apps/desktop/src/plugins/kanban/board-switcher.tsx
index 6fe961eee81..b4c65972853 100644
--- a/apps/desktop/src/plugins/kanban/board-switcher.tsx
+++ b/apps/desktop/src/plugins/kanban/board-switcher.tsx
@@ -8,6 +8,7 @@
import {
Button,
Codicon,
+ ConfirmDialog,
Dialog,
DialogContent,
DialogFooter,
@@ -25,18 +26,32 @@ import {
SelectItem,
SelectTrigger,
SelectValue,
+ useI18n,
useMutation,
useQuery,
useQueryClient,
useValue
} from '@hermes/plugin-sdk'
-import { useEffect, useState } from 'react'
+import { type ReactNode, useEffect, useState } from 'react'
-import { $boardSlug, BOARDS_KEY, createBoard, fetchBoards, fetchProjects, PROJECTS_KEY, updateBoard } from './api'
+import {
+ $boardSlug,
+ BOARDS_KEY,
+ createBoard,
+ deleteBoard,
+ fetchBoards,
+ fetchProjects,
+ pluginOs,
+ PROJECTS_KEY,
+ updateBoard
+} from './api'
+import { runExportBoardFlow, runImportBoardFlow } from './transfer'
import type { BoardMeta } from './types'
import { errText, FIELD_LABEL, useKanban } from './ui'
const NO_PROJECT = '__none__'
+/** Mirrors `kanban_db.DEFAULT_BOARD` — the board that always exists. */
+const DEFAULT_BOARD = 'default'
/** Board scope = a first-class Hermes project. Its primary repo becomes the
* board's default workspace root; new tasks inherit it as a worktree with a
@@ -70,9 +85,92 @@ function ProjectPicker({ onChange, value }: { onChange: (id: string) => void; va
)
}
+/** Every board write ends the same way: refresh the switcher's list and let
+ * the caller finish, or surface the error and leave the dialog open. */
+function useBoardWrite<T>(mutationFn: () => Promise<T>, onDone: (result: T) => void) {
+ const qc = useQueryClient()
+
+ return useMutation({
+ mutationFn,
+ onError: err => host.notify({ kind: 'error', message: errText(err) }),
+ onSuccess: result => {
+ void qc.invalidateQueries({ queryKey: BOARDS_KEY })
+ onDone(result)
+ }
+ })
+}
+
+/** Shared chrome for the board dialogs — same width, same Cancel/confirm pair. */
+function BoardDialog({
+ children,
+ confirmLabel,
+ disabled,
+ onClose,
+ onConfirm,
+ open,
+ title
+}: {
+ children: ReactNode
+ confirmLabel: string
+ disabled: boolean
+ onClose: () => void
+ onConfirm: () => void
+ open: boolean
+ title: string
+}) {
+ const k = useKanban()
+
+ return (
+ <Dialog onOpenChange={o => !o && onClose()} open={open}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>{title}</DialogTitle>
+ </DialogHeader>
+ <div className="flex flex-col gap-3">{children}</div>
+ <DialogFooter>
+ <Button onClick={onClose} variant="text">
+ {k.cancel}
+ </Button>
+ <Button disabled={disabled} onClick={onConfirm}>
+ {confirmLabel}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+/** Display name, with the slug it maps to shown underneath. */
+function BoardNameField({
+ onChange,
+ onEnter,
+ slug,
+ value
+}: {
+ onChange: (name: string) => void
+ onEnter: () => void
+ slug: string
+ value: string
+}) {
+ const k = useKanban()
+
+ return (
+ <label className="flex flex-col gap-1">
+ <span className={FIELD_LABEL}>{k.name}</span>
+ <Input
+ autoFocus
+ onChange={event => onChange(event.target.value)}
+ onKeyDown={event => event.key === 'Enter' && onEnter()}
+ placeholder={k.boardNamePlaceholder}
+ value={value}
+ />
+ {slug && <span className="text-[0.6875rem] text-(--ui-text-quaternary)">{k.slug(slug)}</span>}
+ </label>
+ )
+}
+
function NewBoardDialog({ onClose, open }: { onClose: () => void; open: boolean }) {
const k = useKanban()
- const qc = useQueryClient()
const [name, setName] = useState('')
const [project, setProject] = useState('')
@@ -89,106 +187,145 @@ function NewBoardDialog({ onClose, open }: { onClose: () => void; open: boolean
}
}, [open])
- const create = useMutation({
- mutationFn: () => createBoard(slug, name.trim(), project || undefined),
- onError: err => host.notify({ kind: 'error', message: errText(err) }),
- onSuccess: result => {
+ const create = useBoardWrite(
+ () => createBoard(slug, name.trim(), project || undefined),
+ result => {
$boardSlug.set(result.board.slug)
- void qc.invalidateQueries({ queryKey: BOARDS_KEY })
onClose()
}
- })
+ )
return (
- <Dialog onOpenChange={o => !o && onClose()} open={open}>
- <DialogContent className="max-w-md">
- <DialogHeader>
- <DialogTitle>{k.newBoard}</DialogTitle>
- </DialogHeader>
- <div className="flex flex-col gap-3">
- <label className="flex flex-col gap-1">
- <span className={FIELD_LABEL}>{k.name}</span>
- <Input
- autoFocus
- onChange={event => setName(event.target.value)}
- onKeyDown={event => event.key === 'Enter' && slug && !project && create.mutate()}
- placeholder={k.boardNamePlaceholder}
- value={name}
- />
- {slug && <span className="text-[0.6875rem] text-(--ui-text-quaternary)">{k.slug(slug)}</span>}
- </label>
- <ProjectPicker onChange={setProject} value={project} />
- </div>
- <DialogFooter>
- <Button onClick={onClose} variant="text">
- {k.cancel}
- </Button>
- <Button disabled={!slug || create.isPending} onClick={() => create.mutate()}>
- {k.createBoard}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
+ <BoardDialog
+ confirmLabel={k.createBoard}
+ disabled={!slug || create.isPending}
+ onClose={onClose}
+ onConfirm={() => create.mutate()}
+ open={open}
+ title={k.newBoard}
+ >
+ {/* Enter submits only while the scope is untouched — once a project is
+ picked the choice is worth a deliberate click. */}
+ <BoardNameField
+ onChange={setName}
+ onEnter={() => slug && !project && create.mutate()}
+ slug={slug}
+ value={name}
+ />
+ <ProjectPicker onChange={setProject} value={project} />
+ </BoardDialog>
)
}
-function BoardSettingsDialog({ board, onClose }: { board: BoardMeta | null; onClose: () => void }) {
+/** Name-only edit, matching how projects rename (a dedicated dialog, separate
+ * from the settings surface that owns scope). The slug is immutable — it is
+ * the board's directory name — so this touches the display name alone. */
+function RenameBoardDialog({ board, onClose }: { board: BoardMeta | null; onClose: () => void }) {
const k = useKanban()
- const qc = useQueryClient()
const [name, setName] = useState('')
+
+ useEffect(() => {
+ if (board) {
+ setName(board.name || board.slug)
+ }
+ }, [board])
+
+ const save = useBoardWrite(() => updateBoard(board!.slug, { name: name.trim() }), onClose)
+ const disabled = !name.trim() || save.isPending
+
+ return (
+ <BoardDialog
+ confirmLabel={k.save}
+ disabled={disabled}
+ onClose={onClose}
+ onConfirm={() => save.mutate()}
+ open={Boolean(board)}
+ title={k.renameBoardTitle}
+ >
+ <BoardNameField
+ onChange={setName}
+ onEnter={() => !disabled && save.mutate()}
+ slug={board?.slug ?? ''}
+ value={name}
+ />
+ </BoardDialog>
+ )
+}
+
+function BoardSettingsDialog({ board, onClose }: { board: BoardMeta | null; onClose: () => void }) {
+ const k = useKanban()
const [project, setProject] = useState('')
useEffect(() => {
if (board) {
- setName(board.name || '')
setProject(board.project_id || '')
}
}, [board])
- const save = useMutation({
- // Slug is immutable; send name + project_id ('' clears the scope, which
- // also drops the mirrored default_workdir on the backend).
- mutationFn: () => updateBoard(board!.slug, { name: name.trim(), project_id: project }),
- onError: err => host.notify({ kind: 'error', message: errText(err) }),
- onSuccess: () => {
- void qc.invalidateQueries({ queryKey: BOARDS_KEY })
- onClose()
- }
- })
+ // The name lives in the rename dialog; '' clears the scope, which also
+ // drops the mirrored default_workdir on the backend.
+ const save = useBoardWrite(() => updateBoard(board!.slug, { project_id: project }), onClose)
return (
- <Dialog onOpenChange={o => !o && onClose()} open={Boolean(board)}>
- <DialogContent className="max-w-md">
- <DialogHeader>
- <DialogTitle>{board ? k.boardSettingsFor(board.name || board.slug) : k.boardSettings}</DialogTitle>
- </DialogHeader>
- <div className="flex flex-col gap-3">
- <label className="flex flex-col gap-1">
- <span className={FIELD_LABEL}>{k.name}</span>
- <Input onChange={event => setName(event.target.value)} placeholder={k.boardNamePlaceholder} value={name} />
- {board && <span className="text-[0.6875rem] text-(--ui-text-quaternary)">{k.slug(board.slug)}</span>}
- </label>
- <ProjectPicker onChange={setProject} value={project} />
- </div>
- <DialogFooter>
- <Button onClick={onClose} variant="text">
- {k.cancel}
- </Button>
- <Button disabled={save.isPending} onClick={() => save.mutate()}>
- {k.save}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
+ <BoardDialog
+ confirmLabel={k.save}
+ disabled={save.isPending}
+ onClose={onClose}
+ onConfirm={() => save.mutate()}
+ open={Boolean(board)}
+ title={board ? k.boardSettingsFor(board.name || board.slug) : k.settingsDots}
+ >
+ <ProjectPicker onChange={setProject} value={project} />
+ </BoardDialog>
)
}
export function BoardSwitcher() {
const k = useKanban()
+ // Delete reuses the app-wide label, the way sessions and profiles do.
+ const { t } = useI18n()
+ const qc = useQueryClient()
const slug = useValue($boardSlug)
const { data: boards } = useQuery({ queryFn: fetchBoards, queryKey: BOARDS_KEY, staleTime: 30_000 })
const [adding, setAdding] = useState(false)
const [settingsFor, setSettingsFor] = useState<BoardMeta | null>(null)
+ const [renameFor, setRenameFor] = useState<BoardMeta | null>(null)
+ const [deleteFor, setDeleteFor] = useState<BoardMeta | null>(null)
+
+ // Archive rather than erase, so a mis-click stays recoverable. The backend
+ // reverts the active board to default; drop our override to follow it.
+ const confirmDelete = async (target: BoardMeta) => {
+ const { result } = await deleteBoard(target.slug)
+
+ $boardSlug.set('')
+ void qc.invalidateQueries({ queryKey: BOARDS_KEY })
+ host.notify({ kind: 'success', message: k.boardArchived(result.new_path) })
+ }
+
+ const runExport = async (target: string) => {
+ const os = pluginOs()
+
+ if (!os) {
+ return
+ }
+
+ await runExportBoardFlow(os, k, target)
+ }
+
+ const runImport = async () => {
+ const os = pluginOs()
+
+ if (!os) {
+ return
+ }
+
+ const imported = await runImportBoardFlow(os, k)
+
+ if (imported) {
+ $boardSlug.set(imported)
+ void qc.invalidateQueries({ queryKey: BOARDS_KEY })
+ }
+ }
if (!boards) {
return null
@@ -225,19 +362,57 @@ export function BoardSwitcher() {
))}
<DropdownMenuSeparator />
{current && (
- <DropdownMenuItem onSelect={() => setSettingsFor(current)}>
- <Codicon name="settings-gear" size="0.8rem" />
- {k.boardSettings}
- </DropdownMenuItem>
+ <>
+ <DropdownMenuItem onSelect={() => setRenameFor(current)}>
+ <Codicon name="edit" size="0.8rem" />
+ {k.renameDots}
+ </DropdownMenuItem>
+ <DropdownMenuItem onSelect={() => setSettingsFor(current)}>
+ <Codicon name="settings-gear" size="0.8rem" />
+ {k.settingsDots}
+ </DropdownMenuItem>
+ </>
)}
<DropdownMenuItem onSelect={() => setAdding(true)}>
<Codicon name="add" size="0.8rem" />
{k.newBoardDots}
</DropdownMenuItem>
+ <DropdownMenuSeparator />
+ {current && (
+ <DropdownMenuItem onSelect={() => void runExport(current.slug)}>
+ <Codicon name="package" size="0.8rem" />
+ {k.exportDots}
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuItem onSelect={() => void runImport()}>
+ <Codicon name="cloud-download" size="0.8rem" />
+ {k.importDots}
+ </DropdownMenuItem>
+ {/* `default` is the fallback every board reverts to — the backend
+ refuses to remove it, so it never offers the action. */}
+ {current && current.slug !== DEFAULT_BOARD && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onSelect={() => setDeleteFor(current)} variant="destructive">
+ <Codicon name="trash" size="0.8rem" />
+ {t.common.delete}
+ </DropdownMenuItem>
+ </>
+ )}
</DropdownMenuContent>
</DropdownMenu>
<NewBoardDialog onClose={() => setAdding(false)} open={adding} />
+ <RenameBoardDialog board={renameFor} onClose={() => setRenameFor(null)} />
<BoardSettingsDialog board={settingsFor} onClose={() => setSettingsFor(null)} />
+ <ConfirmDialog
+ confirmLabel={t.common.delete}
+ description={k.deleteBoardConfirm}
+ destructive
+ onClose={() => setDeleteFor(null)}
+ onConfirm={() => confirmDelete(deleteFor!)}
+ open={Boolean(deleteFor)}
+ title={deleteFor ? k.deleteBoardTitle(deleteFor.name || deleteFor.slug) : t.common.delete}
+ />
</>
)
}
diff --git a/apps/desktop/src/plugins/kanban/drawer.tsx b/apps/desktop/src/plugins/kanban/drawer.tsx
index 77ed9539c60..95a01d20499 100644
--- a/apps/desktop/src/plugins/kanban/drawer.tsx
+++ b/apps/desktop/src/plugins/kanban/drawer.tsx
@@ -721,11 +721,11 @@ export function TaskDrawer({
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={mutate(() => patchTask(task.id, { status: 'archived' }), onClose)}>
<Codicon name="archive" size="0.85rem" />
- {k.archiveTask}
+ {k.archive}
</DropdownMenuItem>
<DropdownMenuItem className="text-destructive" onSelect={mutate(() => deleteTask(task.id), onClose)}>
<Codicon name="trash" size="0.85rem" />
- {k.deleteTask}
+ {k.delete}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/apps/desktop/src/plugins/kanban/i18n.ts b/apps/desktop/src/plugins/kanban/i18n.ts
index 76836755d10..466986b4eaa 100644
--- a/apps/desktop/src/plugins/kanban/i18n.ts
+++ b/apps/desktop/src/plugins/kanban/i18n.ts
@@ -158,15 +158,28 @@ type KanbanMessages = {
copyTitle: string
copiedId: (id: string) => string
copiedTitle: string
- archiveTask: string
- deleteTask: string
close: string
working: string
// board switcher
board: string
newBoard: string
newBoardDots: string
- boardSettings: string
+ // Menu labels are bare verbs — the board they act on is the one named in the
+ // switcher's trigger. The nouns come back for the native file-dialog and
+ // in-app dialog titles, which stand alone.
+ exportDots: string
+ importDots: string
+ renameDots: string
+ settingsDots: string
+ exportBoardTitle: string
+ importBoardTitle: string
+ boardExported: (path: string) => string
+ boardImported: (name: string) => string
+ boardImportedAs: (slug: string) => string
+ renameBoardTitle: string
+ deleteBoardTitle: (name: string) => string
+ deleteBoardConfirm: string
+ boardArchived: (path: string) => string
boardSettingsFor: (name: string) => string
name: string
boardNamePlaceholder: string
@@ -361,14 +374,25 @@ export const en: KanbanMessages = {
copyTitle: 'Copy title',
copiedId: id => `Copied ${id}`,
copiedTitle: 'Copied title',
- archiveTask: 'Archive task',
- deleteTask: 'Delete task',
close: 'Close',
working: 'working',
board: 'Board',
newBoard: 'New board',
newBoardDots: 'New board…',
- boardSettings: 'Board settings…',
+ exportDots: 'Export…',
+ importDots: 'Import…',
+ renameDots: 'Rename…',
+ settingsDots: 'Settings…',
+ exportBoardTitle: 'Export board…',
+ importBoardTitle: 'Import board…',
+ boardExported: path => `Board exported to ${path}`,
+ boardImported: name => `Imported ${name}`,
+ boardImportedAs: slug => `That name was taken — imported as ${slug}`,
+ renameBoardTitle: 'Rename board',
+ deleteBoardTitle: name => `Delete "${name}"?`,
+ deleteBoardConfirm:
+ 'The board is archived, not erased — its tasks and attachments stay on disk and can be restored.',
+ boardArchived: path => `Board archived to ${path}`,
boardSettingsFor: name => `Board settings — ${name}`,
name: 'Name',
boardNamePlaceholder: 'Board name',
@@ -562,14 +586,24 @@ const ja: KanbanMessages = {
copyTitle: 'タイトルをコピー',
copiedId: id => `${id} をコピーしました`,
copiedTitle: 'タイトルをコピーしました',
- archiveTask: 'タスクをアーカイブ',
- deleteTask: 'タスクを削除',
close: '閉じる',
working: '作業中',
board: 'ボード',
newBoard: '新しいボード',
newBoardDots: '新しいボード…',
- boardSettings: 'ボード設定…',
+ exportDots: 'エクスポート…',
+ importDots: 'インポート…',
+ renameDots: '名前を変更…',
+ settingsDots: '設定…',
+ exportBoardTitle: 'ボードをエクスポート…',
+ importBoardTitle: 'ボードをインポート…',
+ boardExported: path => `ボードを ${path} にエクスポートしました`,
+ boardImported: name => `${name} をインポートしました`,
+ boardImportedAs: slug => `その名前は使用中のため ${slug} としてインポートしました`,
+ renameBoardTitle: 'ボード名を変更',
+ deleteBoardTitle: name => `「${name}」を削除しますか?`,
+ deleteBoardConfirm: 'ボードは消去されずアーカイブされます。タスクと添付ファイルはディスクに残り、復元できます。',
+ boardArchived: path => `ボードを ${path} にアーカイブしました`,
boardSettingsFor: name => `ボード設定 — ${name}`,
name: '名前',
boardNamePlaceholder: 'ボード名',
@@ -761,14 +795,24 @@ const zh: KanbanMessages = {
copyTitle: '复制标题',
copiedId: id => `已复制 ${id}`,
copiedTitle: '已复制标题',
- archiveTask: '归档任务',
- deleteTask: '删除任务',
close: '关闭',
working: '进行中',
board: '面板',
newBoard: '新建面板',
newBoardDots: '新建面板…',
- boardSettings: '面板设置…',
+ exportDots: '导出…',
+ importDots: '导入…',
+ renameDots: '重命名…',
+ settingsDots: '设置…',
+ exportBoardTitle: '导出面板…',
+ importBoardTitle: '导入面板…',
+ boardExported: path => `面板已导出至 ${path}`,
+ boardImported: name => `已导入 ${name}`,
+ boardImportedAs: slug => `该名称已被占用,已导入为 ${slug}`,
+ renameBoardTitle: '重命名面板',
+ deleteBoardTitle: name => `确定删除“${name}”?`,
+ deleteBoardConfirm: '面板会被归档而非清除,其任务和附件仍保留在磁盘上,可以恢复。',
+ boardArchived: path => `面板已归档至 ${path}`,
boardSettingsFor: name => `面板设置 — ${name}`,
name: '名称',
boardNamePlaceholder: '面板名称',
@@ -959,14 +1003,24 @@ const zhHant: KanbanMessages = {
copyTitle: '複製標題',
copiedId: id => `已複製 ${id}`,
copiedTitle: '已複製標題',
- archiveTask: '封存任務',
- deleteTask: '刪除任務',
close: '關閉',
working: '進行中',
board: '面板',
newBoard: '新增面板',
newBoardDots: '新增面板…',
- boardSettings: '面板設定…',
+ exportDots: '匯出…',
+ importDots: '匯入…',
+ renameDots: '重新命名…',
+ settingsDots: '設定…',
+ exportBoardTitle: '匯出面板…',
+ importBoardTitle: '匯入面板…',
+ boardExported: path => `面板已匯出至 ${path}`,
+ boardImported: name => `已匯入 ${name}`,
+ boardImportedAs: slug => `該名稱已被使用,已匯入為 ${slug}`,
+ renameBoardTitle: '重新命名面板',
+ deleteBoardTitle: name => `確定刪除「${name}」?`,
+ deleteBoardConfirm: '面板會被封存而非清除,其任務和附件仍保留在磁碟上,可以還原。',
+ boardArchived: path => `面板已封存至 ${path}`,
boardSettingsFor: name => `面板設定 — ${name}`,
name: '名稱',
boardNamePlaceholder: '面板名稱',
diff --git a/apps/desktop/src/plugins/kanban/transfer.ts b/apps/desktop/src/plugins/kanban/transfer.ts
new file mode 100644
index 00000000000..8938fd8e891
--- /dev/null
+++ b/apps/desktop/src/plugins/kanban/transfer.ts
@@ -0,0 +1,74 @@
+/**
+ * Board export / import flows — the same shape as the profile ones
+ * (`src/store/profile-share.ts`): pick a path with the native dialog, hand
+ * the PATH to the backend, toast the outcome.
+ *
+ * Bytes never cross the renderer. The picker and the backend are on the same
+ * machine, so the backend does the reading and writing; that also keeps a
+ * multi-hundred-megabyte board of attachments out of the renderer heap.
+ */
+
+import { host, type PluginOs } from '@hermes/plugin-sdk'
+
+import { exportBoard, importBoard } from './api'
+import type { KanbanText } from './i18n'
+import { errText } from './ui'
+
+const ARCHIVE_FILTERS = [{ extensions: ['tar.gz', 'tgz'], name: 'Hermes board' }]
+
+/** Pick a destination and export `slug`. Returns the archive path, or null
+ * when the user cancelled or the export failed. */
+export async function runExportBoardFlow(os: PluginOs, k: KanbanText, slug: string): Promise<null | string> {
+ const output = await os.pickSavePath({
+ title: k.exportBoardTitle,
+ defaultPath: `${slug}.tar.gz`,
+ filters: ARCHIVE_FILTERS
+ })
+
+ if (!output) {
+ return null
+ }
+
+ try {
+ const result = await exportBoard(slug, output)
+ host.notify({ kind: 'success', message: k.boardExported(result.archive) })
+
+ return result.archive
+ } catch (error) {
+ host.notify({ kind: 'error', message: errText(error) })
+
+ return null
+ }
+}
+
+/** Pick an archive and import it as a new board. Returns the new board's slug,
+ * or null when cancelled or failed. */
+export async function runImportBoardFlow(os: PluginOs, k: KanbanText): Promise<null | string> {
+ const archive = await os.pickOpenPath({ title: k.importBoardTitle, filters: ARCHIVE_FILTERS })
+
+ if (!archive) {
+ return null
+ }
+
+ try {
+ const result = await importBoard(archive)
+ host.notify({ kind: 'success', message: k.boardImported(result.name) })
+
+ // The slug auto-suffixes on collision, and warnings cover tasks parked
+ // for an unresolvable workspace — both change what the user sees on the
+ // board they just opened, so neither is allowed to pass silently.
+ if (result.renamed) {
+ host.notify({ kind: 'info', message: k.boardImportedAs(result.board) })
+ }
+
+ for (const warning of result.warnings) {
+ host.notify({ kind: 'warning', message: warning })
+ }
+
+ return result.board
+ } catch (error) {
+ host.notify({ kind: 'error', message: errText(error) })
+
+ return null
+ }
+}
diff --git a/apps/desktop/src/plugins/kanban/types.ts b/apps/desktop/src/plugins/kanban/types.ts
index ef67db4c467..1f6242d275d 100644
--- a/apps/desktop/src/plugins/kanban/types.ts
+++ b/apps/desktop/src/plugins/kanban/types.ts
@@ -139,6 +139,25 @@ export interface BoardMeta {
project_name?: null | string
}
+/** POST /boards/{slug}/export — the archive the backend wrote. */
+export interface BoardExportResult {
+ board: string
+ archive: string
+ size: number
+}
+
+/** POST /boards/import — the NEW board the archive landed as. */
+export interface BoardImportResult {
+ board: string
+ name: string
+ /** True when the archive's slug was taken and the import got a suffix. */
+ renamed: boolean
+ requested_board: string
+ counts: Record<string, number>
+ /** Human-readable notes (parked tasks, dropped attachments). */
+ warnings: string[]
+}
+
/** GET /projects — first-class Hermes projects available to scope a board. */
export interface KanbanProject {
id: string