Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trace viewer): link from attach action to attachment tab #33265

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Oct 24, 2024

Adds a button to attach steps that opens up the Attachment tab and scrolls the selected attachment into view.

Screen.Recording.2024-10-24.at.11.02.32.mov

I've added a couple of ARIA props to make this easier to test.

@Skn0tt Skn0tt requested a review from dgozman October 24, 2024 09:05
@Skn0tt Skn0tt self-assigned this Oct 24, 2024

This comment has been minimized.

{showDuration && <div className='action-duration'>{time || <span className='codicon codicon-loading'></span>}</div>}
{showAttachments && <ToolbarButton icon='attach' title='Open Attachment' onClick={revealAttachments} />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps put this to the left of the duration? Misaligned durations look ugly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed: Screenshot 2024-10-24 at 14 33 00

const title = <span style={{ marginLeft: 5 }}>
{linkifyText(attachment.name)} {hasContent && <a style={{ marginLeft: 5 }} href={downloadURL(attachment)}>download</a>}
const title = <span style={{ marginLeft: 5 }} ref={ref} title={attachment.name}>
<span style={highlight ? { textDecoration: 'underline var(--vscode-terminal-findMatchBackground)', textDecorationThickness: 1.5 } : {}}>{linkifyText(attachment.name)}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually add a className conditionally, and then put all styles into a css file.

</div>;
})}
</div>;
};

function isActiveAttachment(attachment: Attachment, activeAction: ActionTraceEventInContext | undefined): boolean {
return activeAction?.attachments?.some(a => a.name === attachment.name && a.path === attachment.path && a.sha1 === attachment.sha1) ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just activeAction?.attachments?.includes(attachment)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried that, but it doesn't work because referential equality is lost in

attachments.add({ ...attachment, traceUrl });

@@ -82,9 +82,9 @@ export const TabbedPane: React.FunctionComponent<{
tabs.map(tab => {
const className = 'tab-content tab-' + tab.id;
if (tab.component)
return <div key={tab.id} className={className} style={{ display: selectedTab === tab.id ? 'inherit' : 'none' }}>{tab.component}</div>;
return <div key={tab.id} id={`tab-${tab.id}`} role='tabpanel' title={tab.title} className={className} style={{ display: selectedTab === tab.id ? 'inherit' : 'none' }}>{tab.component}</div>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I am not sure you'd like the whole tabpanel to have this title. I'd expect titles on internal elements of the tab content, not a single one covering the whole panel.
  • I am afraid that ids will clash between various tabbed pane. Should we prefix them with some unique value for this TabbedPane?

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

</div>;
})}
</div>;
};

function isActiveAttachment(attachment: Attachment, activeAction: ActionTraceEventInContext | undefined): boolean {
return activeAction?.attachments?.some(a => a.name === attachment.name && a.path === attachment.path && a.sha1 === attachment.sha1) ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I guess if there are multiple attachments for the activeAction, you probably want to reveal just the first one?
  • It seems to me that merely selecting a different action will reveal its attachments? Is that the UI we'd like? I'd prefer highlighting them instead, and only reveal upon an explicit button click.


const isTextAttachment = isTextualMimeType(attachment.contentType);
const hasContent = !!attachment.sha1 || !!attachment.path;

React.useEffect(() => {
if (highlight)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this scrolls, the prop should be called reveal, leaving highlight for visual indication instead.

onSelect?: (id: string) => void
}> = ({ id, title, count, errorCount, selected, onSelect }) => {
onSelect?: (id: string) => void,
'aria-controls'?: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ariaControls? It is very strange to see a property named like this :)

This comment has been minimized.

@Skn0tt
Copy link
Member Author

Skn0tt commented Nov 4, 2024

I've incorporated your changes by splitting up highlight and reveal and making it only reveal the first attachment.

This comment has been minimized.

This comment has been minimized.

@@ -296,6 +298,10 @@ export const Workbench: React.FunctionComponent<{
setSelectedTime={setSelectedTime}
onSelected={onActionSelected}
onHighlighted={setHighlightedAction}
revealAttachment={attachment => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to React.useCallback() here to avoid a new function instance every time.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Test results for "tests 1"

5 failed
❌ [chromium-library] › library/screenshot.spec.ts:25:14 › page screenshot › should run in parallel in multiple pages @chromium-ubuntu-22.04-node18
❌ [chromium-library] › library/screenshot.spec.ts:25:14 › page screenshot › should run in parallel in multiple pages @chromium-ubuntu-22.04-node20
❌ [chromium-library] › library/screenshot.spec.ts:25:14 › page screenshot › should run in parallel in multiple pages @chromium-ubuntu-22.04-node22
❌ [chromium-library] › library/emulation-focus.spec.ts:104:3 › should not affect screenshots @ubuntu-20.04-chromium-tip-of-tree
❌ [chromium-library] › library/screenshot.spec.ts:25:14 › page screenshot › should run in parallel in multiple pages @ubuntu-20.04-chromium-tip-of-tree

5 flaky ⚠️ [chromium-library] › library/emulation-focus.spec.ts:104:3 › should not affect screenshots @chromium-ubuntu-22.04-node20
⚠️ [chromium-library] › library/video.spec.ts:381:5 › screencast › should capture navigation @chromium-ubuntu-22.04-node22
⚠️ [firefox-library] › library/inspector/cli-codegen-python-async.spec.ts:26:5 › should print the correct imports and context options @firefox-ubuntu-22.04-node18
⚠️ [webkit-library] › library/browsercontext-clearcookies.spec.ts:92:3 › should remove cookies by domain @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/inspector/cli-codegen-java.spec.ts:107:5 › should print the correct imports in junit @webkit-ubuntu-22.04-node18

36747 passed, 670 skipped
✔️✔️✔️

Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants