Skip to content

feat: v2 - ai assistant web worker scaffolding#2328

Open
maxy-shpfy wants to merge 1 commit into
05-26-feat_v2_-_ai_assistant_chat_windowfrom
05-26-feat_v2_-_ai_assistant_web_worker_scaffolding
Open

feat: v2 - ai assistant web worker scaffolding#2328
maxy-shpfy wants to merge 1 commit into
05-26-feat_v2_-_ai_assistant_chat_windowfrom
05-26-feat_v2_-_ai_assistant_web_worker_scaffolding

Conversation

@maxy-shpfy
Copy link
Copy Markdown
Collaborator

@maxy-shpfy maxy-shpfy commented May 28, 2026

Description

Introduces the Web Worker infrastructure for the in-browser AI agent. A dedicated worker (src/agent/worker.ts) is spawned lazily on the first chat turn and communicates with the main thread over Comlink. The worker currently returns an echo response, establishing that the bundling, lazy-spawn, and Comlink round-trip work end-to-end before the LLM and tool bridge are wired in.

AgentClient (agentClient.ts) manages the worker lifecycle — spawning, wrapping with Comlink, calling init once, and exposing a typed ask() method. AiChatStore is updated to call AgentClient.ask() instead of the previous hardcoded echo, and now threads threadId and live thinkingText status updates through from the worker response.

The worker bundle is configured to emit ES module output so import.meta.url resolves correctly inside the worker. A globalThis.process polyfill is inlined in the worker entry point to handle an unguarded process.env read in @openai/agents-core v0.4.x without falsely advertising a Node.js environment.

An ARCHITECTURE.md is added under src/agent/ documenting the full topology: thread split, Comlink bridge contract, dispatcher/sub-agent structure, tool registry, session and memory model, observability hooks, skills loader, configuration knobs, and known caveats.

Related Issue and Pull requests

Type of Change

  • Bug fix
  • New feature
  • Improvement
  • Cleanup/Refactor
  • Breaking change
  • Documentation update

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

AI Assistant - WebWorker.mov (uploaded via Graphite)

Test Instructions

  1. Open the v2 editor and expand the AI Chat panel.
  2. Send any message. The assistant reply should read Worker echo: <your message>.
  3. Confirm a threadId is assigned and persists across subsequent messages in the same session.
  4. Confirm the thinking status text updates while the worker is processing.
  5. Reload the page and confirm a new worker is spawned cleanly on the next message.

Additional Comments

The comlink package is added as a production dependency. The @openai/agents-core/_shims Vite alias and the SDK dependency itself are deferred to the next PR, which wires the actual LLM round-trip and tool bridge.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

🎩 Preview

A preview build has been created at: 05-26-feat_v2_-_ai_assistant_web_worker_scaffolding/3a918bd

Copy link
Copy Markdown
Collaborator Author

maxy-shpfy commented May 28, 2026

@maxy-shpfy maxy-shpfy force-pushed the 05-26-feat_v2_-_ai_assistant_chat_window branch from 13d4bc7 to 8dfdf7a Compare May 28, 2026 05:42
@maxy-shpfy maxy-shpfy force-pushed the 05-26-feat_v2_-_ai_assistant_web_worker_scaffolding branch from 3209a15 to 3a918bd Compare May 28, 2026 05:42
@maxy-shpfy maxy-shpfy marked this pull request as ready for review May 28, 2026 05:48
@maxy-shpfy maxy-shpfy requested a review from a team as a code owner May 28, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant