-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(webapp): live-update the runs list on task pages #4377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
samejr
wants to merge
4
commits into
main
Choose a base branch
from
samejr/runs-page-live-reload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+179
−26
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dc74266
feat(webapp): live-update the runs list on task pages
samejr f32b0a2
chore(webapp): format task pages with oxfmt
samejr 4861ad5
fix(webapp): keep the task-page new-runs count consistent with the list
samejr ca95a03
refactor(webapp): extract shared TaskRunsList for both task pages
samejr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: improvement | ||
| --- | ||
|
|
||
| The runs list on a task's page now updates live — run statuses change and newly triggered runs appear without a manual refresh, matching the main Runs page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import { useLocation, useNavigation, useRevalidator } from "@remix-run/react"; | ||
| import { type MutableRefObject, useEffect } from "react"; | ||
| import { Button } from "~/components/primitives/Buttons"; | ||
| import { PulsingDot } from "~/components/primitives/PulsingDot"; | ||
| import { useEnvironment } from "~/hooks/useEnvironment"; | ||
| import { useOrganization } from "~/hooks/useOrganizations"; | ||
| import { useProject } from "~/hooks/useProject"; | ||
| import { useSearchParams } from "~/hooks/useSearchParam"; | ||
| import type { NextRunList } from "~/presenters/v3/NextRunListPresenter.server"; | ||
| import { useRunsLiveReload } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs._index/useRunsLiveReload"; | ||
| import { TaskRunsTable } from "./TaskRunsTable"; | ||
|
|
||
| /** | ||
| * Compact "N new runs" button, shown in a task page's header to the left of the | ||
| * time filter when the live-reload hook has detected newer runs. | ||
| */ | ||
| export function NewRunsButton({ count, onClick }: { count: number; onClick: () => void }) { | ||
| return ( | ||
| <span className="flex duration-150 animate-in fade-in-0"> | ||
| <Button | ||
| variant="secondary/small" | ||
| className="text-text-bright" | ||
| onClick={onClick} | ||
| LeadingIcon={<PulsingDot className="h-2 w-2" />} | ||
| tooltip="Refresh to see new runs" | ||
| aria-label="New runs created. Refresh to see new runs." | ||
| > | ||
| {count >= 100 ? "99+ new runs" : `${count} new ${count === 1 ? "run" : "runs"}`} | ||
| </Button> | ||
| </span> | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Runs table with live updating, shared by the standard and scheduled task | ||
| * landing pages. Mirrors the Runs list page: active rows are patched in place | ||
| * (status/timing/cost). The "N new runs" count is surfaced to the top-bar | ||
| * button via `onNewRunsCountChange` (count drives visibility) and | ||
| * `showNewRunsRef` (the latest click action), since the button lives outside | ||
| * this deferred boundary. The task lives in the route path rather than a | ||
| * `tasks` filter, so we pass `taskSlug` to scope new-run detection to this task. | ||
| */ | ||
| export function TaskRunsList({ | ||
| list, | ||
| taskSlug, | ||
| onNewRunsCountChange, | ||
| showNewRunsRef, | ||
| }: { | ||
| list: NextRunList; | ||
| taskSlug: string; | ||
| onNewRunsCountChange: (count: number) => void; | ||
| showNewRunsRef: MutableRefObject<() => void>; | ||
| }) { | ||
| const organization = useOrganization(); | ||
| const project = useProject(); | ||
| const environment = useEnvironment(); | ||
| const navigation = useNavigation(); | ||
| const location = useLocation(); | ||
| const { has, replace } = useSearchParams(); | ||
| const revalidator = useRevalidator(); | ||
|
|
||
| // Loading a new version of this same page (time filter / pagination change). | ||
| const isLoading = | ||
| navigation.state === "loading" && | ||
| navigation.location !== undefined && | ||
| navigation.location.pathname === location.pathname && | ||
| navigation.location.search !== location.search; | ||
|
|
||
| const { visibleRuns, newRunsCount, dismissNewRuns, childrenStatusesBasePath } = useRunsLiveReload( | ||
| { | ||
| runs: list.runs, | ||
| hasAnyRuns: list.hasAnyRuns, | ||
| isLoading, | ||
| organizationSlug: organization.slug, | ||
| projectSlug: project.slug, | ||
| environmentSlug: environment.slug, | ||
| taskSlug, | ||
| } | ||
| ); | ||
|
|
||
| const onClickShowNewRuns = () => { | ||
| const isPaginated = has("cursor") || has("direction"); | ||
| dismissNewRuns(); | ||
| if (isPaginated) { | ||
| replace({ cursor: undefined, direction: undefined }); | ||
| return; | ||
| } | ||
| revalidator.revalidate(); | ||
| }; | ||
|
|
||
| // Surface the banner to the top-bar button rendered by the page: keep the | ||
| // ref's action current, mirror the count up, and clear it when this boundary | ||
| // unmounts (e.g. the table re-suspends on a filter change). | ||
| useEffect(() => { | ||
| showNewRunsRef.current = onClickShowNewRuns; | ||
| }, [onClickShowNewRuns, showNewRunsRef]); | ||
| useEffect(() => { | ||
| onNewRunsCountChange(newRunsCount); | ||
| }, [newRunsCount, onNewRunsCountChange]); | ||
| useEffect(() => () => onNewRunsCountChange(0), [onNewRunsCountChange]); | ||
|
|
||
| return ( | ||
| <div className="h-full overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-surface-control"> | ||
| <TaskRunsTable | ||
| total={visibleRuns.length} | ||
| hasFilters={list.hasFilters} | ||
| filters={list.filters} | ||
| runs={visibleRuns} | ||
| childrenStatusesBasePath={childrenStatusesBasePath} | ||
| isLoading={isLoading} | ||
| variant="dimmed" | ||
| showTopBorder={false} | ||
| stickyHeader | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.