Skip to content

Commit d071329

Browse files
committed
Improve performance insight details
Assisted-By: devx/633e51ab-4160-4b2c-a196-017418800531
1 parent cce36c8 commit d071329

3 files changed

Lines changed: 66 additions & 15 deletions

File tree

packages/devtools-ui/src/components/PerformanceInsights.tsx

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,35 @@ function DependencyList({
8787
);
8888
}
8989

90+
function TriggerSource({
91+
occurrence,
92+
}: {
93+
occurrence: NoOutputChangeOccurrence;
94+
}) {
95+
if (!occurrence.subscribedTo) {
96+
return <span className="performance-muted">Unknown source</span>;
97+
}
98+
99+
const dependency = occurrence.allDependencies?.find(
100+
candidate => candidate.id === occurrence.subscribedTo
101+
);
102+
if (!dependency) {
103+
return (
104+
<code className="performance-trigger-id">{occurrence.subscribedTo}</code>
105+
);
106+
}
107+
108+
return (
109+
<span className="performance-trigger-source">
110+
<span className={`performance-dependency-type ${dependency.type}`}>
111+
{dependency.type}
112+
</span>
113+
<strong>{dependency.name || "(anonymous)"}</strong>
114+
<code className="performance-trigger-id">{dependency.id}</code>
115+
</span>
116+
);
117+
}
118+
90119
function OccurrenceRow({
91120
occurrence,
92121
}: {
@@ -96,11 +125,8 @@ function OccurrenceRow({
96125
<li className="performance-occurrence">
97126
<div className="performance-occurrence-row">
98127
<span className="performance-occurrence-label">Triggered by</span>
99-
<span
100-
className="performance-occurrence-value"
101-
title={occurrence.subscribedTo}
102-
>
103-
{occurrence.subscribedTo || "Unknown source"}
128+
<span className="performance-occurrence-value">
129+
<TriggerSource occurrence={occurrence} />
104130
</span>
105131
</div>
106132
<div className="performance-occurrence-row">
@@ -293,9 +319,8 @@ export function PerformanceInsights() {
293319
aria-label={`${isOpen ? "Hide" : "Inspect"} recent causes for ${summary.signalName || "anonymous computed"}`}
294320
>
295321
<span aria-hidden="true">
296-
{isOpen ? "" : ""}
322+
{isOpen ? "" : ""}
297323
</span>
298-
{isOpen ? "Hide causes" : "Inspect causes"}
299324
</button>
300325
</div>
301326
</td>

packages/devtools-ui/src/styles.css

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -939,18 +939,21 @@ body {
939939
}
940940

941941
.performance-expand-toggle {
942+
order: -1;
942943
display: inline-flex;
943944
align-items: center;
944-
gap: 4px;
945+
justify-content: center;
945946
flex: none;
946-
padding: 2px 6px;
947-
border: 1px solid var(--border-primary);
947+
inline-size: 20px;
948+
block-size: 20px;
949+
padding: 0;
950+
border: 0;
948951
border-radius: 3px;
949-
background: var(--bg-secondary);
950-
color: var(--text-secondary);
952+
background: none;
953+
color: var(--text-muted);
951954
cursor: pointer;
952955
font: inherit;
953-
font-size: 10px;
956+
font-size: 9px;
954957
}
955958

956959
.performance-expand-toggle:hover {
@@ -1019,6 +1022,24 @@ body {
10191022
word-break: break-all;
10201023
}
10211024

1025+
.performance-trigger-source {
1026+
display: inline-flex;
1027+
align-items: center;
1028+
gap: 6px;
1029+
font-family: inherit;
1030+
}
1031+
1032+
.performance-trigger-source strong {
1033+
font-family: inherit;
1034+
font-weight: 600;
1035+
word-break: normal;
1036+
}
1037+
1038+
.performance-trigger-id {
1039+
color: var(--text-faint);
1040+
font-size: 10px;
1041+
}
1042+
10221043
.performance-occurrence-deps {
10231044
margin-top: 6px;
10241045
}

packages/devtools-ui/test/browser/index.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ describe("@preact/signals-devtools-ui", () => {
13031303
);
13041304
expect(inspectButton).to.not.be.null;
13051305
expect(inspectButton!.getAttribute("aria-expanded")).to.equal("false");
1306+
expect(inspectButton!.textContent).to.equal("▶");
13061307

13071308
// Before expanding, occurrence details are not rendered.
13081309
expect(scratch.querySelector(".performance-occurrence-detail")).to.be
@@ -1312,11 +1313,15 @@ describe("@preact/signals-devtools-ui", () => {
13121313
inspectButton!.click();
13131314
});
13141315
expect(inspectButton!.getAttribute("aria-expanded")).to.equal("true");
1316+
expect(inspectButton!.textContent).to.equal("▼");
13151317

13161318
const detail = scratch.querySelector(".performance-occurrence-detail");
13171319
expect(detail).to.not.be.null;
1318-
expect(detail!.textContent).to.contain("signal-count");
1319-
expect(detail!.textContent).to.contain("count");
1320+
const trigger = detail!.querySelector(".performance-trigger-source");
1321+
expect(trigger).to.not.be.null;
1322+
expect(trigger!.textContent).to.contain("signal");
1323+
expect(trigger!.textContent).to.contain("count");
1324+
expect(trigger!.textContent).to.contain("signal-count");
13201325
expect(detail!.textContent).to.contain("Triggered by");
13211326
expect(detail!.textContent).to.contain("Current dependencies");
13221327
});

0 commit comments

Comments
 (0)