Skip to content

fix: update runtime logs#5351

Merged
perkinsjr merged 24 commits intomainfrom
update-runtime-logs
Apr 3, 2026
Merged

fix: update runtime logs#5351
perkinsjr merged 24 commits intomainfrom
update-runtime-logs

Conversation

@ogzhanolguncu
Copy link
Copy Markdown
Contributor

@ogzhanolguncu ogzhanolguncu commented Mar 17, 2026

What does this PR do?

This PR adds instanceId, region filtering and instanceId and region fields to runtime logs.

Screenshot 2026-03-17 at 11 37 30 Screenshot 2026-03-17 at 11 37 08

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Apr 3, 2026 0:31am

Request Review

@ogzhanolguncu ogzhanolguncu changed the title Update runtime logs fix: update runtime logs Mar 17, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR extends runtime logs with region and instance filtering capabilities. Changes include refactoring container log display from three separate columns to one composite column, adding region and instance_id fields throughout data schemas and queries, introducing UI filters for region and instance selection, and implementing Kubernetes pod name-to-instance ID resolution on the backend.

Changes

Cohort / File(s) Summary
Container Logs Display Refactoring
columns.tsx, deployment-container-logs-table.tsx, skeletons.tsx
Consolidates three separate skeleton components (TimeColumn, SeverityColumn, MessageColumn) into a single ContainerLogRowSkeleton. Refactors log columns from three individual columns (time, severity, message) to one composite "log" column rendering timestamp, severity icon, region flag, instance ID, and truncated message together. Extends ContainerLogRow type with instance_id and region fields.
Runtime Logs Schema & Type Definitions
lib/schemas/runtime-logs.schema.ts, lib/schemas/runtime-logs.filter.schema.ts
Adds region and instanceId to runtime logs request schema with nullable filter blocks. Introduces dashboardRuntimeLog schema with new instance_id and region fields. Extends RuntimeLogsFilterFieldConfig and RuntimeLogsFilterFieldEnum to include region and instanceId as filterable fields supporting "is" operator.
Runtime Logs Query Processing
lib/trpc/routers/deploy/runtime-logs/query.ts, lib/trpc/routers/deploy/runtime-logs/utils.ts
Implements K8s pod name-to-instance ID resolution via new utility functions (toInstanceKey, uniqueK8sRegionEntries, resolveK8sNamesToInstanceIds). Pre-resolves instanceId filters to K8s pod names before querying ClickHouse. Transforms ClickHouse logs to inject resolved instance_id and region fields into response.
ClickHouse Integration
web/internal/clickhouse/src/runtime-logs.ts, lib/trpc/routers/deploy/deployment/runtime-logs.ts
Extends ClickHouse request schema to accept region array and k8sPodNames array. Adds k8s_pod_name field to runtime log output schema. Updates query construction with conditional filters for region and k8s_pod_name. Includes k8s_pod_name in SELECT output alongside region and attributes.
Filter UI Components
logs/components/controls/components/runtime-logs-filters/index.tsx, runtime-logs-region-filter.tsx, runtime-logs-instance-filter.tsx, runtime-logs-deployment-filter.tsx
Adds two new filter components (RuntimeLogsRegionFilter, RuntimeLogsInstanceFilter) that fetch data via TRPC and render multi-select checkboxes with region flags and labels. Updates filter items array to include Region and Instance entries. Refactors deployment filter layout to be more compact, showing full slug without uppercase styling.
Runtime Logs Table & Details Display
logs/components/table/runtime-logs-table.tsx, logs/components/table/runtime-log-details/index.tsx
Adds Instance ID column to runtime logs table with monospaced, truncated text rendering. Updates log identity key to include instance_id. Removes uppercase styling from region display. Reorders deployment info section to show Instance ID before Deployment ID in details view.
Filter State Management & Query Building
logs/hooks/use-runtime-logs-filters.ts, logs/components/table/hooks/use-runtime-logs-query.ts
Extends queryParamsPayload to include region and instanceId as filterable parameters. Adds region and instanceId parsing, validation, and URL synchronization in filter state. Updates query builder to include regionFilters and instanceIdFilters with "is" operator in TRPC input.
Backend Instance Lookup & Router Setup
lib/trpc/routers/deploy/runtime-logs/list-instances.ts, lib/trpc/routers/index.ts, details/active-deployment-card-logs/hooks/use-runtime-logs.tsx
Creates new listInstances TRPC procedure that fetches running instances for a project with region information. Registers procedure in deploy.runtimeLogs router. Adds region and instanceId input parameters to getDeploymentRuntimeLogs query.
LLM Search Enhancement
lib/trpc/routers/deploy/runtime-logs/llm-search/utils.ts, logs/components/controls/components/runtime-logs-search/index.tsx
Extends LLM search prompt documentation with examples and guidance for filtering by region, instanceId, and deploymentId. Adds example query "Show errors from us-east-1 in the last hour" to runtime logs search.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks required sections from the template. It's missing issue reference, type of change checkbox, testing instructions, and most required checklist items. Complete the description template by adding issue reference, marking type of change, providing testing instructions, and filling in required checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix: update runtime logs' is generic and vague, failing to convey the specific changes (adding instanceId and region filtering). Use a more descriptive title like 'feat: add instanceId and region filtering to runtime logs' that clearly indicates the specific changes being introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-runtime-logs

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
web/internal/clickhouse/src/runtime-logs.ts (1)

