Skip to content

fix(navigation): use eventIndex for cross-view event targeting#788

Open
lukecotter wants to merge 6 commits into
certinia:mainfrom
lukecotter:feat-row-indexing
Open

fix(navigation): use eventIndex for cross-view event targeting#788
lukecotter wants to merge 6 commits into
certinia:mainfrom
lukecotter:feat-row-indexing

Conversation

@lukecotter
Copy link
Copy Markdown
Contributor

Summary

Timestamps are not unique within an Apex log, so cross-view navigation (call tree ↔ timeline ↔ DML/SOQL detail) occasionally resolved the wrong event when two log lines shared a timestamp. This PR plumbs a monotonic eventIndex end-to-end and reserves timestamp for the one path where it's the only key available (raw-log file → timeline entry).

Changes

  • Parser assigns a monotonic eventIndex to every log event and exposes eventsById for O(1) lookup; EventSearch gains findEventByEventIndex alongside findEventByTimestamp.
  • Call-tree, DML, SOQL, CallStack, SOQLLinterIssues, DatabaseSOQLDetailPanel, and timeline markers all key on eventIndex; the timestamp props, data-timestamp attribute, and DatabaseAccess.getStack are removed.
  • Tabulator row ids standardized to numeric: time-order uses eventIndex, aggregated/SOQL/DML use synthetic counters; goToRow materializes the path by id and awaits scroll completion to avoid selecting adjacent rows.
  • EventBus.timeline:navigate-to becomes a discriminated union ({ eventIndex } | { timestamp }); ApexLogTimeline picks the path structurally rather than gating on apexLog readiness, and navigateToTimestamp now guards against unset events.
  • LogViewer postMessage handler accepts the timestamp-only payload from the raw-log entry command and forwards it on the timestamp branch — fixes show-in-timeline silently dropping the message when the panel was already open.

Test plan

  • pnpm lint
  • pnpm test — new regressions in EventSearch.test.ts and Database.test.ts cover duplicate-timestamp lookups
  • manual smoke: call-tree → timeline jump, timeline ⌘-click → call-tree, DML/SOQL detail expand, raw-log → timeline with the panel both closed and already open

Reviewer guidance

  • Start with apex-log-parser/src/ApexLogParser.ts (eventIndex assignment) and core/utility/EventSearch.ts (new lookup), then the EventBus discriminated union — the rest is propagation.
  • The tabulator/module/RowNavigation.ts changes (await scroll, path materialization) are the trickiest part of the call-tree side.

- assign a monotonic eventIndex to each parsed log event and expose eventsById for stable lookups when timestamps collide
- route eventIndex through call tree, timeline, soql, call stack, and problem actions so navigation resolves the exact event instead of first matching timestamp
- rework call-tree row targeting to materialize the event path by id and await custom goToRow scrolling to avoid selecting adjacent rows
- make row centering wait on tabulator render lifecycle and add duplicate-timestamp regressions for EventSearch and Database stack resolution
…t targeting

Migrate call-tree navigation, timeline markers, row identification, and event lookups
from timestamp-based to unique eventIndex throughout all cross-component flows.

- Parser issues and timeline markers now carry optional eventIndex for concrete events
- Call-tree navigation requires eventIndex; timestamp fallback removed entirely
- Standardize all Tabulator row ids to numeric (time-order uses eventIndex; aggregated/SOQL/DML use synthetic counters)
- EventBus, notifications, and UI navigation wired to propagate eventIndex end-to-end
- Timeline click-to-calltree jumps now use eventIndex instead of timestamp-only lookups
only for raw-log entry

Timestamps aren't unique, so cell→detail and cross-view navigation
occasionally resolved the wrong event; the panel-already-open raw-log
entry also silently dropped its postMessage.

- CallStack/DML/SOQL/SOQLLinterIssues/DatabaseSOQLDetailPanel: stack
lookups and detail panels now key on eventIndex; drop the timestamp props,
  the data-timestamp attribute, and DatabaseAccess.getStack
- EventBus timeline:navigate-to becomes a discriminated union ({
eventIndex } | { timestamp }); ApexLogTimeline listener picks the path
structurally instead of via the apexLog readiness flag, and
navigateToTimestamp now guards against unset events
- LogViewer postMessage handler accepts timestamp-only payloads (raw-log
entry) and forwards them via the timestamp branch, fixing show-in-timeline
  when the panel is already open
- goToRow and the calltree timeline:navigate-to emit drop the now-dead
timestamp parameter across Timeline, ApexLogTimeline, and CalltreeView
call sites
- narrow filter-cache and DeepFilterable id types from `number | string` to `number`
now that all row ids are numeric, removing an unreachable union arm - drop write-only `timestamp` fields from DMLRow/GridSOQLData rows left over after detail panels
switched to eventIndex
- remove the unused `idMode` branch in _navigateToSearchResult; EventNode id is always
built from eventIndex (selection matches by reference, not id)
Make event-index navigation O(depth) and tolerate missing ancestors.

- rewrite getStackByEventIndex to walk parent pointers from eventsById, replacing the
  O(n) full-tree scan with an O(depth) ascent
- add _waitForTableRender so tree-expand navigation waits on renderComplete (two-frame
  fallback) instead of a single rAF that races the virtual renderer
- fall back to the nearest resolved ancestor when an event is filtered out, rather
  than aborting navigation
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