Skip to content

feat(logs): add copy link and deep link support for log entries#3855

Merged
waleedlatif1 merged 6 commits intostagingfrom
feat/log-link
Mar 31, 2026
Merged

feat(logs): add copy link and deep link support for log entries#3855
waleedlatif1 merged 6 commits intostagingfrom
feat/log-link

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Added "Copy Link" to the log row right-click context menu, copying a shareable URL with `?executionId=` as the param
  • Opening a deep link auto-selects the matching log and opens the details panel
  • Deep link search continues across paginated loads, clears cleanly once all pages are exhausted or the log is found
  • Eliminated 6 ref-sync `useEffect`s in favor of inline ref assignments during render
  • Removed unused `contextMenuRef`

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 31, 2026

PR Summary

Medium Risk
Adds URL-driven log auto-selection with pagination-driven auto-fetching, which could cause unexpected extra requests or selection behavior if query params or paging state are wrong. Otherwise changes are localized to the logs UI and clipboard interactions.

Overview
Adds a “Copy Link” action to the logs row context menu that copies a shareable URL pointing back to the logs page with ?executionId=....

The logs page now reads an executionId query param on load and auto-selects/open the matching log, continuing to page through results until found (or pages are exhausted). It also tightens clipboard writes with .catch(() => {}) and simplifies state/ref syncing by replacing several ref-update useEffects with direct assignments during render.

Written by Cursor Bugbot for commit 48bdbe5. Configure here.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 31, 2026 4:10am

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR adds "Copy Link" / deep-link support to the logs view: a new context-menu item copies a shareable URL with ?executionId=, and on page load the app auto-selects and opens the matching log entry, paging through TanStack Query results until it is found or all pages are exhausted.

A nice secondary cleanup landed alongside the feature: six ref-sync useEffects were replaced with direct render-time assignments, and the orphaned contextMenuRef was removed.

All five P1 issues raised in earlier review rounds have been correctly resolved in this final commit — the fetchNextPage() call is now gated on logsQuery.status === 'success' (preventing spurious fetches before the query is enabled), the early-exit guard that left pendingExecutionIdRef stuck on empty results was removed, and the Link icon was moved into the internal icon library.

  • Deep-link effect (logs.tsx lines 431–443): correctly guards both the "clear ref" and "fetch next page" branches on status === 'success', preventing premature execution during the disabled-query window on initial mount.
  • Inline ref sync (lines 420–429): replaces 6 effect-based syncs with direct assignments in the render body — a valid pattern for refs used only inside stable callbacks.
  • handleCopyLink (line 499–504): constructs the URL from window.location.origin + route params; .catch(() => {}) prevents unhandled clipboard rejections.
  • link.tsx: new emcn icon component following the existing SVG icon pattern.
  • Minor concern: the copied URL does not carry active filter params (e.g. timeRange), so a receiver whose default window doesn't cover the log's timestamp will silently see no selection. Worth considering either forwarding the time range or surfacing a toast when the target isn't found.

Confidence Score: 5/5

  • Safe to merge — all previously raised P1 issues are resolved and no new critical issues were found.
  • Every P1 concern from prior review rounds (premature fetchNextPage before query is enabled, ref stuck on empty results, ref cleared before query starts, icon consistency, unhandled clipboard promise) has been addressed in the final commits. The single remaining comment is a P2 UX concern about missing filter state in the copied URL, which does not block correctness or reliability of the feature.
  • No files require special attention; all changed files are clean.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/logs/logs.tsx Core changes: adds pendingExecutionIdRef deep-link effect (with correct status === 'success' guards), replaces 6 ref-sync effects with inline render assignments, adds handleCopyLink, and removes unused contextMenuRef. All previously flagged P1 issues are resolved.
apps/sim/app/workspace/[workspaceId]/logs/components/log-row-context-menu/log-row-context-menu.tsx Adds onCopyLink prop and "Copy Link" menu item using the now-internal Link icon; consistent with existing menu item patterns and guarded by hasExecutionId.
apps/sim/components/emcn/icons/link.tsx New Link SVG icon component, following the same pattern as other icons in the library.
apps/sim/components/emcn/icons/index.ts Barrel export updated with Link icon in alphabetical order.

Sequence Diagram

sequenceDiagram
    participant User
    participant ContextMenu as LogRowContextMenu
    participant Logs as logs.tsx
    participant Clipboard as Clipboard API
    participant TanStack as TanStack Query

    User->>ContextMenu: Right-click log row
    ContextMenu->>User: Show context menu

    User->>ContextMenu: Click "Copy Link"
    ContextMenu->>Logs: onCopyLink()
    Logs->>Clipboard: writeText(url with ?executionId=)
    Clipboard-->>Logs: resolved/.catch(()=>{})

    Note over User,TanStack: Opening a deep link

    User->>Logs: Navigate to ?executionId=XYZ
    Logs->>Logs: useEffect[] sets pendingExecutionIdRef = XYZ
    Logs->>TanStack: isInitialized → enables query
    TanStack-->>Logs: status='success', sortedLogs updated

    loop Until found or exhausted
        Logs->>Logs: deep-link effect: search sortedLogs for XYZ
        alt found
            Logs->>Logs: dispatch TOGGLE_LOG, clear ref
        else hasNextPage && !isFetching && status=success
            Logs->>TanStack: fetchNextPage()
            TanStack-->>Logs: next page loaded
        else !hasNextPage && status=success
            Logs->>Logs: clear ref (not found)
        end
    end
Loading

Reviews (5): Last reviewed commit: "fix(logs): guard fetchNextPage call unti..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

- Remove  guard that prevented clearing the
  pending ref when filters return no results
- Use  directly in the condition and add it to
  the effect deps so the effect re-triggers after a background refetch
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Only clear pendingExecutionIdRef when the query status is 'success',
preventing premature clearing before the initial fetch completes.
On mount, the query is disabled (isInitialized.current starts false),
so hasNextPage is false but no data has loaded yet — the ref was being
cleared in the same effect pass that set it.
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Add logsQuery.status === 'success' to the fetchNextPage branch so it
mirrors the clear branch. On mount the query is disabled (isFetching is
false, status is pending), causing the effect to call fetchNextPage()
before the query is initialized — now both branches require success.
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit e9c94fa into staging Mar 31, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/log-link branch March 31, 2026 01:42
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