16-18: Minor inconsistency in nullability.

region is nullable (z.array(z.string()).nullable()) while k8sPodNames is not (z.array(z.string())). This works since callers pass empty arrays, but consider making them consistent for API clarity:

- k8sPodNames: z.array(z.string()),
+ k8sPodNames: z.array(z.string()).nullable(),

Then update the query condition to handle null:

WHEN {k8sPodNames: Nullable(Array(String))} IS NOT NULL AND length({k8sPodNames: ...}) > 0 THEN ...
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/internal/clickhouse/src/runtime-logs.ts` around lines 16 - 18, The schema
has inconsistent nullability: region is defined as
z.array(z.string()).nullable() while k8sPodNames is z.array(z.string())—make
them consistent by making k8sPodNames nullable as well
(z.array(z.string()).nullable()) and update any query logic that checks
k8sPodNames to first test for IS NOT NULL before checking length (e.g., change
the WHEN clause to check Nullable(Array(String)) IS NOT NULL AND length(...) >
0) so null and empty-array cases are handled uniformly; update references to
k8sPodNames and the query condition in runtime-logs.ts accordingly.
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/details/active-deployment-card-logs/hooks/use-runtime-logs.tsx (1)

43-43: Type assertion violates coding guidelines.

The as React.MutableRefObject<HTMLDivElement> cast bypasses type safety. Consider using a generic type parameter or handling the null case explicitly.

♻️ Proposed fix
-  const scrollRef = useRef<HTMLDivElement>(null) as React.MutableRefObject<HTMLDivElement>;
+  const scrollRef = useRef<HTMLDivElement | null>(null);

Then update usages to handle the nullable ref, or use a callback ref pattern if non-null is required.

As per coding guidelines: "Never compromise type safety: No any, no ! (non-null assertion), no as Type"

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/(overview)/details/active-deployment-card-logs/hooks/use-runtime-logs.tsx
at line 43, The current declaration `scrollRef` uses a type assertion that
breaks type safety; replace it with a properly typed nullable ref (e.g.,
useRef<HTMLDivElement | null>(null)) or switch to a callback ref, and then
update all usages of `scrollRef` in use-runtime-logs (e.g., where
`scrollRef.current` is accessed) to guard against null (or accept the callback
ref signature) so you no longer need the `as
React.MutableRefObject<HTMLDivElement>` cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/container-logs-table/deployment-container-logs-table.tsx:
- Around line 19-28: The skeleton is being rendered once per column because
renderSkeletonRow maps columns and returns <ContainerLogRowSkeleton /> for every
cell; update renderSkeletonRow (used by the VirtualTable) so it only renders the
full ContainerLogRowSkeleton in the first column (check for column index or
column.key) and return an empty <td> (or a simple placeholder cell) for all
other columns, ensuring className and style (height) are still applied to
preserve layout; target the renderSkeletonRow function and the
ContainerLogRowSkeleton usage to implement this single-cell skeleton rendering.

In `@web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts`:
- Around line 46-60: When instance filters are provided but no matching DB rows
are found, k8sPodNames becomes an empty array which makes the ClickHouse CASE
treat the filter as TRUE and return all logs; fix by short-circuiting: after
fetching instances in the block that populates instanceIds, k8sPodNames and
knownK8sToInstanceId, check if instanceIds.length > 0 and instances.length === 0
and immediately return an empty result (same shape as the resolver’s normal
return) or otherwise mark the query to yield no rows; update the resolver around
the code that sets k8sPodNames / knownK8sToInstanceId so the ClickHouse query
never runs with an empty k8sPodNames.

---

Nitpick comments:
In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/(overview)/details/active-deployment-card-logs/hooks/use-runtime-logs.tsx:
- Line 43: The current declaration `scrollRef` uses a type assertion that breaks
type safety; replace it with a properly typed nullable ref (e.g.,
useRef<HTMLDivElement | null>(null)) or switch to a callback ref, and then
update all usages of `scrollRef` in use-runtime-logs (e.g., where
`scrollRef.current` is accessed) to guard against null (or accept the callback
ref signature) so you no longer need the `as
React.MutableRefObject<HTMLDivElement>` cast.

In `@web/internal/clickhouse/src/runtime-logs.ts`:
- Around line 16-18: The schema has inconsistent nullability: region is defined
as z.array(z.string()).nullable() while k8sPodNames is z.array(z.string())—make
them consistent by making k8sPodNames nullable as well
(z.array(z.string()).nullable()) and update any query logic that checks
k8sPodNames to first test for IS NOT NULL before checking length (e.g., change
the WHEN clause to check Nullable(Array(String)) IS NOT NULL AND length(...) >
0) so null and empty-array cases are handled uniformly; update references to
k8sPodNames and the query condition in runtime-logs.ts accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2ec5cc50-f546-489e-9346-daeb2b5216f6

📥 Commits

Reviewing files that changed from the base of the PR and between fc8d44f and b4509ba.

📒 Files selected for processing (22)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/container-logs-table/columns.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/container-logs-table/deployment-container-logs-table.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/container-logs-table/skeletons.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/details/active-deployment-card-logs/hooks/use-runtime-logs.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/runtime-logs-deployment-filter.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/runtime-logs-instance-filter.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/runtime-logs-region-filter.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-search/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/table/hooks/use-runtime-logs-query.ts
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/table/runtime-log-details/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/table/runtime-logs-table.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/hooks/use-runtime-logs-filters.ts
  • web/apps/dashboard/lib/schemas/runtime-logs.filter.schema.ts
  • web/apps/dashboard/lib/schemas/runtime-logs.schema.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/deployment/runtime-logs.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/list-instances.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/llm-search/utils.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/utils.ts
  • web/apps/dashboard/lib/trpc/routers/index.ts
  • web/internal/clickhouse/src/runtime-logs.ts

Comment thread web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts
Copy link
Copy Markdown
Collaborator

@chronark chronark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of small things + rabbit

@ogzhanolguncu
Copy link
Copy Markdown
Contributor Author

@chronark fixed now

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts (2)

95-101: Keep unresolved instance_id values nullable in the API response.

Using "—" here bakes a display placeholder into the TRPC contract, so downstream code can't distinguish “unresolved instance” from a real ID. Prefer returning null/undefined here and let the UI render the fallback. As per coding guidelines, "Make illegal states unrepresentable by modeling domain with discriminated unions and parsing inputs at boundaries into typed structures".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts` around
lines 95 - 101, The mapped logs currently set unresolved instance_id to the
display placeholder "—" inside the chLogs.map creating logs; instead return a
nullable value so the TRPC response preserves the unresolved state. In the
mapping where you use k8sNameToInstanceId.get(log.k8s_pod_name) for instance_id,
change the fallback from the string "—" to null (or undefined based on existing
typing) so downstream UI can render its own placeholder; ensure the logs
variable (created by chLogs.map) and any related return type/signature reflect
the nullable instance_id in the TRPC contract.

