fix: keep terminal charts visible during scan refresh

This commit is contained in:
2569718930@qq.com
2026-05-28 09:07:09 +08:00
parent 651a93cacf
commit b239ad131f
5 changed files with 31 additions and 7 deletions
@@ -702,7 +702,7 @@ export function LiveTemperatureThresholdChart({
actions={timeframeActions} actions={timeframeActions}
className={PEAK_GLOW_PANEL_CLASS[peakGlow.state]} className={PEAK_GLOW_PANEL_CLASS[peakGlow.state]}
> >
<div className="flex h-full min-h-[300px] flex-col"> <div className={clsx("flex h-full flex-col", compact ? "min-h-0" : "min-h-[300px]")}>
<TemperatureStatsBars <TemperatureStatsBars
isEn={isEn} isEn={isEn}
compact={compact} compact={compact}
@@ -115,7 +115,8 @@ export function TemperatureChartCanvas({
const canRenderChart = chartSize.width > 0 && chartSize.height > 0; const canRenderChart = chartSize.width > 0 && chartSize.height > 0;
const chartWidth = Math.max(1, chartSize.width); const chartWidth = Math.max(1, chartSize.width);
const chartHeight = Math.max(220, chartSize.height); const minChartHeight = compact ? 120 : 220;
const chartHeight = Math.max(minChartHeight, chartSize.height);
const individualRunwaySeriesCount = chartSeries.filter( const individualRunwaySeriesCount = chartSeries.filter(
(series) => series.key.startsWith("runway_") && series.key !== "runway_max", (series) => series.key.startsWith("runway_") && series.key !== "runway_max",
).length; ).length;
@@ -125,7 +126,7 @@ export function TemperatureChartCanvas({
chartSeries.some((series) => series.key === "runway_max"); chartSeries.some((series) => series.key === "runway_max");
return ( return (
<div className="relative flex min-h-[240px] flex-1 flex-col p-2"> <div className={clsx("relative flex flex-1 flex-col p-2", compact ? "min-h-[120px]" : "min-h-[240px]")}>
<div className="flex flex-wrap items-center gap-x-4 gap-y-1.5 px-3 py-1.5 text-[11px] border-b border-[#e2e8f0] bg-white"> <div className="flex flex-wrap items-center gap-x-4 gap-y-1.5 px-3 py-1.5 text-[11px] border-b border-[#e2e8f0] bg-white">
{chartSeries.length > 1 && {chartSeries.length > 1 &&
chartSeries chartSeries
@@ -187,7 +188,7 @@ export function TemperatureChartCanvas({
</span> </span>
)} )}
</div> </div>
<div ref={chartHostRef} className="relative min-h-[220px] flex-1"> <div ref={chartHostRef} className={clsx("relative flex-1", compact ? "min-h-[120px]" : "min-h-[220px]")}>
{canRenderChart && ( {canRenderChart && (
<ReComposedChart <ReComposedChart
width={chartWidth} width={chartWidth}
@@ -19,6 +19,10 @@ export function runTests() {
path.join(projectRoot, "components", "dashboard", "scan-terminal", "LiveTemperatureThresholdChart.tsx"), path.join(projectRoot, "components", "dashboard", "scan-terminal", "LiveTemperatureThresholdChart.tsx"),
"utf8", "utf8",
); );
const chartCanvasSource = fs.readFileSync(
path.join(projectRoot, "components", "dashboard", "scan-terminal", "TemperatureChartCanvas.tsx"),
"utf8",
);
assert( assert(
dashboardSource.includes("MAX_TERMINAL_CHARTS = 9"), dashboardSource.includes("MAX_TERMINAL_CHARTS = 9"),
@@ -55,4 +59,10 @@ export function runTests() {
chartSource.includes("lastAppliedPatchRevisionRef.current = 0;"), chartSource.includes("lastAppliedPatchRevisionRef.current = 0;"),
"switching city slots must clear the previous live temperature so Fahrenheit values cannot leak into Celsius charts", "switching city slots must clear the previous live temperature so Fahrenheit values cannot leak into Celsius charts",
); );
assert(
chartSource.includes('compact ? "min-h-0" : "min-h-[300px]"') &&
chartCanvasSource.includes("const minChartHeight = compact ? 120 : 220") &&
chartCanvasSource.includes('compact ? "min-h-[120px]" : "min-h-[220px]"'),
"compact grid charts must not force desktop minimum heights that get clipped inside 3x3 terminal slots",
);
} }
+11
View File
@@ -36,3 +36,14 @@ def test_scan_terminal_prewarm_is_lazy_by_default():
"if _scan_terminal_prewarm_enabled():\n start_scan_terminal_prewarm()", "if _scan_terminal_prewarm_enabled():\n start_scan_terminal_prewarm()",
"", "",
) )
def test_scan_terminal_backend_timeout_returns_before_next_proxy_abort():
import web.services.scan_terminal_config as scan_terminal_config
route_source = (
ROOT / "frontend" / "app" / "api" / "scan" / "terminal" / "route.ts"
).read_text(encoding="utf-8")
assert 'POLYWEATHER_SCAN_TERMINAL_PROXY_TIMEOUT_MS || "28000"' in route_source
assert scan_terminal_config.SCAN_TERMINAL_BUILD_TIMEOUT_SEC <= 24
+5 -3
View File
@@ -29,9 +29,11 @@ SCAN_TERMINAL_PAYLOAD_TTL_SEC = min(
SCAN_ROWS_REFRESH_SEC, SCAN_ROWS_REFRESH_SEC,
max(10, int(os.getenv("POLYWEATHER_SCAN_TERMINAL_PAYLOAD_TTL_SEC", str(SCAN_ROWS_REFRESH_SEC)))), max(10, int(os.getenv("POLYWEATHER_SCAN_TERMINAL_PAYLOAD_TTL_SEC", str(SCAN_ROWS_REFRESH_SEC)))),
) )
SCAN_TERMINAL_BUILD_TIMEOUT_SEC = max( SCAN_TERMINAL_BUILD_TIMEOUT_SEC = _env_int(
8, "POLYWEATHER_SCAN_TERMINAL_BUILD_TIMEOUT_SEC",
int(os.getenv("POLYWEATHER_SCAN_TERMINAL_BUILD_TIMEOUT_SEC", "120")), 20,
min_value=8,
max_value=24,
) )
SCAN_TERMINAL_MAX_WORKERS = _env_int( SCAN_TERMINAL_MAX_WORKERS = _env_int(
"POLYWEATHER_SCAN_TERMINAL_MAX_WORKERS", "POLYWEATHER_SCAN_TERMINAL_MAX_WORKERS",