Skip to content

[OPIK-4473] [FE] Update Traces table default columns#5257

Open
YarivHashaiComet wants to merge 3 commits intomainfrom
yariv-h/OPIK-4473-update-traces-table-default-columns
Open

[OPIK-4473] [FE] Update Traces table default columns#5257
YarivHashaiComet wants to merge 3 commits intomainfrom
yariv-h/OPIK-4473-update-traces-table-default-columns

Conversation

@YarivHashaiComet
Copy link
Collaborator

Details

Update default visible columns for new users on the Traces tab. Previously showed: ID, Name, Start time, Input, Output, Duration, Comments, User Feedback. Now shows: Start time, Input, Output, Errors, Duration, Total tokens, Estimated cost, Tags, Comments.

Also split the shared DEFAULT_TRACES_PAGE_COLUMNS into separate DEFAULT_TRACES_COLUMNS and DEFAULT_SPANS_COLUMNS constants so each view can have independent defaults.

Existing users with saved column preferences are not affected (localStorage takes precedence).

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-4473

Testing

  • Clear localStorage for the traces table (or use incognito)
  • Navigate to a project's Traces tab
  • Verify the default visible columns are: Start time, Input, Output, Errors, Duration, Total tokens, Estimated cost, Tags, Comments
  • Verify ID, Name, and User Feedback are available in the column selector but not shown by default
  • Verify the Spans tab still uses its own defaults (unchanged)

Documentation

N/A

Update default visible columns for new users on the Traces tab:
Start time, Input, Output, Errors, Duration, Total tokens, Estimated cost,
Tags, Comments. Also split shared defaults into separate trace/span constants
so each view can have its own defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@YarivHashaiComet YarivHashaiComet marked this pull request as ready for review February 17, 2026 14:20
@YarivHashaiComet YarivHashaiComet requested a review from a team as a code owner February 17, 2026 14:20
aadereiko
aadereiko previously approved these changes Feb 17, 2026
Copy link
Collaborator

@aadereiko aadereiko left a comment

Choose a reason for hiding this comment

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

This solution is ok but we should also take into account that users already have some columns in local storages, and it will work when they open it newly

Set default columnsOrder to match ticket-specified visual order using
v2 key migration. Existing users with custom orders are preserved,
while users with default (empty) orders get the new ordering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines 60 to 65
const oldData = localStorage.getItem(oldStorageKey);

if (oldData !== null) {
const parsed = JSON.parse(oldData);
if (Array.isArray(parsed) && parsed.length > 0) {
return parsed;
Copy link
Contributor

Choose a reason for hiding this comment

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

migrateColumnsOrder JSON.parses ${type}-columns-order without guarding, so a corrupted or manually edited value throws during TracesSpansTab initialization and the table fails to render; can we wrap this parse in a try/catch and fall back to the default order instead?

Suggested change
const oldData = localStorage.getItem(oldStorageKey);
if (oldData !== null) {
const parsed = JSON.parse(oldData);
if (Array.isArray(parsed) && parsed.length > 0) {
return parsed;
const oldData = localStorage.getItem(oldStorageKey);
if (oldData !== null) {
try {
const parsed = JSON.parse(oldData);
if (Array.isArray(parsed) && parsed.length > 0) {
return parsed;
}
} catch {
// Ignore malformed JSON and fall back to defaultOrder
}

Finding type: Logical Bugs


  • Apply fix with Baz

Copy link
Contributor

Choose a reason for hiding this comment

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

Commit 7d7652f addressed this comment by wrapping the JSON.parse(oldData) call in a try/catch inside migrateColumnsOrder. On parse failure it now ignores the malformed value and falls back to defaultOrder, preventing TracesSpansTab initialization from crashing due to corrupted localStorage.

Existing users with saved v2 preferences now get the new default
columns. Also adds try/catch to migrateColumnsOrder for robustness.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines 503 to 510
const [selectedColumns, setSelectedColumns] = useLocalStorageState<string[]>(
`${type}-${SELECTED_COLUMNS_KEY_V2_SUFFIX}`,
`${type}-${SELECTED_COLUMNS_KEY_V3_SUFFIX}`,
{
defaultValue: migrateSelectedColumns(
`${type}-${SELECTED_COLUMNS_KEY_SUFFIX}`,
DEFAULT_TRACES_PAGE_COLUMNS,
[COLUMN_ID_ID, "start_time"],
),
defaultValue:
type === TRACE_DATA_TYPE.traces
? DEFAULT_TRACES_COLUMNS
: DEFAULT_SPANS_COLUMNS,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Switched to ${type}-selected-columns-v3 with hardcoded defaults but no migration, so every user who had custom selections under the previous ${type}-selected-columns(-v2) keys loses their visibility setup; can we migrate the old localStorage data instead of unconditionally falling back to the new defaults?

Finding type: Logical Bugs


  • Apply fix with Baz
Other fix methods

Prompt for AI Agents:

In apps/opik-frontend/src/components/pages/TracesPage/TracesSpansTab/TracesSpansTab.tsx
around lines 503 to 510, the selectedColumns initialization (useLocalStorageState) was
switched to `${type}-${SELECTED_COLUMNS_KEY_V3_SUFFIX}` with hardcoded defaults but no
migration. Modify this initialization to attempt to migrate any existing values from the
older keys (`${type}-${SELECTED_COLUMNS_KEY_SUFFIX}` and
`${type}-${SELECTED_COLUMNS_KEY_V2_SUFFIX}`) into the new v3 key before falling back to
the defaults; implement this by reading localStorage (or using an existing migration
helper like migrateColumnsOrder/migrateSelectedColumns if available), normalizing the
stored column arrays, writing the migrated value into the v3 key, and passing that
migrated array as defaultValue to useLocalStorageState. Ensure this runs once on
initialization so users keep their prior custom selections.

Fix in Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants