diff --git a/packages/app/src/runtime/i18n/en.ts b/packages/app/src/runtime/i18n/en.ts index 88dcb990e2..0acc1796bb 100644 --- a/packages/app/src/runtime/i18n/en.ts +++ b/packages/app/src/runtime/i18n/en.ts @@ -93,6 +93,7 @@ export const dict = { "command.session.fork.description": "Create a new session from a previous message", "command.session.export": "Export session", "command.session.export.description": "Export the full session transcript as JSON", + "command.session.copyID": "Copy Session ID", "palette.search.placeholder": "Search files, commands, and sessions", "palette.search.placeholder.home": "Search commands and sessions", @@ -553,6 +554,8 @@ export const dict = { "toast.session.export.success.description": "Saved session to {{filename}}", "toast.session.export.failed.title": "Failed to export session", "toast.session.export.failed.description": "An error occurred while exporting the session", + "toast.session.copyID.failed.title": "Failed to copy session ID", + "toast.session.copyID.failed.description": "An error occurred while copying the session ID", "toast.session.listFailed.title": "Failed to load sessions for {{project}}", "toast.project.reloadFailed.title": "Failed to reload {{project}}", diff --git a/packages/app/src/session/commands/use-session-commands.tsx b/packages/app/src/session/commands/use-session-commands.tsx index ce5b4ee24b..d4b1f31b21 100644 --- a/packages/app/src/session/commands/use-session-commands.tsx +++ b/packages/app/src/session/commands/use-session-commands.tsx @@ -126,6 +126,26 @@ export const useSessionCommands = (actions: SessionCommandContext) => { } } + const copySessionID = async () => { + const sessionID = actions.session.identity.params.id + if (!sessionID) return + try { + await navigator.clipboard.writeText(sessionID) + showToast({ + variant: "success", + icon: "circle-check", + title: language.t("common.copied"), + description: sessionID, + }) + } catch (err) { + showToast({ + variant: "error", + title: language.t("toast.session.copyID.failed.title"), + description: err instanceof Error ? err.message : language.t("toast.session.copyID.failed.description"), + }) + } + } + const openFile = () => { void openDialog( () => import("@/shell/commands/dialog"), @@ -271,6 +291,12 @@ export const useSessionCommands = (actions: SessionCommandContext) => { disabled: !actions.session.identity.params.id, onSelect: exportSession, }), + sessionCommand({ + id: "session.copyID", + title: language.t("command.session.copyID"), + disabled: !actions.session.identity.params.id, + onSelect: copySessionID, + }), ] const fileCmds = () => {