From 9070e954d33672663682b65de1054c95a0079dc9 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 10 Feb 2025 10:25:40 +0100 Subject: [PATCH] plumb commit info --- packages/trace-viewer/src/ui/errorsTab.tsx | 7 ++++++- packages/trace-viewer/src/ui/uiModeView.tsx | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/trace-viewer/src/ui/errorsTab.tsx b/packages/trace-viewer/src/ui/errorsTab.tsx index f0c52742c1..a3dff64413 100644 --- a/packages/trace-viewer/src/ui/errorsTab.tsx +++ b/packages/trace-viewer/src/ui/errorsTab.tsx @@ -24,6 +24,9 @@ import type { StackFrame } from '@protocol/channels'; import { CopyToClipboardTextButton } from './copyToClipboard'; import { attachmentURL } from './attachmentsTab'; import { fixTestPrompt } from '@web/components/prompts'; +import type { GitCommitInfo } from '@testIsomorphic/types'; + +export const GitCommitInfoContext = React.createContext(undefined); const PromptButton: React.FC<{ error: string; @@ -44,7 +47,9 @@ const PromptButton: React.FC<{ } }, [actions]); - const prompt = React.useMemo(() => fixTestPrompt(error, undefined, pageSnapshot), [error, pageSnapshot]); + const gitCommitInfo = React.useContext(GitCommitInfoContext); + console.log({ gitCommitInfo }) + const prompt = React.useMemo(() => fixTestPrompt(error, gitCommitInfo?.['pull.diff'] ?? gitCommitInfo?.['revision.diff'], pageSnapshot), [error, gitCommitInfo, pageSnapshot]); return Copied } style={{ width: '90px', justifyContent: 'center' }} />; }; diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index 4375018765..e808058868 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -37,6 +37,8 @@ import { TestListView } from './uiModeTestListView'; import { TraceView } from './uiModeTraceView'; import { SettingsView } from './settingsView'; import { DefaultSettingsView } from './defaultSettingsView'; +import type { GitCommitInfo } from '@testIsomorphic/types'; +import { GitCommitInfoContext } from './errorsTab'; let xtermSize = { cols: 80, rows: 24 }; const xtermDataSource: XtermDataSource = { @@ -397,6 +399,8 @@ export const UIModeView: React.FC<{}> = ({ }); }, [closeInstallDialog, testServerConnection]); + const gitCommitInfo = React.useMemo(() => testModel?.config.metadata['git.commit.info'] as GitCommitInfo | undefined, [testModel]); + return
{!hasBrowsers &&
Install browsers
@@ -430,13 +434,15 @@ export const UIModeView: React.FC<{}> = ({
- testServerConnection?.openNoReply({ location: { file: location.file, line: location.line, column: location.column } })} - /> + + testServerConnection?.openNoReply({ location: { file: location.file, line: location.line, column: location.column } })} + /> +
} sidebar={