Introducing a new way to review your PRs.

Read the announcement

debpalash / voicestudio

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / desktop-agent-browser

Desktop agent and browser workspace

The desktop workspace joins two user-facing capabilities: an embedded web view for site interaction and a chat surface for local agents that operate VoiceStudio. Electron keeps the sensitive work in the main process, while the renderer presents state, sends approved requests, and preserves the user’s active workspace. This page complements Electron desktop, Electron workspaces, desktop automation workflows, and LLM and agent services.

Workspace purpose

The workspace gives an engineer one mental model for two related flows. A user can open a site without leaving the app, while an agent can inspect or change app state through a short-lived capability. The browser view does not receive the agent’s credentials or Electron APIs. The agent run does not receive the browser’s private session.

Agent workspace modes

The agent workspace can target the app or an attached source checkout. App mode is for normal product work such as setup, audio generation, repair, and workflow actions. Source mode is for diagnosis or code changes inside a validated VoiceStudio checkout. The selected features add task context, but they do not grant extra permission.

The renderer sends one request with the agent harness, mode, workspace, selected features, bounded chat history, the user report, and current renderer context. The main process validates that request before it starts a run. If no source checkout is attached, an action request can still use the app workspace; source work requires a writable checkout.

References: electron/…/agent-workspace.ts• L1-79 electron/…/index.d.ts• L249-257 electron/…/voice-studio-agent.tsx• L69-190

Embedded site browser

The site browser presents an HTTP or HTTPS page inside the current Electron window. It is a separate native web view with an isolated temporary session. This lets the user move between a site and the app without replacing the app window or sharing site storage with the app.

The browser accepts a URL, navigation commands, measured bounds, and an external-browser choice. It reports the current URL, title, loading state, history controls, and load errors. The renderer uses this state to show the address bar, navigation controls, failure notice, and return-to-Studio action.

References: electron/…/site-browser.ts• L1-40 electron/…/site-browser.ts• L72-199 electron/…/site-browser-page.tsx• L141-265

Main-process bridges

Electron acts as the trust boundary between the renderer, remote site content, local agent processes, and the Python backend. The preload layer exposes narrow typed surfaces. The main process checks the sender and controls the lifetime of each capability before it forwards work. Agent child processes receive a separate environment without Electron’s backend-only bridge values, so a local harness cannot reuse those values outside the intended path.

Browser IPC contract

The browser contract has two kinds of messages. Renderer calls request actions such as open, close, navigate, command, bounds, installed-browser lookup, and external launch. Main-process events publish browser state changes, including a final null value when the view closes. A state read at startup fills the gap if an event arrives before the renderer subscribes.

The main process accepts browser requests only from the trusted top-level app frame. Remote pages and subframes cannot call the browser channels. URL validation allows only HTTP and HTTPS sites and rejects credentials and app, file, data, or script schemes.

References: electron/…/index.ts• L13-31 electron/…/site-browser.ts• L24-47 electron/…/site-browser.ts• L13-39

Agent app capability

Each app-mode or source-mode run receives a session-scoped API bridge. The bridge gives the agent access to the attached backend through a temporary loopback address and capability token. Electron keeps the real backend URL and authentication headers in the main process. The bridge blocks authentication routes and limits diagnose mode to read requests.

The same bridge exposes a small set of Electron recovery actions. These actions let an agent inspect status, restart the backend, or request runtime setup when the Python backend is unavailable. The bridge closes and removes its temporary context when the run stops or finishes, so a later process cannot reuse the capability.

References: electron/…/repair-api-bridge.ts• L69-80 electron/…/repair-api-bridge.ts• L88-170 electron/…/repair-api-bridge.ts• L214-337 electron/…/repair-agents.ts• L872-913

LLM completion bridge

The LLM bridge lets backend text-completion code reuse the agent harnesses already managed by Electron. It listens only on loopback, requires a private bearer token, rejects browser-origin requests, and accepts only bounded completion data. Requests run one at a time through the same translation runner, with a queue limit and a request deadline.

Electron starts this bridge while agent registration is active. It publishes the temporary URL, token, and list of discovered harnesses to the backend process, then removes them during shutdown. Agent child processes do not inherit these backend-only values. The backend uses this route for text completion; it does not launch arbitrary commands or carry the bridge capability into agent subprocesses.

References: electron/…/llm-agent-bridge.ts• L5-33 electron/…/llm-agent-bridge.ts• L36-161 electron/…/repair-agents.ts• L85-99 electron/…/repair-agents.ts• L1122-1157 backend/…/llm_cli.py• L11-42

Translation agent bridge

The desktop also uses the discovered agent harnesses for dubbing translation and timing-fit work. It validates segment identity, text size, timing, and output completeness before returning translated text to the app. This path is separate from browser control, but it shares the single-agent busy guard and the process cleanup rules with repair runs and LLM completion.

Translation runs use restricted prompts and tool access. They can stream short progress messages to the renderer, stop during launch or execution, and classify provider failures without exposing raw provider output. A successful run must return one non-empty result for every supplied segment in the original order.

References: electron/…/index.d.ts• L258-280 electron/…/repair-agents.ts• L385-459 electron/…/repair-agents.ts• L970-1116

Agent run lifecycle

An agent run has one owner and one capability set. The main process discovers installed harnesses, rejects a second active run, starts the selected harness, streams output to the renderer, and closes the bridge when the process ends. The renderer uses the session ID to attach output and state changes to the correct conversation turn.

Run sequence

The following sequence shows how a renderer request becomes a bounded agent session and returns status to the chat workspace.

sequenceDiagram
    participant R as Renderer agent workspace
    participant M as Electron main process
    participant B as Session API bridge
    participant A as Local agent harness
    participant P as Python backend

    R->>M: repair:start(request)
    M->>M: Validate request and choose app or source workspace
    M->>B: Start temporary capability
    M->>A: Start selected harness with scoped context
    A->>B: Read app state or request an approved operation
    B->>P: Forward allowed backend request
    P-->>B: Return app result
    A-->>M: Stream output and exit status
    M-->>R: repair:event(output or state)
    M->>B: Close capability and remove context

References: electron/…/repair-agents.ts• L824-956 electron/…/repair-agents.ts• L958-967 electron/…/voice-studio-agent.tsx• L168-218

Completion and stop states

The renderer sees a run as idle, running, complete, failed, or stopped. A stop request terminates the harness when present, marks the session stopped, emits the state event, and closes the app bridge. A process exit also closes temporary prompt and bridge files before it publishes the final state.

The LLM completion path shares the agent runner with translation work. If another agent operation is active, the completion request receives a retryable busy result. Requests that wait too long expire without starting, while a closing bridge rejects new work. Provider, authentication, and model errors become safe status responses rather than raw subprocess output.

References: electron/…/index.d.ts• L241-295 electron/…/repair-agents.ts• L823-967 electron/…/llm-agent-bridge.ts• L81-143

Renderer workspace

The renderer keeps the conversation and embedded browser visible without losing the user’s app work. It treats main-process state as authoritative, but it keeps local draft and focus state so a temporary browser session does not destroy unfinished input.

Agent dock

The agent dock lists available harnesses and lets the user choose diagnose or fix mode. It supports feature hints, optional source checkout selection, bounded conversation history, streaming output, and a stop control. A new chat is disabled during a run so one conversation cannot silently detach from its active session.

The dock also starts app-directed requests from feature presets. It sends the current route and recent frontend logs as context, while the main process adds backend diagnostics and recent main-process errors. This separates context for the task from authority to perform the task.

References: electron/…/voice-studio-agent.tsx• L100-190 electron/…/voice-studio-agent.tsx• L273-510 electron/…/repair-agents.ts• L658-739

Browser presentation

The browser host keeps the normal workspace mounted while the browser is open. It marks that workspace inert and hides it from assistive technology, then mounts the browser page over the measured content area. When the browser closes, the host restores focus to the element that opened it.

