Skip to content

feat: tangent - remote agent for runview and editor - #2728

Open
maxy-shpfy wants to merge 1 commit into
09-16-refactor_tangent_-_structured_workarea_targetfrom
09-16-feat_tangent_-_remote_agent_for_runview_and_editor
Open

maxy-shpfy wants to merge 1 commit into
09-16-refactor_tangent_-_structured_workarea_targetfrom
09-16-feat_tangent_-_remote_agent_for_runview_and_editor

Conversation

@maxy-shpfy

@maxy-shpfy maxy-shpfy commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Description

Introduces the remote sub-agent runtime for Tangent, enabling Prime to spawn editor and run-inspector agents directly into embedded pipeline and run-view tabs. Each spawned agent runs in a dedicated Web Worker (remoteEnvWorker.ts) backed by createRemoteEnvWorkerApi, which hosts multiple isolated MemorySession instances and serializes turns per agent. The agent worker is wired to the tab's live ToolBridgeApi via Comlink, so CSOM mutations are undoable canvas edits visible in real time.

Key additions:

  • remoteEditorAgent — a flat (non-routing) agent that receives a resolved CSOM tool allowlist and system prompt from Prime, selects the permitted tools from a mode-aware registry (full mutating surface for editor, read-only inspect surface for runView), and appends a tool-availability section and optional task-specific instructions to its base prompt.
  • createRemoteEnvWorkerApi — the worker-side API: init, setAiConfig, setContext, spawnAgent, runTurn, abortAgent, killAgent. Turns are serialized per agent; overlapping turns for the same agent are rejected. Respawn correctly isolates old abort controllers from new ones.
  • remoteEnvHost — upgraded from a pure tool-catalog host to a full spawn/message/kill orchestrator. Turns are chained per agentId, kill/disconnect abort in-flight turns without surfacing them as errors, and lifecycle events (start, activity, end, error) are streamed back to Prime via agentEvent.
  • connectRemoteEnvWithRefresh — extracted token-refresh loop with exponential back-off on failure, onConnected callback fired only after the socket resolves, and a stop function for clean teardown.
  • TangentRemoteEnvProvider — shared transport component for any spawnable tab: boots the worker, connects with token refresh, pushes AI config and context changes into the worker without rebuilding the connection.
  • TangentEditorAgentProvider / TangentRunAgentProvider — thin wrappers that build the appropriate ToolBridgeApi (editor with live CSOM mutations, run view with read-only fetches) and hand it to TangentRemoteEnvProvider.
  • EmbeddedPipelineEditor and EmbeddedRunView — extended with sessionId, environmentId, and environment/bridge lifecycle callbacks so the workarea shell can wire each tab into the project-level environment registry.
  • TangentProjectContext — adds per-tab environment and bridge registries (registerTabEnvironment, waitForTabEnvironment, registerTabBridge, getActiveTabBridge) backed by refs so the routing bridge and workarea tools can read live state outside React's render cycle.
  • createActiveTabRoutingBridge — a ToolBridgeApi that forwards every call to whichever pipeline tab is currently active, giving the project-level editor agent a stable target as the user switches tabs.
  • createWorkareaRemoteTools — extended with run-inspect tools (get_run_status, debug_pipeline_run, get_execution_details, get_execution_state, get_container_state, get_container_log) backed by a project-level backend bridge, and open_workarea_target now waits for the tab's environment to connect before returning so Prime receives the environmentId it needs to spawn into that tab.
  • useLazyBridgeAuth — extracted hook providing stable lazy getters for backend URL and auth token, used by both the editor and run-view bridge builders.
  • System prompts for the remote editor (remoteEditor.md) and run inspector (remoteRun.md) agents.
  • The tangent-shell feature flag now also enables the AI settings sidebar item.
  • validatePipeline is now individually exported from createCsomTools alongside allTools.

Screenshots (if applicable)

Test Instructions

  1. Open a Tangent session with the tangent-shell flag enabled.
  2. Open a pipeline tab in the Dynamic Workarea and confirm the tab's environment id appears in list_workarea_tabs / open_workarea_target responses.
  3. Have Prime spawn an editor sub-agent into the pipeline tab's environment; verify CSOM mutations appear on the canvas and are undoable.
  4. Open a run tab and confirm Prime can spawn a run-inspector agent that can call debug_pipeline_run and the fine-grained execution tools without being able to mutate the spec.
  5. Switch active pipeline tabs and confirm the project-level routing bridge re-targets the newly active tab.
  6. Revoke and refresh the AI provider config mid-session and confirm the next turn uses the updated settings without reconnecting.
  7. Kill an in-flight agent turn and confirm no error toast is shown and the agent lifecycle is correctly cleaned up.

Additional Comments

@tangent/remote-subagent has been removed from the knip ignore list as it is now a direct runtime dependency of remoteEnvHost. The remoteEnvWorker.ts entry point has been added to knip so dead-code analysis covers the worker build.

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: 09-16-feat_tangent_-_remote_agent_for_runview_and_editor/593b8ab

maxy-shpfy commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@maxy-shpfy
maxy-shpfy force-pushed the 09-16-feat_tangent_-_remote_agent_for_runview_and_editor branch from 168c361 to 593b8ab Compare September 18, 2026 19:28
@maxy-shpfy
maxy-shpfy marked this pull request as ready for review September 18, 2026 19:34
@maxy-shpfy
maxy-shpfy requested a review from a team as a code owner September 18, 2026 19:34
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.

1 participant