Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Jan 14, 2026

Summary

Pattern match more error types to reduce swallow

Type of Change

  • Bug fix

Testing

Manual

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)

@vercel
Copy link

vercel bot commented Jan 14, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 14, 2026 1:04am

@Sg312 Sg312 changed the base branch from main to staging January 14, 2026 01:04
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 14, 2026

Greptile Summary

This PR improves error handling by using a centralized error extraction system that pattern-matches multiple API error formats, preventing error message swallowing. The main change refactors tools/utils.ts to use extractErrorMessage() which tries parsing errors as JSON first, then falls back to plain text, before matching against 12+ error patterns (GraphQL, Twitter, OAuth, etc.). This ensures better error visibility across different API integrations.

Additionally, the PR includes:

  • Copilot enhancements: Added slash command support (/fast, /plan, /debug, etc.) with UI components for command selection
  • Web scraping tools: Registered three new client tools (scrape_page, get_page_contents, crawl_website)
  • Async improvements: Changed sub-agent tool execution from blocking await to non-blocking Promise.resolve().then() for better concurrency
  • Schedule block UX: Default timezone changed from UTC to user's local timezone using Intl.DateTimeFormat()
  • Performance optimizations: Memoized React components and callbacks in copilot UI

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations around async execution patterns
  • The core error handling improvement is well-designed with proper fallbacks. The copilot features add significant functionality. One concern: the async tool execution change in store.ts (line ~1865-1894) removes await which could lead to race conditions if subsequent code depends on tool completion. The removed auto-allowed tools logic should be verified that it doesn't break existing workflows.
  • Pay close attention to apps/sim/stores/panel/copilot/store.ts for the async execution pattern change and removed auto-allowed tools logic

Important Files Changed

Filename Overview
apps/sim/tools/utils.ts Improved error handling by calling extractErrorMessage with proper error data including plain text responses
apps/sim/blocks/blocks/schedule.ts Changed default timezone from UTC to user's local timezone using Intl.DateTimeFormat()
apps/sim/stores/panel/copilot/store.ts Added slash command support, registered new web scraping tools, and improved async tool execution with non-blocking promises
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx Added slash menu UI component with keyboard navigation and command selection

Sequence Diagram

sequenceDiagram
    participant Client as Client/Agent
    participant Utils as tools/utils.ts
    participant API as External API
    participant Extractor as error-extractors.ts
    
    Client->>Utils: executeRequest(toolId, tool, params)
    Utils->>API: fetch(url, method, headers, body)
    
    alt API responds with error
        API-->>Utils: Response (!ok)
        
        Note over Utils: Try to parse error response
        Utils->>Utils: Try JSON parse
        alt JSON parse succeeds
            Note over Utils: errorData = JSON object
        else JSON parse fails
            Utils->>Utils: Try text parse
            alt Text parse succeeds
                Note over Utils: errorData = plain text string
            else Text parse fails
                Note over Utils: errorData = null
            end
        end
        
        Utils->>Extractor: extractErrorMessage({status, statusText, data})
        
        Note over Extractor: Iterate through error patterns:<br/>1. GraphQL errors<br/>2. Twitter errors<br/>3. Standard message<br/>4. Plain text data<br/>5. HTTP status text
        
        alt Pattern matches
            Extractor-->>Utils: Extracted error message
        else No pattern matches
            Extractor-->>Utils: "Request failed with status {status}"
        end
        
        Utils->>Utils: throw new Error(message)
        Utils-->>Client: ToolResponse { success: false, error }
    else API responds successfully
        API-->>Utils: Response (ok)
        Utils->>Utils: transformResponse(response)
        Utils-->>Client: ToolResponse { success: true, output }
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (2)

  1. apps/sim/stores/panel/copilot/store.ts, line 1226-1240 (link)

    style: removed auto-allowed tools behavior that previously auto-executed certain integration tools

    Verify that workflows using exa_* or google_calendar_* tools still work correctly with the new user confirmation requirement. Was the auto-allowed tools feature intentionally removed, or should some tools still auto-execute without user confirmation?

  2. apps/sim/stores/panel/copilot/store.ts, line 1866-1874 (link)

    style: changed from blocking await to non-blocking Promise.resolve().then() for sub-agent tool execution

    This could cause issues if subsequent code expects the tool to complete before continuing. The promise chain is fire-and-forget, so errors are logged but not propagated. Is this intentional to improve responsiveness, or could this lead to race conditions where UI updates before tools finish?

25 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@Sg312 Sg312 merged commit 3d037c9 into staging Jan 14, 2026
15 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/error-swallow branch January 14, 2026 16:56
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