The browser page measures its modal body and sends those bounds to the main process. The native web view therefore follows workspace layout, window resize, scrolling, and renderer zoom. The page owns browser controls, while the native web view owns the remote site content.

References: electron/…/site-browser-host.tsx• L5-53 electron/…/site-browser-page.tsx• L47-100 electron/…/site-browser.ts• L49-63

Browser session lifecycle

Opening the browser creates one reusable view for the main window. A later open request navigates that view instead of creating another one. Closing it removes the view, clears its temporary storage and cache, removes window listeners, and publishes null so the renderer can restore the app workspace.

The browser also closes when the user presses Escape while the remote page has focus or when the parent window closes. Navigation failures remain visible as browser state, so the user can reload, change the address, or open the current URL in an external browser.

References: electron/…/site-browser.ts• L72-199 electron/…/site-browser.ts• L201-243 electron/…/site-browser-page.tsx• L102-160

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the browser channel names, preload methods, shared state shape, and renderer event subscription aligned. A mismatch can leave the native view open while the renderer shows no browser.
  • Keep URL validation in the shared contract and main-process navigation checks aligned. A new allowed scheme must also be reviewed for external launch and popup behavior.
  • Keep agent workspace selection, prompt rules, and API bridge permissions aligned. App mode must not become an accidental source-edit path.
  • Keep run cleanup paired with every new capability, temporary file, environment value, and child process. A stale token or bridge can outlive the visible chat session.
  • Keep the LLM bridge request limits, queue behavior, and backend transport expectations aligned. The backend must continue to require loopback HTTP and the private bearer token.
  • Keep backend-only bridge environment values out of every agent child process. Discovery probes and translation or repair runs must use the same scrubbed child environment.
  • Keep the shared busy guard aligned across repair, translation, and completion entry points. A new entry point must not allow overlapping local harness processes.
  • Keep browser bounds updates tied to the renderer’s measured viewport. Layout or zoom changes can otherwise place the native view outside the visible workspace.

Important failure modes

TriggerConsequenceGuard
A remote page or subframe invokes browser IPCThe request is rejected and the page cannot control the app browserMain-process sender and trusted-frame checks
A user enters a non-web URL or a URL with credentialsNavigation does not start and the renderer shows a failure stateShared HTTP/HTTPS URL validation
An agent completion request lacks the private token or includes an Origin headerThe completion is forbiddenLoopback bridge token check and origin rejection
A completion request exceeds the queue or its deadlineThe request is rejected or expires without startingBounded request body, queue count, and deadline checks
A local agent child inherits Electron’s backend-only bridge valuesA third-party harness could reuse a capability outside its intended boundaryScrubbed child environment for probes and agent runs
A second agent run starts while another run is preparing or activeThe request is reported as busySingle-run guard across repair, translation, and completion
A run stops or its harness exitsThe agent loses backend access and temporary context files are removedSession-scoped bridge cleanup
The backend is unavailable during an app operationThe agent cannot complete the operation until status, restart, or setup recovery succeedsElectron recovery controls and explicit state polling

Key files

FileWhy to read it
electron/…/site-browser.tsMain-process browser lifecycle, native view ownership, navigation policy, and state events
electron/…/site-browser.tsBrowser state and preload contract plus URL rules
electron/…/site-browser-host.tsxWorkspace preservation, inert behavior, and focus return
electron/…/site-browser-page.tsxBrowser controls, viewport measurement, and user-facing failure state
electron/…/repair-agents.tsAgent discovery, run lifecycle, streaming state, app/source selection, translation, and LLM bridge setup
electron/…/repair-api-bridge.tsSession-scoped backend capability and recovery boundary
electron/…/llm-agent-bridge.tsLocal completion protocol, limits, serialization, and safe error mapping
electron/…/agent-workspace.tsAgent feature context and workspace validation rules
electron/…/voice-studio-agent.tsxRenderer agent dock and conversation behavior
electron/…/index.ts and electron/…/index.d.tsThe typed bridge between renderer calls, main-process handlers, and shared state