87-93: Skip the fallback lookup when there are no unknown pod names.

resolveK8sNamesToInstanceIds is called even when unknownK8sNames is empty. A cheap guard keeps empty pages and fully-resolved pages from doing extra work.

♻️ Proposed change
-    const resolvedMapping = await resolveK8sNamesToInstanceIds(unknownK8sNames);
+    const resolvedMapping =
+      unknownK8sNames.length > 0
+        ? await resolveK8sNamesToInstanceIds(unknownK8sNames)
+        : new Map<string, string>();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts` around
lines 87 - 93, The code always calls resolveK8sNamesToInstanceIds even when
unknownK8sNames is empty; add a cheap guard to skip the call and avoid work:
check if unknownK8sNames.length === 0 and if so set resolvedMapping to an empty
Map (or simply construct k8sNameToInstanceId from knownK8sToInstanceId) instead
of awaiting resolveK8sNamesToInstanceIds, otherwise call
resolveK8sNamesToInstanceIds as before and build k8sNameToInstanceId from
[...knownK8sToInstanceId, ...resolvedMapping]; reference unknownK8sNames,
resolveK8sNamesToInstanceIds, knownK8sToInstanceId, and k8sNameToInstanceId.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts`:
- Around line 95-101: The mapped logs currently set unresolved instance_id to
the display placeholder "—" inside the chLogs.map creating logs; instead return
a nullable value so the TRPC response preserves the unresolved state. In the
mapping where you use k8sNameToInstanceId.get(log.k8s_pod_name) for instance_id,
change the fallback from the string "—" to null (or undefined based on existing
typing) so downstream UI can render its own placeholder; ensure the logs
variable (created by chLogs.map) and any related return type/signature reflect
the nullable instance_id in the TRPC contract.
- Around line 87-93: The code always calls resolveK8sNamesToInstanceIds even
when unknownK8sNames is empty; add a cheap guard to skip the call and avoid
work: check if unknownK8sNames.length === 0 and if so set resolvedMapping to an
empty Map (or simply construct k8sNameToInstanceId from knownK8sToInstanceId)
instead of awaiting resolveK8sNamesToInstanceIds, otherwise call
resolveK8sNamesToInstanceIds as before and build k8sNameToInstanceId from
[...knownK8sToInstanceId, ...resolvedMapping]; reference unknownK8sNames,
resolveK8sNamesToInstanceIds, knownK8sToInstanceId, and k8sNameToInstanceId.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a076f748-7dc8-4073-a929-58d8027e38e8

