Skip to content

feat(plugin-code-server): spawn via ctx.terminals as a read-only hub session#54

Merged
antfu merged 4 commits into
mainfrom
chubby-frogs-fix
Jul 1, 2026
Merged

feat(plugin-code-server): spawn via ctx.terminals as a read-only hub session#54
antfu merged 4 commits into
mainfrom
chubby-frogs-fix

Conversation

@antfubot

@antfubot antfubot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

What & why

When the code-server plugin is mounted in a hub, it now launches code-server through the hub's ctx.terminals instead of spawning a raw child process. The process surfaces in the hub's terminals panel as a read-only session (the hub wires no stdin) with a proper icon (ph:code-duotone) and name (Code Server, described by the workspace folder).

Standalone runtimes (CLI / Vite / build) have no ctx.terminals, so they keep spawning a direct child process exactly as before — the plugin stays hub-agnostic by duck-typing the terminals bridge (same pattern the terminals plugin uses), with no build/runtime dependency on @devframes/hub.

Behavior

  • Hub present: spawn via ctx.terminals.startChildProcess(...); the returned child feeds the unchanged readiness/port/log/exit wiring, so startup, auth handoff and health probing are identical.
  • Lifecycle: the session status is reflected onto the hub (stopped on stop, error on unexpected crash — the hub doesn't update a child-process session on its own exit), and each start removes the stale same-id session before registering a fresh one (every start uses a new port + password).
  • Auth: PASSWORD is neutralized explicitly since the hub merges process.env, keeping HASHED_PASSWORD auto-auth intact.

Tests

Added a faithful fake ctx.terminals (really spawns, merges process.env, exposes getChildProcess/terminate) and two cases: the read-only session's name/icon/description/pid + end-to-end auth through the hub, and stop→stopped→fresh re-register on the next start. tsnapi API snapshots regenerated.

Verified: pnpm test (534 passed), pnpm typecheck, pnpm lint, pnpm build.

This PR was created with the help of an agent.

…session

When mounted in a hub, launch code-server through ctx.terminals so it shows up
in the hub's terminals panel as a read-only session with a proper icon and
name. Reflect stop/exit on that session and re-register a fresh one on the next
start. Standalone runtimes keep spawning a direct child process unchanged.
@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 26815bc
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a44c0d7f2432f00080f5a8c
😎 Deploy Preview https://deploy-preview-54--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

antfubot added 3 commits July 1, 2026 05:11
Show terminal sessions contributed by other devframes through the hub
(ctx.terminals) — such as code-server — in the terminals plugin's own tab.
They render read-only with the contributing tool's icon and name, stream
output from the hub's channel, and refresh as they start/stop. The plugin
offers no rename/restart/kill controls for sessions it doesn't own.
Normalize a hub session's dock icon (ph:code-duotone) to the client's UnoCSS
class (i-ph-code-duotone) and safelist the built-in plugins' icons so those
runtime-supplied glyphs are emitted by the SPA build and actually render.
@antfu antfu merged commit c0f3c80 into main Jul 1, 2026
12 checks passed
@antfu antfu deleted the chubby-frogs-fix branch July 1, 2026 07:35
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.

2 participants