Waleed d1b01849a8 improvement(perf): cut server-only and unused code out of the workspace client bundles (#6975)
* improvement(perf): cut server-only and unused code out of the workspace client bundles

Every workspace route shipped JavaScript it never executes. Four independent
import edges, each fixed by moving a symbol rather than changing behaviour:

- js-tiktoken's BPE rank tables (5.4 MB source / 2.5 MB wire) reached the
  workflow editor because the tokenization barrel re-exported the exact
  counters alongside the character heuristics. Split into
  lib/tokenization/accurate.ts, which the barrel no longer re-exports.
- crypto-browserify (~105 KB gzip, all 26 workspace routes) came from the
  Salesforce and Gong triggers importing webhook provider modules that reach
  node:crypto through @sim/security. The two symbols they actually needed are
  now in crypto-free modules.
- tables, files and knowledge each imported one dependency-free hook from the
  sidebar-hooks barrel, whose other exports reach the 5 MB generated
  tool-metadata artifact. Deep-imported per the code-splitting rule in
  sim-imports.md.
- lib/workflows/subblocks/display.ts imported a string constant from a React
  module under app/, inverting the app/lib layering. Moved to lib/.

Also adds a loading boundary to chat/[chatId]. Without one, a dynamic route is
prefetched as nothing, so clicking a chat held the previous chat on screen for
the whole server round trip.

Measured on a production build, JS downloaded before the load event:

  /w/[workflowId]  7.38 MB -> 4.80 MB  (-35%)
  /logs            4.57 MB -> 4.44 MB
  /knowledge       4.35 MB -> 4.22 MB
  /home            4.57 MB -> 4.44 MB

crypto-browserify no longer appears in any shipped chunk. The tool-registry
boundary baseline is retightened so the reclaimed graph weight cannot silently
regress.

* improvement(sidebar): move useContextMenu to shared hooks

Review flagged the four workspace routes deep-importing `useContextMenu` from
the sidebar's hooks barrel as a barrel-convention violation. Fair — the
code-splitting exception in sim-imports.md is written for `lazy()` splits, and
these are static imports.

The hook was in the wrong place to begin with. It is entirely generic — no
sidebar-specific references, just right-click state and positioning — and nine
consumers across tables, files, knowledge, home, the terminal and the preview
editor already reached across features to get it. Moved to `@/hooks`, the
repo's shared-hooks location, and every consumer including the sidebar's own
now imports it from there.

This satisfies the barrel convention rather than making an exception to it, and
keeps the graph win: tables, knowledge and files stay off the sidebar barrel's
path to `stores/workflow-diff -> serializer -> tools/metadata`, unchanged at
20.19 / 20.89 / 21.37 MB of reachable source.
2026-08-21 21:14:00 -07:00
2026-08-21 12:59:08 -07:00

Sim.ai Documentation Slack X

Ask DeepWiki Set Up with Cursor

Sim — Integrate, Context, Build, and Monitor AI agents

A workspace to build, deploy and manage AI agents and workflows.

Quickstart

Cloud-hosted: sim.ai

Open sim.ai

Self-hosted

npx sim-setup

Open http://localhost:3000

The Sim platform — chat on the left, the visual workflow builder on the right

Capabilities

  • Connect 1,000+ integrations and every major LLM
  • Add Slack, Notion, HubSpot, Salesforce, databases, and more
  • Build agents visually, conversationally, or with code
  • Ingest files, knowledge bases, and structured table data
  • Monitor runs, logs, schedules, and workflow activity

One workspace, every surface

Chat and workflows are just the start — tables, files, and knowledge all live in the same workspace.

Tables in Sim — structured data your agents can query

Tables — a database, built in

Files in Sim — documents for your team and every agent

Files — one store for your team and every agent

Knowledge bases in Sim — synced docs your agents can search

Knowledge — your agents' memory

Self-hosting

Requirements: Node.js 20+ and Docker.

npx sim-setup is an interactive wizard that creates a small sim/ deployment directory, provisions the database, generates secrets, writes .env, connects a Chat API key, and starts the published Sim images with Docker Compose. It does not clone the repository.

When it finishes, open http://localhost:3000.

Inside a cloned Sim repository, run bun run sim-setup to unlock the source-only local development and Kubernetes modes.

Reconfigure an optional capability without rerunning the full wizard:

npx sim-setup config
npx sim-setup add email
npx sim-setup add storage
npx sim-setup add sandbox
npx sim-setup add jobs
npx sim-setup add cache
npx sim-setup add knowledge
npx sim-setup add llm
npx sim-setup add integration slack

npx sim-setup config detects the effective local-dev, Docker Compose, or current-context Helm configuration and reports configured, missing, or invalid capabilities and OAuth integrations without printing credential values. This is separate from npx sim-setup status, which reports whether installed services are running and healthy.

Manage your install from its directory:

npx sim-setup start | stop | restart   # bring your install up / down / cycle
npx sim-setup update                   # pull and apply Compose images
npx sim-setup status                   # what's installed and healthy
npx sim-setup logs                     # follow logs
npx sim-setup doctor                   # diagnose configuration problems
npx sim-setup down                     # remove containers (data kept)
npx sim-setup reset                    # archive .env and wipe managed data

The setup package detects how you're running and acts accordingly. Use --dir <path> to create or manage a deployment somewhere other than ./sim.

Sim also supports local models via Ollama and vLLM. See the self-hosting docs for details.

Chat API Keys

Chat is a Sim-managed service. npx sim-setup connects a Chat API key for you — sign in when it opens your browser and the key is stored automatically. To view, create, or revoke keys later, go to sim.ai/selfhost/settings/chat-keys.

Environment Variables

See the environment variables reference for the full list, or apps/sim/.env.example for defaults.

Tech Stack

Next.js · Bun · PostgreSQL · Drizzle · Better Auth · Tailwind — and the rest of the stack

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Built by the Sim team in San Francisco

Languages
TypeScript 77%
MDX 20.8%
JavaScript 1.9%
CSS 0.1%