Skip to content

Commit 9683be9

Browse files
committed
refactor(webapp): simplify manual memoization
1 parent 3da30d8 commit 9683be9

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

apps/webapp/app/components/billing/BillingAlertsSection.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ export function BillingAlertsSection({
140140
);
141141
const maxAlerts = isPercentageMode ? MAX_PERCENTAGE_ALERTS : MAX_ABSOLUTE_ALERTS;
142142

143+
/* oxlint-disable react/react-compiler -- Stable derived thresholds prevent the synchronization effect from resetting local edits. */
143144
const savedThresholds = useMemo(
144145
() => storedAlertsToThresholds(alerts, billingLimitMode, effectiveLimitCents, planLimitCents),
145146
[alerts, billingLimitMode, effectiveLimitCents, planLimitCents]
146147
);
148+
/* oxlint-enable react/react-compiler */
147149
const savedEmails = useMemo(() => alerts.emails, [alerts.emails]);
148-
const hasLegacySpikes = useMemo(
149-
() => hasLegacySpikeAlertLevels(alerts, billingLimitMode, effectiveLimitCents, planLimitCents),
150-
[alerts, billingLimitMode, effectiveLimitCents, planLimitCents]
150+
const hasLegacySpikes = hasLegacySpikeAlertLevels(
151+
alerts,
152+
billingLimitMode,
153+
effectiveLimitCents,
154+
planLimitCents
151155
);
152156

153157
const nextThresholdIdRef = useRef(savedThresholds.length);

apps/webapp/app/components/dashboard-agent/DashboardAgentPanel.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ export function DashboardAgentPanel({
416416
}, []);
417417

418418
const dismissWatchCard = () => dispatchWatchCard({ type: "dismissed" });
419+
const activeChatId = active?.chatId;
419420

420421
const submitWatch = useCallback(async () => {
421422
const draft = watchCard.draft;
@@ -429,7 +430,7 @@ export function DashboardAgentPanel({
429430
body.set("draft", JSON.stringify(draft));
430431
body.set("clientRequestId", clientRequestId);
431432
// A watch is chat-bound: with no chat open the server creates one.
432-
if (active?.chatId) body.set("chatId", active.chatId);
433+
if (activeChatId) body.set("chatId", activeChatId);
433434

434435
const res = await fetch(actionPath, { method: "POST", body });
435436
const data = (await res.json()) as {
@@ -446,7 +447,7 @@ export function DashboardAgentPanel({
446447
}
447448

448449
const messages = data.messages;
449-
if (active?.chatId === data.chatId) {
450+
if (activeChatId === data.chatId) {
450451
setAppendedMessages((current) => ({
451452
chatId: data.chatId!,
452453
messages,
@@ -474,7 +475,7 @@ export function DashboardAgentPanel({
474475
}, [
475476
watchCard.draft,
476477
watchCard.requestId,
477-
active?.chatId,
478+
activeChatId,
478479
actionPath,
479480
organization.id,
480481
claimChatSlot,

apps/webapp/app/hooks/useDashboardEditor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export function useDashboardEditor({
257257
// Sync queue processor - ensures only one sync runs at a time
258258
// -------------------------------------------------------------------------
259259

260+
/* oxlint-disable react/react-compiler -- The recursive callback drains a serialized sync queue. */
260261
const processNextSync = useCallback(async () => {
261262
// If already syncing or queue is empty, do nothing
262263
if (isSyncingRef.current || syncQueueRef.current.length === 0) {
@@ -309,6 +310,7 @@ export function useDashboardEditor({
309310
processNextSync();
310311
}
311312
}, [widgetActionUrl, layoutActionUrl, onSyncError]);
313+
/* oxlint-enable react/react-compiler */
312314

313315
// -------------------------------------------------------------------------
314316
// Queue helpers

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues/route.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,10 +1430,7 @@ function QueueEnvMetricChart({
14301430
[tile.id, tile.label, lineColor]
14311431
);
14321432

1433-
const { tickFormatter, tooltipLabelFormatter } = useMemo(
1434-
() => buildActivityTimeAxis(data),
1435-
[data]
1436-
);
1433+
const { tickFormatter, tooltipLabelFormatter } = buildActivityTimeAxis(data);
14371434
const hasData = data.length > 0 && data.some((p) => Number(p[tile.id] ?? 0) > 0);
14381435

14391436
// Peak readout lives in the card title (ChartCard has no dedicated value slot). A zero/empty

0 commit comments

Comments
 (0)