Skip to content

v0.6.66: child trace spans, reranker controls, attachment previews, logs block, parallel-in-loop wall clock, gpt-image-2#4444

Merged
waleedlatif1 merged 15 commits intomainfrom
staging
May 5, 2026
Merged

v0.6.66: child trace spans, reranker controls, attachment previews, logs block, parallel-in-loop wall clock, gpt-image-2#4444
waleedlatif1 merged 15 commits intomainfrom
staging

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented May 5, 2026

waleedlatif1 and others added 14 commits May 4, 2026 00:11
…#4425)

* fix(table): return 400 instead of 500 for malformed sort/filter input

* fix(table): revert default-case throw to plain Error and update JSDoc @throws tags
… calls (#4428)

* fix(executor): strip childTraceSpans from block state before LLM tool calls

* fix(executor): return stripped output so orchestrator setBlockOutput stays clean
* feat(knowledge): expose Cohere reranker controls on knowledge block

Add a self-hosted Cohere API key field (mirroring the agent block's hosted-key
pattern), a configurable reranker input pool size (1-100), and surface
meta.warnings from Cohere rerank responses via logger.warn. All new contract
fields are optional and nullable for full backwards compatibility.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(knowledge): address PR feedback on Cohere reranker controls

- Drop required:true on apiKey field — server has BYOK→env→rotation fallback
  chain, so self-hosted users with COHERE_API_KEY env should not be blocked
- Drop .min(1) on rerankerApiKey contract field so empty strings coerce to
  undefined via the transform (matches the existing query field pattern)
- Log a warning when rerankerInputCount is clamped up to topK so users notice
  their setting was overridden

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* feat(knowledge): mirror agent block API key visibility for Cohere reranker

Restore required:true on the Cohere API Key field and hide it server-side via
a new NEXT_PUBLIC_COHERE_CONFIGURED public env flag — same pattern the Agent
block uses for Azure (NEXT_PUBLIC_AZURE_CONFIGURED). Self-hosters who set
COHERE_API_KEY in their environment also set NEXT_PUBLIC_COHERE_CONFIGURED=true,
which removes the field from the UI; everyone else sees a required field.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(knowledge): treat empty rerankerInputCount as unset

An empty string from the Documents Sent to Reranker input passed the
undefined/null guard, so Number('') = 0 → clamped to 1, sending only 1
document to the reranker instead of falling back to the 4× topK auto
default. Add the empty-string check to the guard.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
…#4433)

* fix(mothership): catch draft restore errors instead of crashing /home

Wrap the mount-time draft restore in try/catch with clearDraft on
throw, and coerce text to a string in the useState initializer.
A corrupt entry in mothership-drafts:v1 localStorage previously took
down the entire workspace via the error boundary.

* fix(mothership): defer state writes and log restore failures

Build the restored state in locals first and only apply on success
so a partial throw can't leave stale contexts in the UI with the
draft already cleared. Switch the empty catch to logger.error so
corrupt-draft incidents surface in production logs.
… and self-heal stale log panel entries (#4424)

* fix(mothership): stop persisting log resources from get_workflow_logs and self-heal stale log panel entries

* fix(mothership): skip retries on 404 in useLogDetail for instant self-heal

* fix(mothership): simplify onNotFoundRef sync to inline assignment
…support (#4435)

* feat(mothership): restore attachment previews on draft and add video support

* fix(mothership): icon fallback behind video preview
…messages (#4434)

* fix(copilot): redact sim_key API keys from persisted Mothership chat messages

* improvement(emcn): promote ApiKeyReveal to SecretReveal in emcn

* fix(copilot): thread cursor across content blocks when restoring sim_key tags
* feat(image-generator): add gpt-image-2 model support

* docs
…-safe (#4431)

* fix(logs): split summary/detail contracts to make trace tab gate type-safe

The Trace tab was silently missing from the Log Details sidepanel because
list and detail rows shared one WorkflowLog type with executionData:
z.unknown(). The UI couldn't distinguish a summary row (no spans) from a
detail row (with spans), so the tab gate read undefined and hid itself.

Splits into WorkflowLogSummary (list) and WorkflowLogDetail (typed
executionData with optional traceSpans). Detail and by-execution routes
both write through to the same logKeys.detail(id) cache, eliminating the
two-key fragmentation that caused the merge memo workaround. List route
moves to cursor pagination on (sortValue, id) with proper NULLS LAST
handling and SQL-side sort across workflow + job execution tables.
Detail route now requires and asserts workspaceId. Deep-link path uses
useLogByExecutionId instead of auto-paginating the entire workspace.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(logs): audit follow-ups — render side-effect, stats invalidation, enhanced spread order

- Move onActiveTabChange call from render into useEffect to avoid
  side-effects during render (StrictMode safety).
- Re-add logKeys.stats() invalidation to cancel/retry mutations so
  the dashboard reflects status flips immediately.
- Reorder enhanced: true after ...execData spread in detail and
  by-execution routes so the literal discriminator is never
  overwritten by stale execData.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(logs): mirror SQL NULLS LAST in JS merge for cursor consistency

The in-memory merge of workflow + job pages negated the comparator
for DESC, which placed null sort values at the start. SQL orders
both ASC and DESC with NULLS LAST, so DESC pages emitted a cursor
{v: <last non-null>, id: ...} while null rows still satisfied the
cursor predicate (OR sort_expr IS NULL) on the next page —
producing duplicate null rows across pages on cost/duration sorts.

Handle nulls explicitly in the JS comparator so they always sort
last regardless of direction, matching the SQL ordering.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(logs): final-audit follow-ups — stable tab callback, byExecution invalidation, optimistic detail patch, trace loading state

- Wrap LogDetails -> LogDetailsContent onActiveTabChange in useCallback
  so the child useEffect doesn't refire on every parent render.
- Add logKeys.byExecutionAll() to cancel + retry invalidation so the
  table-embedded sidebar picks up status changes immediately.
- Optimistic write-through to logKeys.detail in useCancelExecution so
  the open sidebar reflects 'cancelling' instantly; rolls back on error.
- Distinguish trace loading from trace-empty: when log.executionData is
  not yet fetched, render "Loading trace…" instead of the empty state.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(logs): migrate stores/components to contract types

Replace the legacy `WorkflowLog` / `LogsResponse` / `WorkflowData` /
`CostMetadata` / `ToolCallMetadata` shapes in
`stores/logs/filters/types.ts` with direct use of the contract types
`WorkflowLogSummary`, `WorkflowLogDetail`, and a new `WorkflowLogRow`
alias for surfaces that render either form. Removes the
`summaryToWorkflowLog` / `detailToWorkflowLog` bridge in the React
Query layer along with their double-cast annotations.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* refactor(logs): address PR review feedback

- Whitelist sort columns against logSortBy enum to prevent client crash
  when non-sortable headers (workflow, trigger) reach the contract parser.
- Extract fetchLogDetail helper shared by /api/logs/[id] and
  /api/logs/by-execution/[executionId] — collapses ~360 duplicated lines
  to a single source of truth keyed on lookup column.

* fix(logs): exclude job logs when level filter is workflow-only

When level=running or level=pending (workflow-only states involving
endedAt/pausedExecutions semantics), jobLevelConditions stayed empty
so no level constraint reached jobConditions — every job log in the
workspace leaked into the result. Skip the job side entirely when the
level filter has no job-applicable values (error/info).

* chore(logs): drop dead utils — mapToExecutionLog and friends

Remove ExecutionLog/RawLogResponse/ExecutionCost/LogWithExecutionData/
TraceSpan/BlockExecution interfaces and the mapToExecutionLog,
mapToExecutionLogAlt, extractOutput functions — all unreferenced after
the contract split. -212 lines.

* chore(logs): drop unused LOG_COLUMN_ORDER and LogColumnKey

* fix(logs): hydrate filters from URL synchronously on mount

The previous useEffect-based initializeFromURL caused useLogsList and
useDashboardStats to fire once with default store filters, then refetch
after the effect updated filters from the URL. Move the initial hydrate
into a useState lazy initializer so the first render already reads
URL-derived filters; the popstate handler keeps the existing effect for
back/forward navigation.

* chore(logs): trim verbose comments added during PR

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(logs): guard navigation arrows when selected log is off-page

Deep-linked logs resolved via useLogByExecutionId may not be in the
current page list, leaving selectedLogIndex at -1. The hasNext prop
was evaluating -1 < logs.length - 1 (true for any non-empty list),
which enabled the next arrow and jumped to the first item on click.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(logs): sync active-tab callback before paint to keep keyboard guards aligned

Run the resolvedTab → onActiveTabChange propagation in useLayoutEffect
so the parent's activeTabRef updates synchronously before the next
paint. This closes the brief window where window keydown handlers
in the logs page would still see activeTabRef.current === 'trace'
and short-circuit arrow-key navigation immediately after switching
to a log without a Trace tab.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
* v0.6.29: login improvements, posthog telemetry (#4026)

* feat(posthog): Add tracking on mothership abort (#4023)

Co-authored-by: Theodore Li <theo@sim.ai>

* fix(login): fix captcha headers for manual login  (#4025)

* fix(signup): fix turnstile key loading

* fix(login): fix captcha header passing

* Catch user already exists, remove login form captcha

* fix double wrap reponse of guest session handler

* remove dead code, and fix test

---------

Co-authored-by: Waleed <walif6@gmail.com>
Co-authored-by: Theodore Li <theodoreqili@gmail.com>
Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com>
Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com>
Co-authored-by: Theodore Li <theo@sim.ai>
* improvement(mothership): improve streaming state transitions

* address comments
…#4442)

* feat(logs): add Logs block for querying execution logs from workflows

* fix(logs): guard transformResponse on non-2xx and correct executionMetadata description

- Add response.ok check in all three logs tools' transformResponse so a
  4xx/5xx body cannot be silently treated as a success payload (defense
  in depth; the executor already throws on non-2xx before transform runs).
- Drop totalTokens from executionMetadata description in block and tool
  outputs since the snapshot route does not emit it.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 5, 2026 3:56am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 5, 2026

PR Summary

Medium Risk
Medium risk: changes touch auth/session responses, log listing/detail APIs (new pagination + sorting), and vector search reranking inputs, which can affect data access patterns and UI behavior. Most changes are additive/contract-driven but could introduce subtle regressions in pagination ordering, auth envelopes, or search cost/behavior.

Overview
Adds new capabilities across docs, APIs, and Mothership UX, including GPT Image 2 support, Table trigger docs, and expanded tool documentation for Knowledge/Mem0.

On the backend, introduces a cursor-based, multi-sort logs listing in GET /api/logs, refactors GET /api/logs/[id] onto shared contracts + fetchLogDetail, and adds GET /api/logs/by-execution/[executionId]; also updates logs auth to support checkSessionOrInternalAuth. Knowledge search now exposes reranker input sizing (rerankerInputCount) and optional BYOK reranker API key passthrough, with guardrails/cost-bounding.

In Mothership/Copilot, improves streaming state propagation by including streamId in task status events and stop notifications, returns chatId in stream batch resume responses, hardens draft restore (prevents crashes and restores attachment previews), adds video attachment previews, and supports redacted credential display via SecretReveal. Table row APIs now return 400 for malformed sort/filter SQL validation errors instead of generic 500s.

Reviewed by Cursor Bugbot for commit 51addc5. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

  • Introduces a Logs block and three log tools (logs_query, logs_get, logs_get_execution), a sim_key redaction layer for Mothership chat (write-side server redaction + read-side page-session key cache), and GPT Image 2 support with per-model size/quality/background validation.
  • Fixes wall-clock duration for loop iterations containing concurrent parallel branches by switching from sum(durationMs) to max(endedAt) − min(startedAt), backed by comprehensive new tests. Also strips childTraceSpans from the block output passed to LLM tool-call state.
  • Addresses several correctness bugs: double-wrapped anonymous session response, 500→400 for malformed table filter/sort input, draft restore crash, and cross-table cursor logic in the log list route.

Confidence Score: 5/5

Safe to merge — no P0 or P1 issues found across 81 changed files.

All fixes are well-scoped and tested: wall-clock duration has regression tests, redaction has unit tests, anonymous session fix is confirmed by updated route tests, and error-status mapping follows established patterns. No identified correctness or security defects.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/chat/sim-key-redaction.ts New module: two-sided sim_key redaction — server-side strip before DB persist, client-side page-session cache for live key re-injection. Well-tested and handles multi-block streaming merge.
apps/sim/executor/execution/block-executor.ts Strips childTraceSpans from block output before setBlockOutput and return value; error path now reads spans directly from ChildWorkflowError. Both paths are consistent.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/utils.ts Wall-clock fix: subflow and iteration durations now use max(endedAt)−min(startedAt) instead of sum(durationMs), preventing inflation for concurrent parallel branches. Tests added.
apps/sim/blocks/blocks/image_generator.ts Adds gpt-image-2 model with per-model size/quality/background ALLOWED_ maps for safe param validation; follows existing duplicate-id conditional subblock pattern for shared quality/size fields.
apps/sim/lib/table/sql.ts Introduces TableQueryValidationError class; all validation throws upgraded so routes can map caller errors to 400 while preserving 500 for programmer errors.
apps/sim/lib/logs/fetch-log-detail.ts New shared loader for the log-detail shape used by both by-id and by-execution routes; correctly enforces workspace scoping and permission JOIN.
apps/sim/blocks/blocks/logs.ts New Logs block wiring query/get_log/get_execution operations to their respective tools; param mapping and validation look complete.
apps/sim/tools/logs/query.ts New logs_query tool; correctly reads workspaceId from execution context and builds query string. Handles empty/falsy limit and null nextCursor.
apps/sim/lib/copilot/chat/persisted-message.ts Wires sim-key redaction into message persistence: redactSensitiveContent on content, redactToolCallResult on tool results, mergeAndRedactPersistedBlocks on content blocks.

Sequence Diagram

sequenceDiagram
    participant C as Client (useChat)
    participant S as /api/copilot/chat/stream
    participant P as buildPersistedAssistantMessage
    participant DB as Postgres
    participant R as restoreRevealedSimKeysForMessage

    C->>S: SSE stream
    S-->>C: token chunks (incl. credential tags)
    Note over C: captureRevealedSimKeys()<br/>stores live key in revealedSimKeysRef
    S->>P: assemble persisted message
    P->>P: redactSensitiveContent()<br/>mergeAndRedactPersistedBlocks()
    P->>DB: persist (key → REDACTED)
    C->>DB: refetch after stream ends
    DB-->>C: message with redacted tags
    C->>R: restoreRevealedSimKeysForMessage(msg, cache)
    R-->>C: message with live key re-injected (in-memory only)
Loading

Reviews (2): Last reviewed commit: "fix(terminal): use wall-clock duration f..." | Re-trigger Greptile

Comment thread apps/sim/tools/logs/get_execution.ts
Comment thread apps/sim/tools/logs/get_execution.ts
Comment thread apps/sim/app/api/logs/route.ts
@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

Reviewed by Cursor Bugbot for commit 51addc5. Configure here.

…op select-all viewport jump (#4445)

* fix(tables): suppress phantom rows on sort, center gutter numbers, stop select-all viewport jump

* fix(tables): suppress scroll on Ctrl+A select-all

Cmd/Ctrl+A duplicates the select-all logic but missed the
suppressFocusScrollRef flag, so the keyboard path still triggered
the viewport jump.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@waleedlatif1 waleedlatif1 merged commit 4253e57 into main May 5, 2026
30 checks passed
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.

4 participants