Skip to content

Commit e2734c2

Browse files
author
Dylan Huang
committed
okay done
1 parent ff6e92c commit e2734c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

vite-app/src/components/LogsSection.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const LogsSection = observer(({ rolloutId }: LogsSectionProps) => {
1515
const [error, setError] = useState<string | null>(null);
1616
const [isExpanded, setIsExpanded] = useState(false);
1717
const [selectedLevel, setSelectedLevel] = useState<string>("");
18+
const [hasLoadedOnce, setHasLoadedOnce] = useState(false);
1819

1920
const fetchLogs = async (isInitialLoad = false) => {
2021
if (!rolloutId) return;
@@ -69,6 +70,7 @@ export const LogsSection = observer(({ rolloutId }: LogsSectionProps) => {
6970
} else {
7071
// 404 with JSON content-type means "no logs found" - this is valid
7172
setLogs([]);
73+
setHasLoadedOnce(true);
7274
return;
7375
}
7476
}
@@ -86,6 +88,7 @@ export const LogsSection = observer(({ rolloutId }: LogsSectionProps) => {
8688

8789
const data: LogsResponse = await response.json();
8890
setLogs(data.logs);
91+
setHasLoadedOnce(true);
8992
} catch (err) {
9093
if (err instanceof Error && err.message.includes("Unexpected token")) {
9194
setError(
@@ -101,6 +104,7 @@ export const LogsSection = observer(({ rolloutId }: LogsSectionProps) => {
101104

102105
useEffect(() => {
103106
if (isExpanded && rolloutId) {
107+
setHasLoadedOnce(false); // Reset when filters change
104108
fetchLogs(true); // Initial load
105109
const interval = setInterval(() => fetchLogs(false), 5000); // Poll every 5 seconds without loading state
106110
return () => clearInterval(interval);
@@ -119,7 +123,7 @@ export const LogsSection = observer(({ rolloutId }: LogsSectionProps) => {
119123
onClick={() => setIsExpanded(!isExpanded)}
120124
>
121125
<h4 className="font-semibold text-xs text-gray-700">
122-
Logs ({logs.length})
126+
Logs {hasLoadedOnce ? `(${logs.length})` : ""}
123127
</h4>
124128
<svg
125129
className={`h-3 w-3 text-gray-500 transition-transform duration-200 ${

0 commit comments

Comments
 (0)