Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(frontend): add fast-follow refresh mode for rollout actions (#19631)

boojack07f9545a64cc
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
index bc8e093656..bb33e73b2c 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
@@ -51,6 +51,7 @@
<script lang="ts" setup>
import { computed, watchEffect } from "vue";
import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
+import { emitPlanStatusChanged } from "@/components/Plan/logic";
import TaskStatus from "@/components/RolloutV1/components/Task/TaskStatus.vue";
import TaskStatusActions from "@/components/RolloutV1/components/Task/TaskStatusActions.vue";
import { useDatabaseV1Store } from "@/store";
@@ -88,7 +89,7 @@ const getStageForTask = (task: Task): Stage | undefined => {
// Handle action confirmed - trigger data refresh
const handleActionConfirmed = () => {
- events.emit("status-changed", { eager: true });
+ emitPlanStatusChanged(events, { refreshMode: "fast-follow" });
};
// Fetch task target databases
diff --git a/frontend/src/components/Plan/components/RefreshIndicator.vue b/frontend/src/components/Plan/components/RefreshIndicator.vue
index be9435f675..6087646725 100644
--- a/frontend/src/components/Plan/components/RefreshIndicator.vue
+++ b/frontend/src/components/Plan/components/RefreshIndicator.vue
@@ -1,10 +1,15 @@
<template>
<div class="hidden sm:flex items-center gap-2">
- <span v-if="lastRefreshDisplay" class="text-xs text-gray-400">
- {{
- $t("plan.refresh-indicator.last-refresh", { time: lastRefreshDisplay })
- }}
- </span>
+ <NTooltip v-if="lastRefreshDisplay && lastRefreshAbsolute">
+ <template #trigger>
+ <span class="text-xs text-gray-400">
+ {{
+ $t("plan.refresh-indicator.last-refresh", { time: lastRefreshDisplay })
+ }}
+ </span>
+ </template>
+ <span>{{ lastRefreshAbsolute }}</span>
+ </NTooltip>
<NButton
size="tiny"
quaternary
@@ -22,14 +27,13 @@
<script setup lang="ts">
import { RefreshCcwIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
+import { NButton, NTooltip } from "naive-ui";
import { computed, onUnmounted, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import { formatAbsoluteDateTime } from "@/utils";
+import { formatAbsoluteDateTime, formatRelativeTime } from "@/utils";
import { useResourcePoller } from "../logic/poller";
-const { t } = useI18n();
const currentTime = ref(Date.now());
+const REFRESH_INDICATOR_NOW_THRESHOLD_MS = 3_000;
const resourcePoller = useResourcePoller();
@@ -50,6 +54,10 @@ onUnmounted(() => {
});
const lastRefreshTime = computed(() => resourcePoller.lastRefreshTime.value);
+const lastRefreshAbsolute = computed(() => {
+ if (!lastRefreshTime.value) return null;
+ return formatAbsoluteDateTime(lastRefreshTime.value);
+});
const lastRefreshDisplay = computed(() => {
if (!lastRefreshTime.value) return null;
@@ -57,14 +65,11 @@ const lastRefreshDisplay = computed(() => {
// Force reactivity by using currentTime (triggers every second)
void currentTime.value;
- const now = Date.now();
- const diff = now - lastRefreshTime.value;
-
- if (diff < 10000) {
- return t("common.just-now");
- } else if (diff < 60000) {
- const seconds = Math.floor(diff / 1000);
- return t("common.n-seconds-ago", { count: seconds });
+ const diff = Date.now() - lastRefreshTime.value;
+ if (diff < 3_600_000) {
+ return formatRelativeTime(lastRefreshTime.value, {
+ nowThresholdMs: REFRESH_INDICATOR_NOW_THRESHOLD_MS,
+ });
}
return formatAbsoluteDateTime(lastRefreshTime.value);
});
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index 68b3d82b9d..907a5e66bc 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -13,8 +13,13 @@ import type {
IssueStatusAction,
} from "../components/HeaderSection/Actions/registry";
+export type RefreshMode = "normal" | "fast-follow";
+
export type PlanEvents = Emittery<{
- "status-changed": { eager: boolean };
+ "status-changed": {
+ eager: boolean;
+ refreshMode?: RefreshMode;
+ };
"perform-issue-review-action": {
action: IssueReviewAction;
};
@@ -57,6 +62,17 @@ export const usePlanContext = () => {
return context;
};
+export const emitPlanStatusChanged = (
+ events: PlanEvents,
+ options: {
+ eager?: boolean;
+ refreshMode?: RefreshMode;
+ } = {}
+) => {
+ const { eager = true, refreshMode = "normal" } = options;
+ events.emit("status-changed", { eager, refreshMode });
+};
+
export const tryUsePlanContext = () => {
return inject(KEY);
};
diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.ts
index 0e7d763c21..ac4b5a0cca 100644
--- a/frontend/src/components/Plan/logic/poller/poller.ts
+++ b/frontend/src/components/Plan/logic/poller/poller.ts
@@ -25,7 +25,12 @@ import { useCurrentProjectV1 } from "@/store";
import { isValidRolloutName } from "@/types";
import { IssueSchema } from "@/types/proto-es/v1/issue_service_pb";
import { RolloutSchema } from "@/types/proto-es/v1/rollout_service_pb";
-import { getRolloutFromPlan, isValidIssueName, isValidPlanName } from "@/utils";
+import {
+ getRolloutFromPlan,
+ isValidIssueName,
+ isValidPlanName,
+ sleep,
+} from "@/utils";
import { usePlanContext } from "../context";
import {
refreshIssue,
@@ -38,8 +43,9 @@ import {
type ResourceType = "plan" | "planCheckRuns" | "issue" | "rollout" | "taskRuns";
-// Progressive polling configuration.
-const POLLER_INTERVAL = { min: 2000, max: 30000, growth: 2, jitter: 3000 };
+// CI/CD-style polling: quick follow-up after user actions, then progressive backoff.
+const POLLER_INTERVAL = { min: 1000, max: 30000, growth: 2, jitter: 250 };
+const FAST_FOLLOW_REFRESH_DELAYS = [500, 1500, 3000];
const KEY = Symbol(
`bb.plan.poller.${uuidv4()}`
@@ -76,6 +82,7 @@ export const provideResourcePoller = () => {
isPollerRunning: false,
isInitializing: false, // Track if initialization is in progress
});
+ let actionRefreshSequenceId = 0;
// Define refresh strategies for each resource
const resourceStrategies: Record<ResourceType, ResourceRefreshStrategy> = {
@@ -273,6 +280,23 @@ export const provideResourcePoller = () => {
}
};
+ const scheduleFastFollowRefreshes = (resources: ResourceType[]) => {
+ const sequenceId = ++actionRefreshSequenceId;
+
+ void (async () => {
+ for (const retryDelay of FAST_FOLLOW_REFRESH_DELAYS) {
+ await sleep(retryDelay);
+ if (sequenceId !== actionRefreshSequenceId) {
+ return;
+ }
+ await refreshResources(resources, {
+ force: true,
+ isManual: false,
+ });
+ }
+ })();
+ };
+
// Create the poller
const resourcePoller = useProgressivePoll(refreshResources, {
interval: POLLER_INTERVAL,
@@ -363,10 +387,21 @@ export const provideResourcePoller = () => {
);
// Event listeners
- events.on("status-changed", async ({ eager }) => {
+ events.on("status-changed", async ({ eager, refreshMode = "normal" }) => {
try {
+ const shouldFastFollow = refreshMode === "fast-follow";
if (eager) {
- await refreshResources(resourcesToPolled.value, { isManual: false });
+ const resources = resourcesToPolled.value;
+ await refreshResources(resources, {
+ force: shouldFastFollow,
+ isManual: false,
+ });
+ if (shouldFastFollow) {
+ scheduleFastFollowRefreshes(resources);
+ }
+ } else if (shouldFastFollow) {
+ resourcePoller.restart();
+ scheduleFastFollowRefreshes(resourcesToPolled.value);
}
} catch (error) {
console.error("Error refreshing resources on status-changed:", error);
diff --git a/frontend/src/components/RolloutV1/components/Rollout/RolloutView.vue b/frontend/src/components/RolloutV1/components/Rollout/RolloutView.vue
index 40137a61e1..c464793abc 100644
--- a/frontend/src/components/RolloutV1/components/Rollout/RolloutView.vue
+++ b/frontend/src/components/RolloutV1/components/Rollout/RolloutView.vue
@@ -57,7 +57,10 @@ import { NButton } from "naive-ui";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
-import { usePlanContextWithRollout } from "@/components/Plan/logic";
+import {
+ emitPlanStatusChanged,
+ usePlanContextWithRollout,
+} from "@/components/Plan/logic";
import { rolloutServiceClientConnect } from "@/connect";
import { PROJECT_V1_ROUTE_PLAN_ROLLOUT_STAGE } from "@/router/dashboard/projectV1";
import { useCurrentProjectV1 } from "@/store";
@@ -171,7 +174,7 @@ const handleCreateStage = async (stage: Stage) => {
};
const handleStageActionConfirmed = () => {
- events.emit("status-changed", { eager: true });
+ emitPlanStatusChanged(events, { refreshMode: "fast-follow" });
showStageActionPanel.value = false;
stageActionTarget.value = null;
};
diff --git a/frontend/src/components/RolloutV1/components/Stage/StageTimeline.vue b/frontend/src/components/RolloutV1/components/Stage/StageTimeline.vue
index 0e3e2f0b3a..f41ca4c717 100644
--- a/frontend/src/components/RolloutV1/components/Stage/StageTimeline.vue
+++ b/frontend/src/components/RolloutV1/components/Stage/StageTimeline.vue
@@ -91,27 +91,30 @@
:timestamp="taskRun.updateTime"
custom-class="!text-xs !text-gray-400"
/>
- <span v-if="getTaskRunCreatorDisplay(taskRun)">·</span>
- <router-link
- v-if="getTaskRunCreatorDisplay(taskRun)"
- :to="{
- name: WORKSPACE_ROUTE_USER_PROFILE,
- params: {
- principalEmail: getTaskRunCreatorDisplay(taskRun)?.email || '',
- },
- }"
- class="hover:underline"
- @click.stop
- >
- {{ getTaskRunCreatorDisplay(taskRun)?.title }}
- </router-link>
- <NTooltip v-if="getTaskRunDuration(taskRun)">
+ <template v-if="getTaskRunCreatorDisplay(taskRun)">
<span>·</span>
- <template #trigger>
- <span>{{ getTaskRunDuration(taskRun) }}</span>
- </template>
- {{ $t("common.duration") }}
- </NTooltip>
+ <router-link
+ :to="{
+ name: WORKSPACE_ROUTE_USER_PROFILE,
+ params: {
+ principalEmail: getTaskRunCreatorDisplay(taskRun)?.email || '',
+ },
+ }"
+ class="hover:underline"
+ @click.stop
+ >
+ {{ getTaskRunCreatorDisplay(taskRun)?.title }}
+ </router-link>
+ </template>
+ <template v-if="getTaskRunDuration(taskRun)">
+ <span>·</span>
+ <NTooltip>
+ <template #trigger>
+ <span>{{ getTaskRunDuration(taskRun) }}</span>
+ </template>
+ {{ $t("common.duration") }}
+ </NTooltip>
+ </template>
</div>
</div>
</NTimelineItem>
diff --git a/frontend/src/components/RolloutV1/components/Task/TaskItem.vue b/frontend/src/components/RolloutV1/components/Task/TaskItem.vue
index d83d13f0e9..fa61ed2404 100644
--- a/frontend/src/components/RolloutV1/components/Task/TaskItem.vue
+++ b/frontend/src/components/RolloutV1/components/Task/TaskItem.vue
@@ -235,6 +235,7 @@ import HighlightCodeBlock from "@/components/HighlightCodeBlock.vue";
import Timestamp from "@/components/misc/Timestamp.vue";
import { usePlanContextWithRollout } from "@/components/Plan";
import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
+import { emitPlanStatusChanged } from "@/components/Plan/logic";
import { PROJECT_V1_ROUTE_PLAN_ROLLOUT_TASK } from "@/router/dashboard/projectV1";
import type { Stage, Task } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
@@ -302,7 +303,7 @@ const {
// Handle action confirmed - trigger data refresh
const handleActionConfirm = () => {
- events.emit("status-changed", { eager: true });
+ emitPlanStatusChanged(events, { refreshMode: "fast-follow" });
};
const taskDetailRoute = computed(() => {
diff --git a/frontend/src/components/RolloutV1/components/Task/TaskList.vue b/frontend/src/components/RolloutV1/components/Task/TaskList.vue
index e1575815fc..8bf0a615b5 100644
--- a/frontend/src/components/RolloutV1/components/Task/TaskList.vue
+++ b/frontend/src/components/RolloutV1/components/Task/TaskList.vue
@@ -48,7 +48,10 @@
<script lang="ts" setup>
import { computed, ref, watch } from "vue";
-import { usePlanContextWithRollout } from "@/components/Plan/logic";
+import {
+ emitPlanStatusChanged,
+ usePlanContextWithRollout,
+} from "@/components/Plan/logic";
import type { Rollout, Stage } from "@/types/proto-es/v1/rollout_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import { DEFAULT_PAGE_SIZE } from "../../constants";
@@ -113,8 +116,7 @@ const {
const handleActionComplete = () => {
clearSelection();
- // Trigger immediate refresh of rollout data after task actions
- events.emit("status-changed", { eager: true });
+ emitPlanStatusChanged(events, { refreshMode: "fast-follow" });
};
// Reset pagination when filters change, but preserve state on refresh
diff --git a/frontend/src/components/RolloutV1/components/Task/TaskStatusActions.vue b/frontend/src/components/RolloutV1/components/Task/TaskStatusActions.vue
index 6290fa702d..ac5ddeab74 100644
--- a/frontend/src/components/RolloutV1/components/Task/TaskStatusActions.vue
+++ b/frontend/src/components/RolloutV1/components/Task/TaskStatusActions.vue
@@ -27,6 +27,7 @@
:action="currentAction"
:target="actionTarget"
@close="handleActionPanelClose"
+ @confirm="handleActionConfirmed"
/>
</template>
</div>
@@ -114,6 +115,10 @@ const handleDropdownSelect = (key: string) => {
const handleActionPanelClose = () => {
closeActionPanel();
+};
+
+const handleActionConfirmed = () => {
+ closeActionPanel();
emit("action-confirmed");
};
</script>
diff --git a/frontend/src/components/RolloutV1/components/Task/TaskView.vue b/frontend/src/components/RolloutV1/components/Task/TaskView.vue
index d2a25544c4..dadc3598c4 100644
--- a/frontend/src/components/RolloutV1/components/Task/TaskView.vue
+++ b/frontend/src/components/RolloutV1/components/Task/TaskView.vue
@@ -137,6 +137,7 @@ import { RouterLink } from "vue-router";
import { MonacoEditor } from "@/components/MonacoEditor";
import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
import {
+ emitPlanStatusChanged,
getSpecTitle,
usePlanContextWithRollout,
} from "@/components/Plan/logic";
@@ -269,6 +270,6 @@ watchEffect(async () => {
// Handle task action completion to refresh data
const handleTaskActionConfirmed = async () => {
- events.emit("status-changed", { eager: true });
+ emitPlanStatusChanged(events, { refreshMode: "fast-follow" });
};
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 67115bdc5b..30126f7c29 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -134,8 +134,6 @@
"delete": "Delete",
"history": "History",
"loading": "Loading",
- "just-now": "just now",
- "n-seconds-ago": "{count} seconds ago",
"copy": "Copy",
"copied": "Copied",
"manage": "Manage",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index c374256e4b..e8ba9ed155 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -134,8 +134,6 @@
"delete": "Eliminar",
"history": "Historial",
"loading": "Cargando",
- "just-now": "En este momento",
- "n-seconds-ago": "Hace {count} segundos",
"copy": "Copiar",
"copied": "Copiado",
"manage": "Administrar",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index ebabd57b7a..7e87ebfc1a 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -134,8 +134,6 @@
"delete": "消去",
"history": "履歴",
"loading": "読み込み中",
- "just-now": "ちょうど今",
- "n-seconds-ago": "{count} 秒前",
"copy": "コピー",
"copied": "コピーされました",
"manage": "管理",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 2dacf09653..1584adcdf7 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -134,8 +134,6 @@
"delete": "Xóa",
"history": "Lịch sử",
"loading": "Đang tải",
- "just-now": "ngay bây giờ",
- "n-seconds-ago": "{count} giây trước",
"copy": "Sao chép",
"copied": "Đã sao chép",
"manage": "Quản lý",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 8c5077f7b2..aeabdd8894 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -134,8 +134,6 @@
"delete": "删除",
"history": "历史记录",
"loading": "加载中",
- "just-now": "现在",
- "n-seconds-ago": "{count} 秒前",
"copy": "拷贝",
"copied": "已拷贝",
"manage": "管理",
diff --git a/frontend/src/utils/datetime.test.ts b/frontend/src/utils/datetime.test.ts
index 6fad688240..95de2c6268 100644
--- a/frontend/src/utils/datetime.test.ts
+++ b/frontend/src/utils/datetime.test.ts
@@ -26,6 +26,13 @@ describe("formatRelativeTime", () => {
expect(result).toBe("now");
});
+ test("supports overriding the 'now' threshold", () => {
+ const result = formatRelativeTime(Date.now() - 5000, {
+ nowThresholdMs: 3000,
+ });
+ expect(result).toContain("seconds ago");
+ });
+
test("returns 'X seconds ago' for 10-59 seconds", () => {
const result = formatRelativeTime(Date.now() - 30_000);
expect(result).toContain("seconds ago");
@@ -53,12 +60,13 @@ describe("formatRelativeTime", () => {
});
describe("formatAbsoluteDateTime", () => {
- test("includes month, day, year, and time", () => {
+ test("includes month, day, year, time, and seconds", () => {
const ts = new Date("2026-03-02T14:30:00Z").getTime();
const result = formatAbsoluteDateTime(ts);
expect(result).toContain("Mar");
expect(result).toContain("2026");
expect(result).toContain("2");
+ expect(result).toContain("00");
});
});
diff --git a/frontend/src/utils/datetime.ts b/frontend/src/utils/datetime.ts
index ca7fd44788..4010433f1e 100644
--- a/frontend/src/utils/datetime.ts
+++ b/frontend/src/utils/datetime.ts
@@ -1,12 +1,21 @@
import { locale } from "@/plugins/i18n";
export const RELATIVE_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
+export const DEFAULT_NOW_THRESHOLD_MS = 10_000;
+
+type RelativeTimeFormatOptions = {
+ nowThresholdMs?: number;
+};
export function getActiveLocale(): string {
return locale.value;
}
-export function formatRelativeTime(timestampMs: number): string {
+export function formatRelativeTime(
+ timestampMs: number,
+ options: RelativeTimeFormatOptions = {}
+): string {
+ const { nowThresholdMs = DEFAULT_NOW_THRESHOLD_MS } = options;
const diffMs = Date.now() - timestampMs;
const absDiff = Math.abs(diffMs);
const sign = diffMs >= 0 ? -1 : 1;
@@ -15,7 +24,7 @@ export function formatRelativeTime(timestampMs: number): string {
numeric: "auto",
});
- if (absDiff < 10_000) {
+ if (absDiff < nowThresholdMs) {
return rtf.format(0, "second");
}
if (absDiff < 60_000) {
@@ -37,6 +46,7 @@ export function formatAbsoluteDateTime(timestampMs: number): string {
year: "numeric",
hour: "numeric",
minute: "2-digit",
+ second: "2-digit",
timeZoneName: "short",
}).format(new Date(timestampMs));
}