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 <noreply@anthropic.com>
This commit is contained in:
Neil
2026-11-15 01:28:50 -08:00
committed by GitHub
co-authored by Claude
parent 4e834bf939
commit f7d4fe072b
17 changed files with 89 additions and 28 deletions
@@ -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
}: {
@@ -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({
<div className="text-sm font-medium">
{t('auto.components.editor.CheckRunDetailsPanel.f2fe8a4e8f', 'Annotations')}
</div>
<CheckRunCopyButton
<CopyTextButton
text={clipboardText}
label={t('auto.components.editor.CheckRunAnnotations.copy', 'Copy annotations')}
/>
@@ -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({
<div className="text-sm font-medium">
{t('auto.components.editor.CheckRunDetailsPanel.d098e5529a', 'Output')}
</div>
<CheckRunCopyButton
<CopyTextButton
text={outputClipboardText}
label={t(
'auto.components.editor.CheckRunDetailsPanel.copyOutput',
@@ -23,7 +23,7 @@ import {
type StepOutcome
} from '../../../../../../shared/source-control/checks/pr-check-step-status'
import { formatJobsForClipboard } from '../actions/check-run-clipboard-text'
import { CheckRunCopyButton } from './CheckRunCopyButton'
import { CopyTextButton } from '@/components/clipboard/CopyTextButton'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
@@ -250,7 +250,7 @@ export function CheckRunJobs({
? t('auto.components.editor.CheckRunDetailsPanel.066fedd446', 'Failed jobs')
: t('auto.components.editor.CheckRunDetailsPanel.49731703ea', 'Jobs')}
</div>
<CheckRunCopyButton
<CopyTextButton
text={clipboardText}
label={t('auto.components.editor.CheckRunJobs.copy', 'Copy jobs')}
/>
@@ -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(
<TooltipProvider>
<TerminalErrorToast error={error} onDismiss={vi.fn()} />
</TooltipProvider>
)
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}`))
})
})
@@ -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<void> => {
if (!onRetry || retrying) {
return
@@ -130,14 +135,23 @@ export function TerminalErrorToast({
: t('auto.components.terminal.pane.TerminalErrorToast.errorTitle', 'Terminal error')}
</div>
</div>
<Button
variant="ghost"
size="icon-xs"
onClick={onDismiss}
aria-label={t('terminal.paneTopBanner.dismiss', 'Dismiss')}
>
<X />
</Button>
<div className="flex shrink-0 items-center gap-1">
<CopyTextButton
text={copyText}
label={t(
'auto.components.terminal.pane.TerminalErrorToast.copyErrorDetails',
'Copy error details'
)}
/>
<Button
variant="ghost"
size="icon-xs"
onClick={onDismiss}
aria-label={t('terminal.paneTopBanner.dismiss', 'Dismiss')}
>
<X />
</Button>
</div>
</div>
<div className="shrink-0 px-4 pb-4">
<div className="whitespace-pre-wrap break-words text-sm leading-5">{displayError}</div>
@@ -163,7 +177,7 @@ export function TerminalErrorToast({
.
</p>
) : null}
{showClientEnvironment && footer ? (
{footer ? (
<div className="mt-3 whitespace-pre-wrap break-words font-mono text-xs text-muted-foreground">
{footer}
</div>
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -3474,7 +3474,8 @@
"ptyAllocationLimit": "システムはこれ以上 pty デバイスを割り当てられません。Orca または他のプログラムで使っていないターミナルをいくつか閉じてから、もう一度お試しください。",
"terminalProcessLimit": "システムはこれ以上ターミナルプロセスを起動できません。使っていないターミナルを閉じるか、不要なプロセスを終了してから、もう一度お試しください。",
"hostTerminalCap": "ホストではすでに Orca が許可する上限までターミナルが実行されています。不要になったターミナルを閉じてから、もう一度お試しください。",
"ownerHostMismatch": "このターミナルの保存済みセッションは別のホスト接続に属しているため、Orca はここで再接続できません。続行するには、新規ターミナルを開いてください。"
"ownerHostMismatch": "このターミナルの保存済みセッションは別のホスト接続に属しているため、Orca はここで再接続できません。続行するには、新規ターミナルを開いてください。",
"copyErrorDetails": "エラーの詳細をコピー"
},
"TerminalProcessExitOverlay": {
"capacityTitle": "Git Bash のコンソール上限に達しました",
+2 -1
View File
@@ -3474,7 +3474,8 @@
"ptyAllocationLimit": "시스템에서 더 이상 pty 장치를 할당할 수 없습니다. Orca 또는 다른 프로그램에서 사용하지 않는 터미널을 몇 개 닫은 후 다시 시도하세요.",
"terminalProcessLimit": "시스템에서 터미널 프로세스를 더 시작할 수 없습니다. 사용하지 않는 터미널을 닫거나 불필요한 프로세스를 종료한 후 다시 시도하세요.",
"hostTerminalCap": "호스트에서 이미 Orca가 허용하는 최대 개수의 터미널이 실행 중입니다. 더 이상 필요 없는 터미널을 닫은 후 다시 시도하세요.",
"ownerHostMismatch": "이 터미널의 저장된 세션은 다른 호스트 연결에 속해 있어 Orca가 여기에서 다시 연결할 수 없습니다. 계속하려면 새 터미널을 여세요."
"ownerHostMismatch": "이 터미널의 저장된 세션은 다른 호스트 연결에 속해 있어 Orca가 여기에서 다시 연결할 수 없습니다. 계속하려면 새 터미널을 여세요.",
"copyErrorDetails": "오류 세부 정보 복사"
},
"TerminalProcessExitOverlay": {
"capacityTitle": "Git Bash 콘솔 한도에 도달했습니다",
+2 -1
View File
@@ -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",
+2 -1
View File
@@ -4133,7 +4133,8 @@
"remoteTerminalClosed": "Удалённый терминал закрыт.",
"ptyAllocationLimit": "Система не может выделить больше устройств pty. Закройте неиспользуемые терминалы в Orca или других программах и повторите попытку.",
"terminalProcessLimit": "Система не может запустить ещё один процесс терминала. Закройте неиспользуемые терминалы или процессы и повторите попытку.",
"hostTerminalCap": "На этом компьютере уже запущено максимальное разрешённое Orca число терминалов. Закройте ненужный терминал и повторите попытку."
"hostTerminalCap": "На этом компьютере уже запущено максимальное разрешённое Orca число терминалов. Закройте ненужный терминал и повторите попытку.",
"copyErrorDetails": "Копировать сведения об ошибке"
},
"TerminalProcessExitOverlay": {
"capacityTitle": "Достигнут лимит консолей Git Bash",
+2 -1
View File
@@ -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ı",
+2 -1
View File
@@ -3967,7 +3967,8 @@
"remoteTerminalClosed": "遠端終端機已關閉。",
"ptyAllocationLimit": "系統無法再分配 pty 裝置。請在 Orca 或其他程式中關閉一些不用的終端機,然後重試。",
"terminalProcessLimit": "系統無法再啟動終端機行程。請關閉不用的終端機或結束不用的行程,然後重試。",
"hostTerminalCap": "主機上執行的終端機數量已達到 Orca 允許的上限。請關閉一個不再需要的終端機,然後重試。"
"hostTerminalCap": "主機上執行的終端機數量已達到 Orca 允許的上限。請關閉一個不再需要的終端機,然後重試。",
"copyErrorDetails": "複製錯誤詳細資訊"
},
"TerminalProcessExitOverlay": {
"capacityTitle": "已達到 Git Bash 主控台上限",
+2 -1
View File
@@ -3669,7 +3669,8 @@
"ptyAllocationLimit": "系统无法再分配 pty 设备,请在 Orca 或其他程序中关闭一些不用的终端,然后重试",
"terminalProcessLimit": "系统无法再启动终端进程,请关闭不用的终端或退出不用的进程,然后重试",
"hostTerminalCap": "主机上运行的终端数量已达到 Orca 允许的上限,请关闭一个不再需要的终端,然后重试",
"ownerHostMismatch": "此终端保存的会话属于另一个主机连接,因此 Orca 无法在此重新附加它,请打开新终端以继续"
"ownerHostMismatch": "此终端保存的会话属于另一个主机连接,因此 Orca 无法在此重新附加它,请打开新终端以继续",
"copyErrorDetails": "复制错误详情"
},
"TerminalProcessExitOverlay": {
"capacityTitle": "已达到 Git Bash 控制台上限",