Skip to content

Commit e77f937

Browse files
committed
fix(BlockedThreads): adapt SVG tree colors for dark mode
D3 SVG text defaults to fill:black and links had hardcoded #ccc/#333 strokes — both invisible in dark mode. Read isDark at render time to set text fill and link stroke to appropriate light/dark values. Re-draw trees when the theme changes via watch(isDark). Assisted-by: GitHub Copilot (Claude Sonnet 4.5)
1 parent 85dcec1 commit e77f937

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

frontend/src/components/threaddump/BlockedThreads.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import * as d3 from 'd3';
2020
import { useAnalysisApiRequester } from '@/composables/analysis-api-requester';
2121
import { tdt } from '@/i18n/i18n';
2222
import { useI18n } from 'vue-i18n';
23+
import { isDark } from '@/composables/theme';
2324
import Thread from '@/components/threaddump/Thread.vue';
2425
2526
const { request } = useAnalysisApiRequester();
@@ -64,6 +65,11 @@ function openThread(id: number) {
6465
}
6566
6667
function renderTree(svgEl: SVGSVGElement, root: TreeNode) {
68+
const dark = isDark.value;
69+
const textColor = dark ? '#e0e0e0' : '#303133';
70+
const linkColor = dark ? '#555' : '#ccc';
71+
const linkHoverColor = dark ? '#aaa' : '#333';
72+
6773
const margin = { top: 0, right: 0, bottom: 0, left: 40 };
6874
const neededHeight = Math.max(60, root.children!.length * 25);
6975
const width = 660 - margin.left - margin.right;
@@ -127,9 +133,15 @@ function renderTree(svgEl: SVGSVGElement, root: TreeNode) {
127133
.attr('y', 0)
128134
.style('text-anchor', 'start')
129135
.style('font', '13px sans-serif')
136+
.style('fill', textColor)
130137
.style('cursor', 'pointer')
131138
.text((d) => (d.data as TreeNode).name)
132139
.on('click', (_e, d) => openThread((d.data as TreeNode).id));
140+
141+
// Apply dynamic link colors via inline styles so dark/light mode is respected.
142+
svg.selectAll<SVGPathElement, unknown>('.link')
143+
.style('stroke', linkColor);
144+
svgEl.style.setProperty('--link-hover-color', linkHoverColor);
133145
}
134146
135147
function buildTree(bt: VBlockingThread): TreeNode {
@@ -171,6 +183,9 @@ onMounted(() => {
171183
onBeforeUpdate(() => {
172184
svgRefs.value = [];
173185
});
186+
187+
// Re-draw when the user switches between light and dark mode.
188+
watch(isDark, () => drawTrees());
174189
</script>
175190

176191
<template>
@@ -206,11 +221,10 @@ onBeforeUpdate(() => {
206221
<style scoped>
207222
:deep(.link) {
208223
fill: none;
209-
stroke: #ccc;
210224
stroke-width: 1px;
211225
}
212226
:deep(.link:hover) {
213-
stroke: #333;
227+
stroke: var(--link-hover-color, #333);
214228
stroke-width: 2px;
215229
}
216230
:deep(.node circle) {

0 commit comments

Comments
 (0)