Skip to content

Feat/improved logging#3833

Draft
TheodoreSpeaks wants to merge 9 commits intostagingfrom
feat/improved-logging
Draft

Feat/improved logging#3833
TheodoreSpeaks wants to merge 9 commits intostagingfrom
feat/improved-logging

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

We need additional observability into our system, even for successful calls.
Add additional logs for the /execute endpoint with metadata for user id, workflow id, workspace id, execution id. Reverted change to upgrade mothership chat logs to error.

I upgraded our logging system to INFO, so all logs should start showing up.

New formatting:

  [2026-03-28T14:32:01.500Z] [DEBUG] [ExecutionLogger] {workflowId=wf-9f3e workspaceId=ws-7720 executionId=exec-88f2} Starting workflow
   execution
  [2026-03-28T14:32:01.512Z] [DEBUG] [ExecutionLogger] {workflowId=wf-9f3e workspaceId=ws-7720 executionId=exec-88f2} Created workflow
  log {"logId":"log-ab12"}
  [2026-03-28T14:32:02.200Z] [DEBUG] [ExecutionLogger] {executionId=exec-88f2} Completing workflow execution {"isResume":false}
  [2026-03-28T14:32:02.350Z] [ERROR] [ExecutionLogger] {workflowId=wf-9f3e executionId=exec-88f2} Workflow not found for user stats
  update

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

Ran workflow execution and validated new metadata logs are shown

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)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 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 29, 2026 0:37am

Request Review

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 28, 2026

PR Summary

Medium Risk
Broad logging changes across workflow execution and copilot/orchestrator paths could increase log volume and affect alerting/performance, but do not change core execution behavior.

Overview
Improves observability by introducing Logger.withMetadata() in @sim/logger and updating log formatting to automatically append key/value metadata to every line.

Refactors workflow execution (/api/workflows/[id]/execute and executor engine/block execution) to use request/execution-scoped loggers with consistent metadata (requestId, workflowId, workspaceId, userId, executionId) and cleans up many log messages.

Downgrades many copilot/chat/orchestrator lifecycle logs from error to info (including stream resume and tool execution) so successful flows are visible without being flagged as errors.

Written by Cursor Bugbot for commit 584ac10. This will update automatically on new commits. Configure here.

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR delivers two main changes under a single branch: (1) structured logging improvements for the /execute endpoint and copilot routes, and (2) a set of UI enhancements to the sidebar, markdown file viewer, and plus-menu dropdown.

Logging changes:

  • Adds a withMetadata() method to the core Logger class, enabling child loggers that automatically prepend key-value context (workflowId, workspaceId, userId, executionId) to every log line without repeating it in every call site.
  • Migrates the /execute route from ad-hoc [requestId] string prefixes to a structured reqLogger / asyncLogger built via withMetadata(), matching the new format shown in the PR description.
  • Reverts a previous mistake where informational copilot/mothership chat events were logged at ERROR level — all corrected back to INFO.
  • Good test coverage added for withMetadata (inheritance, merge, override, undefined filtering).

UI changes:

  • Interactive checkbox toggling in the Markdown file preview, using a render-phase counter ref to track checkbox indices across ReactMarkdown renders.
  • PlusMenuDropdown refactored to open at an arbitrary viewport anchor (e.g. the @ caret position in the textarea), using a virtual zero-size fixed trigger element.
  • Sidebar improvements: keyboard shortcuts for new workflow/task (Mod+Shift+P / Mod+Shift+K), international keyboard layout fix via codeToKey(), sidebar expand via keyboard, and a search-modal centering fix that accounts for sidebar width.

Notable findings:

  • The production log level default remains ERROR; the new INFO-level execute route logs require LOG_LEVEL=INFO to be set in the environment to take effect.
  • reqLogger is updated twice with userId in handleExecutePost — once from auth.userId and once from actorUserId — which can produce inconsistent context in logs for workspace API key requests.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style/informational suggestions with no runtime impact

The core logging feature is well-implemented and thoroughly tested. Copilot route fixes are straightforward level downgrades. UI changes are self-contained. No P0/P1 issues found — both flagged items are P2 observations that don't block correct operation.

