Skip to content

Commit df47c30

Browse files
fix: fix script timings spam in the workspace UI (#17590)
Fix #17188 We forgot to filter the scripts by `run_on_start`, since we only calculate timings in the start phase, which was causing the miss match between the expected script timings count, and the loop in the refetch logic. While I think this fix is enough for now, I think the server should be responsible to telling the client when to stop fetching. It could be a simple attribute such as `done: false | true` or a websocket endpoint as suggested by @dannykopping [here](#17188 (comment)).
1 parent 14105ff commit df47c30

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@ export const WorkspaceReadyPage: FC<WorkspaceReadyPageProps> = ({
166166
// Sometimes, the timings can be fetched before the agent script timings are
167167
// done or saved in the database so we need to conditionally refetch the
168168
// timings. To refetch the timings, I found the best way was to compare the
169-
// expected amount of script timings with the current amount of script
170-
// timings returned in the response.
169+
// expected amount of script timings that run on start, with the current
170+
// amount of script timings returned in the response.
171171
refetchInterval: (data) => {
172172
const expectedScriptTimingsCount = workspace.latest_build.resources
173173
.flatMap((r) => r.agents)
174-
.flatMap((a) => a?.scripts ?? []).length;
174+
.flatMap((a) => a?.scripts ?? [])
175+
.filter((script) => script.run_on_start).length;
175176
const currentScriptTimingsCount = data?.agent_script_timings?.length ?? 0;
177+
176178
return expectedScriptTimingsCount === currentScriptTimingsCount
177179
? false
178180
: 1_000;

0 commit comments

Comments
 (0)