fix(dashboard): say the logs are loading while an empty result stands in

The previous result stays on screen while a new range or filter loads.
When that result was empty, the query reports success, so the view said
no lines matched the range it had not read yet.

Assisted-by: LLM
Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-10 00:54:51 +07:00
1 parent 7eff63b028
commit 48f459e103
2 files changed
+18 -1

No files matched your search

@@ -93,6 +93,23 @@ describe("LogsView with the production query defaults", () => {
expect(screen.getByText("ready to accept connections")).toBeInTheDocument()
})
it("says it is loading, not that nothing matched, while a longer range replaces an empty one", async () => {
const { client } = clientWith((endpoint, params) => {
if (!endpoint.endsWith("query")) return defaultHandler(endpoint, params)
return Date.parse(params.get("start") ?? "") < Date.now() - 2 * 3600_000
? new Promise(() => {})
: new Response("")
})
renderWithProductionDefaults(client, "tenant-range-a")
const frame = () => screen.getByRole("region", { name: "Log lines" })
expect(await within(frame()).findByText("No log lines for this range and filter.")).toBeInTheDocument()
await userEvent.click(screen.getByRole("button", { name: "24h" }))
await waitFor(() => expect(within(frame()).getByRole("status")).toHaveAttribute("aria-busy", "true"))
expect(within(frame()).queryByText("No log lines for this range and filter.")).toBeNull()
})
})
describe("LogsView", () => {
@@ -168,7 +168,7 @@ function ScopedLogsView({ root }: { root: string }) {
// Previous results stay as placeholder data while a new query loads, so only a new key resets the scroll pin.
key={followRun ?? `history\n${query}\n${range}`}
entries={entries}
placeholder={placeholderFor({ follow, stopped: tail.state === "stopped", loading: history.isLoading, failed: Boolean(error), longestRange: range === LONGEST_RANGE, retry: () => void history.refetch() })}
placeholder={placeholderFor({ follow, stopped: tail.state === "stopped", loading: history.isLoading || (history.isPlaceholderData && history.isFetching), failed: Boolean(error), longestRange: range === LONGEST_RANGE, retry: () => void history.refetch() })}
/>
</div>
)