No files require special attention; the two P2 notes in packages/logger/src/index.ts and apps/sim/app/api/workflows/[id]/execute/route.ts are informational only

Important Files Changed

Filename Overview
packages/logger/src/index.ts Adds withMetadata() to the Logger class, returning a child logger that prepends key-value pairs to every log line; production default log level remains ERROR (override via LOG_LEVEL env var)
packages/logger/src/index.test.ts Adds thorough unit tests for the new withMetadata feature, covering inheritance, merging, override, and undefined-value filtering
apps/sim/app/api/workflows/[id]/execute/route.ts Replaces manual [requestId] string prefixes with structured reqLogger / asyncLogger built via withMetadata; executionId, userId, workspaceId, and workflowId are all carried in metadata
apps/sim/lib/logs/execution/logger.ts Adopts withMetadata for executionId context; enriches execLog with workflowId/workspaceId after DB lookup inside completeExecution
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx Adds interactive checkbox support for Markdown previews; uses a render-phase counter ref pattern to track checkbox indices across ReactMarkdown renders
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/plus-menu-dropdown.tsx Refactors PlusMenuDropdown to position itself at an arbitrary viewport anchor (e.g. caret position); separates the trigger button from the DropdownMenu using a zero-size virtual anchor div
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Large sidebar refactor: adds keyboard shortcuts (Mod+Shift+P/K) for adding workflows/tasks, sidebar expand via keyboard, collapsed-edge click handler, and search modal centering fix for sidebar offset

Sequence Diagram

sequenceDiagram
    participant Client
    participant ExecuteRoute as /execute route
    participant Logger as Logger (withMetadata)
    participant DB

    Client->>ExecuteRoute: POST /api/workflows/{id}/execute
    Note over ExecuteRoute: reqLogger = logger.withMetadata({requestId, workflowId})
    ExecuteRoute->>ExecuteRoute: checkHybridAuth()
    Note over ExecuteRoute: executionId = uuidv4()<br/>reqLogger = reqLogger.withMetadata({userId, executionId})
    ExecuteRoute->>Logger: reqLogger.info("Starting server-side execution")
    ExecuteRoute->>DB: authorizeWorkflow + preprocessExecution
    DB-->>ExecuteRoute: workflow record (incl. workspaceId, actorUserId)
    Note over ExecuteRoute: reqLogger = reqLogger.withMetadata({workspaceId, userId: actorUserId})
    ExecuteRoute->>Logger: reqLogger.info("Preprocessing passed")
    ExecuteRoute->>ExecuteRoute: run workflow (SSE or non-SSE)
    ExecuteRoute->>Logger: reqLogger.info/error (block events, errors)
    ExecuteRoute-->>Client: response
Loading

Reviews (2): Last reviewed commit: "improvement(ui): sidebar (#3832)" | Re-trigger Greptile

waleedlatif1 and others added 5 commits March 28, 2026 15:54
#3830)

* improvement(sidebar): expand sidebar by hovering and clicking the edge

* improvement(sidebar): add keyboard shortcuts for new workflow/task, center search modal, fix edge ARIA

* improvement(sidebar): use Tooltip.Shortcut for inline shortcut display

* fix(sidebar): change new workflow shortcut from Mod+Shift+W to Mod+Shift+P to avoid browser close-window conflict

* fix(hotkeys): fall back to event.code for international keyboard layout compatibility

* fix(sidebar): guard add-workflow shortcut with canEdit and isCreatingWorkflow checks
* feat(ui): handle image paste

* Fix lint

* Fix type error

---------

Co-authored-by: Theodore Li <theo@sim.ai>
* feat(files): interactive markdown checkbox toggling in preview

* fix(files): handle ordered-list checkboxes and fix index drift

* lint

* fix(files): remove counter offset that prevented checkbox toggling

* fix(files): apply task-list styling to ordered lists too

* fix(files): render single pass when interactive to avoid index drift

* fix(files): move useMemo above conditional return to fix Rules of Hooks

* fix(files): pass content directly to preview when not streaming to avoid stale frame
…sistency (#3831)

* improvement(home): position @ mention popup at caret and fix icon consistency

* fix(home): pin mirror div to document origin and guard button anchor

* chore(auth): restore hybrid.ts to staging
@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@greptile review

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.

2 participants