Skip to content

fix: save selected view in configuration - #502

Merged
sergiofilhowz merged 2 commits into
mainfrom
fix/save-session-config
Jul 15, 2026
Merged

fix: save selected view in configuration#502
sergiofilhowz merged 2 commits into
mainfrom
fix/save-session-config

Conversation

@sergiofilhowz

@sergiofilhowz sergiofilhowz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Problem

The Traces tab's saved views live server-side in the console configuration entry, but the active view selection was stored in per-browser localStorage. The selection didn't follow the engine — every new browser (or cleared storage) lost the choice, and the seeded "sessions" view was only selected via a frontend fallback.

Solution

Persist the pointer next to the views as traces.activeViewId in the console configuration entry:

  • The console worker seeds activeViewId: "view-sessions" and documents the field in the entry schema; when the pointer is absent (configs seeded before this change) the UI still defaults to the sessions view.
  • useTraceViews reads/writes the pointer through the existing read-modify-write mutation funnel; the in-tab selection stays live even when the configuration worker is unreachable.
  • Deleting the active view clears the pointer in the same config write, so the two updates can't interleave and the pointer never dangles.
  • Removed the now-unused localStorage helpers.

Also updates vite.config.ts to match the binary's server posture: binds 0.0.0.0 so the dev server accepts external connections, and the /ws proxy engine target is configurable via III_ENGINE_URL (same default as the binary's --url).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • TRACES V2 now uses server-backed console configuration to select the active view (with an immediate per-tab override that stays responsive if saving fails).
    • “Follow turns” is now persisted via console configuration (defaulting to enabled) and managed through a dedicated toggle hook.
  • Bug Fixes
    • Deleting the currently active view now reliably clears the selection so it can’t remain dangling.
  • Developer Experience
    • Dev Engine WebSocket proxy now derives from a configurable Engine URL (with a local fallback).

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jul 15, 2026 1:13pm
workers-tech-spec Ready Ready Preview, Comment Jul 15, 2026 1:13pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 42 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Traces V2 active-view and follow-turn preferences now use server-side console configuration instead of localStorage. Tab-local choices remain responsive, view deletion updates its pointer atomically, and the Vite WebSocket proxy accepts a configurable Engine URL.

Changes

Traces preferences persistence

Layer / File(s) Summary
Console preference contract
console/src/configuration.rs, console/web/src/pages/TracesV2/lib/tracesViews.ts
The console configuration adds active-view and follow-turn fields with defaults, and traces helpers parse and write the active-view pointer.
Tab selection and atomic view mutations
console/web/src/lib/storage.ts, console/web/src/pages/TracesV2/hooks/useTraceViews.ts, console/web/src/pages/TracesV2/index.tsx
Active-view localStorage helpers are removed; server state, tab-local overrides, whole-entry writes, and atomic deletion pointer cleanup are used instead.
Server-backed follow-turn toggle
console/web/src/pages/TracesV2/hooks/useFollowTurns.ts, console/web/src/pages/TracesV2/index.tsx
Follow-turn state moves to a dedicated hook that persists console configuration changes while retaining responsive tab-local state.

Development Engine WebSocket proxy

Layer / File(s) Summary
Configurable development WebSocket target
console/web/vite.config.ts
The /ws proxy target now uses III_ENGINE_URL, falling back to the local Engine endpoint.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

Poem

A rabbit hops where saved views grow,
From browser crumbs to server flow.
Follow-turns now persist just right,
Deleted views leave pointers light.
WebSockets tunnel through the night! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: persisting the Traces selected view in server-side configuration.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/save-session-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sergiofilhowz
sergiofilhowz merged commit f52a1bd into main Jul 15, 2026
12 of 15 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
console/web/src/pages/TracesV2/hooks/useFollowTurns.ts (2)

70-88: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Destructure mutateAsync to preserve reference stability.

The mutation object returned by useMutation changes reference on every status update (e.g., idle → pending → success). Passing it in the dependency array causes toggleFollowTurns to be recreated repeatedly, which can trigger unnecessary re-renders of downstream child components like TimelineStrip.

Destructure mutateAsync (which has a guaranteed stable reference) to prevent this.

♻️ Proposed refactor
-  const mutation = useMutation({
+  const { mutateAsync } = useMutation({
     mutationFn: async (on: boolean) => {
       const current = (await fetchConsoleConfigValue()) ?? {}
       const next = withFollowTurns(current, on)
       await setConsoleConfigValue(next)
       return next
     },
     onSuccess: (next) => {
       qc.setQueryData(CONSOLE_CONFIG_QUERY_KEY, next)
     },
   })
 
   const toggleFollowTurns = useCallback(() => {
     const next = !followTurns
     setChosen(next)
     // Best-effort server persist; the in-memory choice stays live even when
     // the configuration worker is unreachable.
-    mutation.mutateAsync(next).catch(() => {})
-  }, [followTurns, mutation])
+    mutateAsync(next).catch(() => {})
+  }, [followTurns, mutateAsync])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@console/web/src/pages/TracesV2/hooks/useFollowTurns.ts` around lines 70 - 88,
Destructure mutateAsync from the useMutation result and update toggleFollowTurns
to call it directly. Replace the mutation object in the callback dependency
array with the stable mutateAsync reference, preserving the existing best-effort
error handling and toggle behavior.

21-23: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Centralize the shared query key.

Consider exporting this query key from @/lib/console-config instead of redefining it locally in each hook. Centralizing the key prevents subtle cache-miss bugs caused by typos across different consumers (like useTraceViews and useSpanFilterSelection).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@console/web/src/pages/TracesV2/hooks/useFollowTurns.ts` around lines 21 - 23,
Centralize CONSOLE_CONFIG_QUERY_KEY in the `@/lib/console-config` module by
exporting it there, then update useFollowTurns and the related consumers such as
useTraceViews and useSpanFilterSelection to import and reuse that shared symbol
instead of defining local keys.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@console/web/src/pages/TracesV2/hooks/useFollowTurns.ts`:
- Around line 70-88: Destructure mutateAsync from the useMutation result and
update toggleFollowTurns to call it directly. Replace the mutation object in the
callback dependency array with the stable mutateAsync reference, preserving the
existing best-effort error handling and toggle behavior.
- Around line 21-23: Centralize CONSOLE_CONFIG_QUERY_KEY in the
`@/lib/console-config` module by exporting it there, then update useFollowTurns
and the related consumers such as useTraceViews and useSpanFilterSelection to
import and reuse that shared symbol instead of defining local keys.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c41f93c5-01cb-4788-96e8-86d51410b3b7

📥 Commits

Reviewing files that changed from the base of the PR and between 3756860 and 7cbc103.

📒 Files selected for processing (4)
  • console/src/configuration.rs
  • console/web/src/lib/storage.ts
  • console/web/src/pages/TracesV2/hooks/useFollowTurns.ts
  • console/web/src/pages/TracesV2/index.tsx
💤 Files with no reviewable changes (1)
  • console/web/src/lib/storage.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • console/src/configuration.rs

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.

1 participant