📥 Commits

Reviewing files that changed from the base of the PR and between b4509ba and 44cff3d.

📒 Files selected for processing (3)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/index.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/runtime-logs-region-filter.tsx
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/logs/components/controls/components/runtime-logs-filters/runtime-logs-region-filter.tsx

@ogzhanolguncu ogzhanolguncu requested a review from chronark March 17, 2026 14:38
@ogzhanolguncu
Copy link
Copy Markdown
Contributor Author

@mcstepp You are right being extra careful doesn't hurt. It should be good to go now.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts`:
- Around line 50-58: The code is mapping instances by instances.k8sName which is
only unique per region and can be overwritten across regions; update the mapping
in the block that builds knownK8sToInstanceId (and other similar mappings used
later) to use a region-aware composite key (for example `${k8sName}::${region}`
or the actual region field) instead of k8sName alone, and update the companion
function resolveK8sNamesToInstanceIds in
web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/utils.ts to return and
accept these region-aware keys so callers (including the places that build
knownK8sToInstanceId and the code paths referenced by
resolveK8sNamesToInstanceIds) can correctly look up instance_id by the composite
key.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d053dd8c-7cd5-4333-9867-ce9f5a6fee33

📥 Commits

Reviewing files that changed from the base of the PR and between ad6f2bd and 2d4977c.

📒 Files selected for processing (3)
  • web/apps/dashboard/lib/trpc/routers/deploy/deployment/runtime-logs.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/utils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/utils.ts

Comment thread web/apps/dashboard/lib/trpc/routers/deploy/runtime-logs/query.ts
@perkinsjr perkinsjr added this pull request to the merge queue Apr 3, 2026
Merged via the queue into main with commit c56b754 Apr 3, 2026
20 checks passed
@perkinsjr perkinsjr deleted the update-runtime-logs branch April 3, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants