Skip to content

apps desktop console

Claude edited this page Sep 23, 2026 · 2 revisions

Desktop console

Active contributors: ferdiiskandar

Purpose

The desktop console is the MyPrompt Electron application. It presents a terminal-style transcript where the user types an idea and receives a compiled Coding Brief or Super Prompt, watches the response stream in, and runs Transform, Evaluator, library, workspace, benchmark, and billing commands. The shell owns provider keys, the desktop session, and the local workspace store.

Directory layout

desktop/
  bootstrap.ts          entry: module alias shim + userData override
  main.ts               Electron main: env load, window, shell state, telemetry, grid fit
  preload.ts            context-isolated bridge (window.sentraDesktop)
  ipc/                  command routers (core, auth, workspace, library, provider-keys, ...)
  renderer/
    index.html
    renderer.ts         terminal console: parsing, rendering, streaming (~3,400 lines)
    strings.ts          import-free string table

Key abstractions

Abstraction Role Source
bootstrap.ts Rewrites @/ imports to dist-electron, sets userData before main.ts loads desktop/bootstrap.ts
main.ts Reads env, builds shell state and badges, sizes the frameless window, serves system:stats desktop/main.ts
preload.ts Exposes window.sentraDesktop with invoke, onStream, offStream, auth and workspace helpers desktop/preload.ts
renderer.ts Parses input, runs commands, renders the transcript, decodes Optimizer streams desktop/renderer/renderer.ts
desktop:command envelope { command, payload, accessToken } handled by registerCoreIpc desktop/ipc/core.ts

How it works

The window is frameless (frame: false). On Windows it is opaque in the console colour so ClearType sub-pixel antialiasing survives; elsewhere it is transparent so the CSS radius and shadow show. The window is sized in character columns and rows, not pixels: the renderer measures one monospace cell and reports it over window:fit-grid; main.ts converts columns × cell width plus padding into content size. The target floor is 80 × 20, applied on every launch, and the grid fit runs once per persisted-state version.

The renderer accepts two input shapes. Bare commands (brief, super, transform, lane, profile, effort, log, key, stat, mode, copy, clear, help, quit) are handled locally or dispatched as engine calls. Slash commands (/evaluate, /library, /draft, /benchmark, /templates, /provider, /usage, /subscription, /auth) map to the DesktopCommandId catalog. Text that is neither is treated as a prompt.

Despatch runs through one path. The renderer builds a DesktopInvocation, calls window.sentraDesktop.invoke('desktop:command', envelope), and the main-process router in core.ts resolves the command. Transform is pure and runs directly. Optimizer and Evaluator check the desktop session: a signed-in user gets tier quota, model access, and a stored provider key; a guest falls back to resolveGuestProvider and the environment key. optimize:run is special: the router starts streamOptimizeCommand in the background and returns { status: 'started', requestId }, then pushes optimize:status, optimize:chunk, optimize:done, and optimize:error events back over the preload bridge.

flowchart LR
  R[renderer.ts input] --> P[preload invoke]
  P --> E[desktop:command router core.ts]
  E -->|transform:run| T[lib/transform/engine.ts]
  E -->|optimize:run| S[streamOptimizeCommand]
  E -->|evaluate:run| V[lib/evaluator/engine.ts]
  S --> C[lib/optimizer/engine.ts]
  C -->|status/chunk/done/error| P
  P --> R
Loading

Integration points

  • Provider registry and readiness drive the model chip and badges in app:get-shell-state; see LLM providers.
  • Workspace drafts, recent runs, and benchmarks live in desktop/ipc/workspace-store.ts; see Workspace and library.
  • Provider keys and subscriptions route through desktop/ipc/provider-keys.ts and desktop/ipc/subscription.ts.

Entry points for modification

Add a command by extending DesktopCommandId and COMMAND_CATALOG in renderer.ts, then handling the id in handleDesktopCommand in core.ts. Add a shell field by widening the app:get-shell-state payload in main.ts and the DesktopShellState type in renderer.ts. Keep strings.ts import-free.

Key source files

File Purpose
desktop/bootstrap.ts Module alias shim and userData override
desktop/main.ts Window, shell state, telemetry, grid fit
desktop/preload.ts Context-isolated bridge
desktop/ipc/core.ts desktop:command router and Optimizer streaming
desktop/renderer/renderer.ts Terminal console
desktop/renderer/strings.ts String table

Clone this wiki locally