From f7d4fe072bbe2de9a4e8e1ae485bceccc6c237b2 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 15 Nov 2026 01:28:50 -0800 Subject: [PATCH] feat(terminal): add a copy button to the terminal error toast (#42679) The toast shows the error plus the client's Orca/OS/shell details and asks users to file an issue, but copying it meant drag-selecting the monospace text. Add a copy icon beside dismiss that copies the error together with the same environment footer the toast renders. Move the generic { text, label } copy icon button out of the editor checks panel into components/clipboard as CopyTextButton so the checks panel and the terminal toast share it, and fold showClientEnvironment into the footer so the copied text and the rendered footer share one guard. Fixes #30061 Co-authored-by: Claude --- .../CopyTextButton.tsx} | 2 +- .../panel/CheckRunAnnotations.tsx | 4 +-- .../panel/CheckRunDetailsPanel.tsx | 4 +-- .../check-details/panel/CheckRunJobs.tsx | 4 +-- .../errors/TerminalErrorToast.test.tsx | 36 +++++++++++++++++++ .../errors/TerminalErrorToast.tsx | 34 ++++++++++++------ src/renderer/src/i18n/locales/de.json | 3 +- src/renderer/src/i18n/locales/en.json | 3 +- src/renderer/src/i18n/locales/es.json | 3 +- src/renderer/src/i18n/locales/fr.json | 3 +- src/renderer/src/i18n/locales/ja.json | 3 +- src/renderer/src/i18n/locales/ko.json | 3 +- src/renderer/src/i18n/locales/pt.json | 3 +- src/renderer/src/i18n/locales/ru.json | 3 +- src/renderer/src/i18n/locales/tr.json | 3 +- src/renderer/src/i18n/locales/zh-Hant.json | 3 +- src/renderer/src/i18n/locales/zh.json | 3 +- 17 files changed, 89 insertions(+), 28 deletions(-) rename src/renderer/src/components/{editor/check-details/panel/CheckRunCopyButton.tsx => clipboard/CopyTextButton.tsx} (97%) create mode 100644 src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx diff --git a/src/renderer/src/components/editor/check-details/panel/CheckRunCopyButton.tsx b/src/renderer/src/components/clipboard/CopyTextButton.tsx similarity index 97% rename from src/renderer/src/components/editor/check-details/panel/CheckRunCopyButton.tsx rename to src/renderer/src/components/clipboard/CopyTextButton.tsx index 51ea88ef36c..49830175eb1 100644 --- a/src/renderer/src/components/editor/check-details/panel/CheckRunCopyButton.tsx +++ b/src/renderer/src/components/clipboard/CopyTextButton.tsx @@ -6,7 +6,7 @@ import { cn } from '@/lib/class-names' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' -export function CheckRunCopyButton({ +export function CopyTextButton({ text, label }: { diff --git a/src/renderer/src/components/editor/check-details/panel/CheckRunAnnotations.tsx b/src/renderer/src/components/editor/check-details/panel/CheckRunAnnotations.tsx index 78a1adc908b..9ee92d37c4c 100644 --- a/src/renderer/src/components/editor/check-details/panel/CheckRunAnnotations.tsx +++ b/src/renderer/src/components/editor/check-details/panel/CheckRunAnnotations.tsx @@ -5,7 +5,7 @@ import type { PRCheckAnnotation } from '../../../../../../shared/github/checks/c import { openAnnotationLocation } from '../actions/check-annotation-open' import { getOpenableAnnotationLine } from '../actions/check-annotation-path' import { formatAnnotationsForClipboard } from '../actions/check-run-clipboard-text' -import { CheckRunCopyButton } from './CheckRunCopyButton' +import { CopyTextButton } from '@/components/clipboard/CopyTextButton' export function CheckRunAnnotations({ annotations, @@ -37,7 +37,7 @@ export function CheckRunAnnotations({
{t('auto.components.editor.CheckRunDetailsPanel.f2fe8a4e8f', 'Annotations')}
- diff --git a/src/renderer/src/components/editor/check-details/panel/CheckRunDetailsPanel.tsx b/src/renderer/src/components/editor/check-details/panel/CheckRunDetailsPanel.tsx index fa1feb73714..8bbd247511c 100644 --- a/src/renderer/src/components/editor/check-details/panel/CheckRunDetailsPanel.tsx +++ b/src/renderer/src/components/editor/check-details/panel/CheckRunDetailsPanel.tsx @@ -11,7 +11,7 @@ import { useCheckRunDetailsFixWithAI } from '../actions/check-run-details-fix-wi import { formatCheckRunOutputForClipboard } from '../actions/check-run-clipboard-text' import { CheckRunAnnotations } from './CheckRunAnnotations' import { CheckRunJobs } from './CheckRunJobs' -import { CheckRunCopyButton } from './CheckRunCopyButton' +import { CopyTextButton } from '@/components/clipboard/CopyTextButton' import { LoadingSpinner } from '@/components/LoadingSpinner' import { useCheckDetailsReadingPosition } from '../reading/use-check-details-reading-position' import { openAppHttpLink } from '@/lib/browser/navigation/app-http-link-open' @@ -344,7 +344,7 @@ export function CheckRunDetailsPanel({
{t('auto.components.editor.CheckRunDetailsPanel.d098e5529a', 'Output')}
- - diff --git a/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx b/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx new file mode 100644 index 00000000000..de0a012b49c --- /dev/null +++ b/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.test.tsx @@ -0,0 +1,36 @@ +// @vitest-environment happy-dom +import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { TooltipProvider } from '@/components/ui/tooltip' +import { TerminalErrorToast } from './TerminalErrorToast' + +const { FOOTER } = vi.hoisted(() => ({ + FOOTER: ['---', 'Orca: 1.4.200', 'OS: darwin 25.0.0 (arm64)', 'Shell: /bin/zsh'].join('\n') +})) + +vi.mock('@/app-shell/platform/client-environment-info', () => ({ + resolveClientEnvironmentFooter: vi.fn().mockResolvedValue(FOOTER) +})) + +afterEach(() => { + cleanup() + vi.unstubAllGlobals() +}) + +describe('TerminalErrorToast copy button', () => { + it('copies the error text with its environment footer', async () => { + const writeClipboardText = vi.fn().mockResolvedValue(undefined) + vi.stubGlobal('api', { ui: { writeClipboardText } }) + const error = 'Failed to spawn shell "/bin/zsh": posix_spawn failed (shell: /bin/zsh).' + render( + + + + ) + await screen.findByText(/Orca: 1\.4\.200/) + + fireEvent.click(screen.getByRole('button', { name: 'Copy error details' })) + + await waitFor(() => expect(writeClipboardText).toHaveBeenCalledWith(`${error}\n\n${FOOTER}`)) + }) +}) diff --git a/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.tsx b/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.tsx index 38169e7ba39..764ed8907df 100644 --- a/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.tsx +++ b/src/renderer/src/components/terminal-pane/errors/TerminalErrorToast.tsx @@ -11,6 +11,7 @@ import { useEffect, useState } from 'react' import { AlertTriangle, X } from 'lucide-react' import { useTranslate } from '@/i18n/use-translate' import { Button } from '@/components/ui/button' +import { CopyTextButton } from '@/components/clipboard/CopyTextButton' import { isAgentLaunchOnlyError } from '../launch-outcome/agent-launch-pane-notice-text' import { hasClientEnvironmentFooter } from '../../../../../shared/client-environment-info' import { @@ -88,7 +89,11 @@ export function TerminalErrorToast({ } }, [displayError, showClientEnvironment]) - const footer = environmentFooter?.error === displayError ? environmentFooter.footer : '' + const footer = + showClientEnvironment && environmentFooter?.error === displayError + ? environmentFooter.footer + : '' + const copyText = footer ? `${displayError}\n\n${footer}` : displayError const handleRetry = async (): Promise => { if (!onRetry || retrying) { return @@ -130,14 +135,23 @@ export function TerminalErrorToast({ : t('auto.components.terminal.pane.TerminalErrorToast.errorTitle', 'Terminal error')} - +
+ + +
{displayError}
@@ -163,7 +177,7 @@ export function TerminalErrorToast({ .

) : null} - {showClientEnvironment && footer ? ( + {footer ? (
{footer}
diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index 9ac260809f9..524a9450267 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -4042,7 +4042,8 @@ "remoteTerminalClosed": "Das entfernte Terminal wurde geschlossen.", "ptyAllocationLimit": "Das System kann keine weiteren pty-Geräte zuweisen. Einige ungenutzte Terminals in Orca oder einem anderen Programm schließen und anschließend erneut versuchen.", "terminalProcessLimit": "Das System kann keinen weiteren Terminal-Prozess starten. Ungenutzte Terminals schließen oder ungenutzte Prozesse beenden und anschließend erneut versuchen.", - "hostTerminalCap": "Auf dem Host laufen bereits so viele Terminals, wie Orca zulässt. Ein nicht mehr benötigtes Terminal schließen und anschließend erneut versuchen." + "hostTerminalCap": "Auf dem Host laufen bereits so viele Terminals, wie Orca zulässt. Ein nicht mehr benötigtes Terminal schließen und anschließend erneut versuchen.", + "copyErrorDetails": "Fehlerdetails kopieren" }, "TerminalProcessExitOverlay": { "capacityTitle": "Konsolenlimit von Git Bash erreicht", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index a247e2349b1..2ad1ae847b4 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -4667,7 +4667,8 @@ "terminalProcessLimit": "Your system cannot start another terminal process. Close unused terminals or quit unused processes, then try again.", "hostTerminalCap": "The host is already running as many terminals as Orca allows. Close a terminal you no longer need, then try again.", "title": "Terminal issue", - "errorTitle": "Terminal error" + "errorTitle": "Terminal error", + "copyErrorDetails": "Copy error details" }, "TerminalProcessExitOverlay": { "capacityTitle": "Git Bash console limit reached", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 2a979a85cec..745c5ab801d 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -3532,7 +3532,8 @@ "e16012e31e": "El demonio de terminal propietario de esta sesión salió, por lo que no se pudo recuperar la sesión y su desplazamiento hacia atrás. Abra una nueva terminal para continuar.", "sessionUnavailable": "Orca no pudo volver a conectarse a la sesión de terminal de este panel en el host. Abra una nueva terminal para continuar.", "sourceRestoring": "Reconectando este terminal: se está restableciendo su salida. La sesión aún está en marcha.", - "ownerHostMismatch": "La sesión guardada de este terminal pertenece a otra conexión de host, así que Orca no puede reconectarlo aquí. Abre un terminal nuevo para continuar." + "ownerHostMismatch": "La sesión guardada de este terminal pertenece a otra conexión de host, así que Orca no puede reconectarlo aquí. Abre un terminal nuevo para continuar.", + "copyErrorDetails": "Copiar detalles del error" }, "TerminalProcessExitOverlay": { "capacityTitle": "Se alcanzó el límite de consolas de Git Bash", diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index 4f263bc20a7..4432d5ddbd6 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -3803,7 +3803,8 @@ "ptyAllocationLimit": "Votre système ne peut plus allouer de périphériques pty. Fermez quelques terminaux inutilisés, dans Orca ou dans un autre programme, puis réessayez.", "terminalProcessLimit": "Votre système ne peut pas démarrer un autre processus de terminal. Fermez les terminaux inutilisés ou quittez les processus inutiles, puis réessayez.", "hostTerminalCap": "L'hôte exécute déjà autant de terminaux qu'Orca le permet. Fermez un terminal dont vous n'avez plus besoin, puis réessayez.", - "ownerHostMismatch": "La session enregistrée de ce terminal appartient à une autre connexion d'hôte : Orca ne peut donc pas le rattacher ici. Ouvrez un nouveau terminal pour continuer." + "ownerHostMismatch": "La session enregistrée de ce terminal appartient à une autre connexion d'hôte : Orca ne peut donc pas le rattacher ici. Ouvrez un nouveau terminal pour continuer.", + "copyErrorDetails": "Copier les détails de l'erreur" }, "TerminalProcessExitOverlay": { "capacityTitle": "Limite de consoles Git Bash atteinte", diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index a9748f3ce2f..5d97d7fc551 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -3474,7 +3474,8 @@ "ptyAllocationLimit": "システムはこれ以上 pty デバイスを割り当てられません。Orca または他のプログラムで使っていないターミナルをいくつか閉じてから、もう一度お試しください。", "terminalProcessLimit": "システムはこれ以上ターミナルプロセスを起動できません。使っていないターミナルを閉じるか、不要なプロセスを終了してから、もう一度お試しください。", "hostTerminalCap": "ホストではすでに Orca が許可する上限までターミナルが実行されています。不要になったターミナルを閉じてから、もう一度お試しください。", - "ownerHostMismatch": "このターミナルの保存済みセッションは別のホスト接続に属しているため、Orca はここで再接続できません。続行するには、新規ターミナルを開いてください。" + "ownerHostMismatch": "このターミナルの保存済みセッションは別のホスト接続に属しているため、Orca はここで再接続できません。続行するには、新規ターミナルを開いてください。", + "copyErrorDetails": "エラーの詳細をコピー" }, "TerminalProcessExitOverlay": { "capacityTitle": "Git Bash のコンソール上限に達しました", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index 808367615a4..5a03675cf14 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -3474,7 +3474,8 @@ "ptyAllocationLimit": "시스템에서 더 이상 pty 장치를 할당할 수 없습니다. Orca 또는 다른 프로그램에서 사용하지 않는 터미널을 몇 개 닫은 후 다시 시도하세요.", "terminalProcessLimit": "시스템에서 터미널 프로세스를 더 시작할 수 없습니다. 사용하지 않는 터미널을 닫거나 불필요한 프로세스를 종료한 후 다시 시도하세요.", "hostTerminalCap": "호스트에서 이미 Orca가 허용하는 최대 개수의 터미널이 실행 중입니다. 더 이상 필요 없는 터미널을 닫은 후 다시 시도하세요.", - "ownerHostMismatch": "이 터미널의 저장된 세션은 다른 호스트 연결에 속해 있어 Orca가 여기에서 다시 연결할 수 없습니다. 계속하려면 새 터미널을 여세요." + "ownerHostMismatch": "이 터미널의 저장된 세션은 다른 호스트 연결에 속해 있어 Orca가 여기에서 다시 연결할 수 없습니다. 계속하려면 새 터미널을 여세요.", + "copyErrorDetails": "오류 세부 정보 복사" }, "TerminalProcessExitOverlay": { "capacityTitle": "Git Bash 콘솔 한도에 도달했습니다", diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index 430afbb6599..ba33287a3a7 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -16803,7 +16803,8 @@ "ownerHostMismatch": "A sessão salva deste terminal pertence a outra conexão de host, então o Orca não pode reconectá-la aqui. Abra um novo terminal para continuar.", "ptyAllocationLimit": "Seu sistema não consegue alocar mais dispositivos pty. Feche alguns terminais que você não está usando, no Orca ou em outro programa, e tente novamente.", "terminalProcessLimit": "Seu sistema não consegue iniciar outro processo de terminal. Feche terminais ou processos sem uso e tente novamente.", - "hostTerminalCap": "O host já está executando o máximo de terminais permitido pelo Orca. Feche um terminal de que não precisa mais e tente novamente." + "hostTerminalCap": "O host já está executando o máximo de terminais permitido pelo Orca. Feche um terminal de que não precisa mais e tente novamente.", + "copyErrorDetails": "Copiar detalhes do erro" }, "CloseTerminalDialog": { "1d1a7a9c1f": "Cancelar", diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index e9fbe09bf64..07dfea7c58e 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -4133,7 +4133,8 @@ "remoteTerminalClosed": "Удалённый терминал закрыт.", "ptyAllocationLimit": "Система не может выделить больше устройств pty. Закройте неиспользуемые терминалы в Orca или других программах и повторите попытку.", "terminalProcessLimit": "Система не может запустить ещё один процесс терминала. Закройте неиспользуемые терминалы или процессы и повторите попытку.", - "hostTerminalCap": "На этом компьютере уже запущено максимальное разрешённое Orca число терминалов. Закройте ненужный терминал и повторите попытку." + "hostTerminalCap": "На этом компьютере уже запущено максимальное разрешённое Orca число терминалов. Закройте ненужный терминал и повторите попытку.", + "copyErrorDetails": "Копировать сведения об ошибке" }, "TerminalProcessExitOverlay": { "capacityTitle": "Достигнут лимит консолей Git Bash", diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index a400a0cb018..c2a782a8066 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -4011,7 +4011,8 @@ "remoteTerminalClosed": "Uzak terminal kapatıldı.", "ptyAllocationLimit": "Sisteminiz daha fazla pty aygıtı ayıramıyor. Orca'da veya başka bir programda kullanmadığınız terminalleri kapatıp tekrar deneyin.", "terminalProcessLimit": "Sisteminiz başka bir terminal süreci başlatamıyor. Kullanmadığınız terminalleri kapatın veya kullanılmayan süreçlerden çıkıp tekrar deneyin.", - "hostTerminalCap": "Bu ana makine zaten Orca'nın izin verdiği en yüksek sayıda terminali çalıştırıyor. Artık ihtiyacınız olmayan bir terminali kapatıp tekrar deneyin." + "hostTerminalCap": "Bu ana makine zaten Orca'nın izin verdiği en yüksek sayıda terminali çalıştırıyor. Artık ihtiyacınız olmayan bir terminali kapatıp tekrar deneyin.", + "copyErrorDetails": "Hata ayrıntılarını kopyala" }, "TerminalProcessExitOverlay": { "capacityTitle": "Git Bash konsol sınırına ulaşıldı", diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index 93b624a158d..c74e27d468e 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -3967,7 +3967,8 @@ "remoteTerminalClosed": "遠端終端機已關閉。", "ptyAllocationLimit": "系統無法再分配 pty 裝置。請在 Orca 或其他程式中關閉一些不用的終端機,然後重試。", "terminalProcessLimit": "系統無法再啟動終端機行程。請關閉不用的終端機或結束不用的行程,然後重試。", - "hostTerminalCap": "主機上執行的終端機數量已達到 Orca 允許的上限。請關閉一個不再需要的終端機,然後重試。" + "hostTerminalCap": "主機上執行的終端機數量已達到 Orca 允許的上限。請關閉一個不再需要的終端機,然後重試。", + "copyErrorDetails": "複製錯誤詳細資訊" }, "TerminalProcessExitOverlay": { "capacityTitle": "已達到 Git Bash 主控台上限", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 478e1564c8b..3ad3cf9dd85 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -3669,7 +3669,8 @@ "ptyAllocationLimit": "系统无法再分配 pty 设备,请在 Orca 或其他程序中关闭一些不用的终端,然后重试", "terminalProcessLimit": "系统无法再启动终端进程,请关闭不用的终端或退出不用的进程,然后重试", "hostTerminalCap": "主机上运行的终端数量已达到 Orca 允许的上限,请关闭一个不再需要的终端,然后重试", - "ownerHostMismatch": "此终端保存的会话属于另一个主机连接,因此 Orca 无法在此重新附加它,请打开新终端以继续" + "ownerHostMismatch": "此终端保存的会话属于另一个主机连接,因此 Orca 无法在此重新附加它,请打开新终端以继续", + "copyErrorDetails": "复制错误详情" }, "TerminalProcessExitOverlay": { "capacityTitle": "已达到 Git Bash 控制台上限",