Skip to content

improve rendering performance & local rendering over ssh - #54

Open
RobPruzan wants to merge 11 commits into
mainfrom
local-rendering-over-ssh
Open

RobPruzan wants to merge 11 commits into
mainfrom
local-rendering-over-ssh

Conversation

@RobPruzan

@RobPruzan RobPruzan commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR uses a new pixel features which allows inside certain terminal environments for terminal-code running over ssh to render locally, allowing for significantly higher FPS

This PR also bumps pixel, which includes significant performance improvements for terminal-code over ssh without local rendering, and inside the rex terminal

This will resolve #19 when herdr releases a passthrough mode for kitty graphics

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tode Ready Ready Preview Nov 24, 2026 3:59am UTC

Request Review

@RobPruzan RobPruzan changed the title local rendering over ssh improve rendering performance & local rendering over ssh Nov 24, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 9 potential issues.

2 security issues not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread src/upgrade.ts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Running listener outlives an upgrade

upgrade replaces the install without restarting the rendering listener. serveLink reads the new version from disk while the listener still runs its old protocol code.

(Refers to this code)

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/tunnel.ts
Comment on lines +86 to +90
prompt.question(question, (answer) => {
prompt.close();
resolve(answer.trim());
});
prompt.on("close", () => resolve(""));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Discarded SSH setup destination

When users enter a destination, ask closes readline before returning their answer. The synchronous close handler resolves with an empty string, so setup exits without connecting.

Suggested change
prompt.question(question, (answer) => {
prompt.close();
resolve(answer.trim());
});
prompt.on("close", () => resolve(""));
prompt.question(question, (answer) => {
resolve(answer.trim());
prompt.close();
});
prompt.on("close", () => resolve(""));

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/launch.ts
Comment on lines +254 to 258
private async openHere(url: string): Promise<number> {
const local = this.options.proxy ? null : await renderLocally(url);
if (typeof local === "number") return local;
const window = attachWindow(local ?? url, this.options);
this.closeWindow = () => window.close();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Stuck setup wizards over SSH

With local rendering active, openHere offloads setup wizards. The streamed proxy blocks navigation to the next stage or editor because it uses another port. Wizard actions that call Pane.close also leave the window open.

Learn more

The import and shortcut wizards run on separate loopback HTTP servers. runOnboarding opens the first wizard in a pane, then returns the next wizard or editor URL to that same window. The import page and shortcuts page navigate to that URL. The streamed window proxies only the initial port, so every transition to another server fails. In the standalone shortcut wizard, runManager calls Pane.close() when the user finishes without navigating, but the offloaded branch never installs a close callback.

Example: Run terminal-code --shortcut-setup over SSH with a working rendering link and resolve a shortcut conflict. Applying the changes and continuing sends the window to the editor's port, which the proxy rejects. Quitting without applying instead leaves the wizard open because the pane cannot close it.

Recommended fix: Keep wizard windows on the existing renderer by making offloading opt-in for editor launches. To offload wizards too, provide a stop callback and explicitly support transitions between approved endpoints.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/screen.ts Outdated
Comment on lines +125 to +126
proxy: `socks5://127.0.0.1:${front.port}`,
partition: partitionFor(target.host),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Closing a second editor breaks the first

Opening two offloaded windows from one server makes streamedWindow assign the second window’s proxy to their shared browser session. Closing the second window shuts down that proxy, so new requests from the first window fail.

Learn more

Each streamed window creates a SOCKS listener tied to its own rendering link and closes that listener when the window exits. The daemon’s WebView passes the proxy and partition to Pixel. Pixel 0.3.3 applies the proxy with Electron’s session.setProxy, so it affects the entire browser session, not just one window. Both windows use the same persistent session when their server host matches. The first window retains no way to restore its original proxy when the second window exits.

Example: Open two projects from the same SSH host in separate terminal panes. Close the second editor, then reload the first. Its browser session tries to connect through the closed SOCKS listener.

Recommended fix: Give each active offloaded window its own browser session, or share one proxy with the same lifetime as the shared session.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/service.ts
Comment on lines +116 to +119
async function stopStray(): Promise<void> {
const state = listenerState();
if (state && state.pid !== process.pid && alive(state.pid)) await kill(state.pid);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Unrelated process termination after PID reuse

After a listener crash and PID reuse, stopStray treats any live process at the saved PID as the listener. kill terminates that process, even when it belongs to another application.

Learn more

The listener records its PID on disk. It removes that record in its signal handlers, which do not run after a hard kill or abrupt shutdown. Later, installService or removeService attempts to stop the recorded process. alive checks only that the PID exists, not that the process is the old listener. kill sends SIGTERM and follows with SIGKILL if the process remains.

Example: The listener is killed and leaves PID 1234 in its state file. After the OS assigns PID 1234 to a user-owned editor, rerunning the enable command terminates that editor instead.

Recommended fix: Use the service manager to stop managed listeners. For a detached listener, verify process identity and a recorded start identifier before signaling it, or use a private control socket rather than a persisted PID.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/remote.ts Outdated
Comment on lines +53 to +60
export function targets(enabled = readSettings().enabled): Target[] {
const found: Target[] = tunnelSockets().map((socketFile) => ({
route: "tunnel" as const,
label: `ssh tunnel ${path.basename(socketFile)}`,
connect: { path: socketFile },
socketFile,
}));
const address = enabled ? localAddress() : null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Outgoing SSH offload stays enabled

After disableCommand runs on the SSH server, targets still returns open SSH tunnels. New editor launches keep rendering locally through those tunnels.

Suggested change
export function targets(enabled = readSettings().enabled): Target[] {
const found: Target[] = tunnelSockets().map((socketFile) => ({
route: "tunnel" as const,
label: `ssh tunnel ${path.basename(socketFile)}`,
connect: { path: socketFile },
socketFile,
}));
const address = enabled ? localAddress() : null;
export function targets(enabled = readSettings().enabled): Target[] {
if (!enabled) return [];
const found: Target[] = tunnelSockets().map((socketFile) => ({
route: "tunnel" as const,
label: `ssh tunnel ${path.basename(socketFile)}`,
connect: { path: socketFile },
socketFile,
}));
const address = localAddress();

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/tunnel.ts Outdated
Comment on lines +72 to +76
const REMOTE_SCRIPT = [
`tc="$HOME/.local/bin/terminal-code"`,
`[ -x "$tc" ] || tc="$HOME/.local/bin/tode"`,
`[ -x "$tc" ] || { echo "terminal-code-missing" >&2; exit 127; }`,
`exec "$tc" --local-rendering-tunnel`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 SSH setup misses custom installs

When the server uses a custom bin directory, REMOTE_SCRIPT ignores it and searches only the default directory. Setup reports terminal-code missing even when it is on the remote PATH.

Learn more

The installer accepts XDG_BIN_HOME and copies both shims there. SSH setup starts the tunnel using a remote shell script that looks only under ~/.local/bin. The script ignores both XDG_BIN_HOME and the remote PATH, then reports a missing install.

Example: Install terminal-code on the server with XDG_BIN_HOME=$HOME/bin and expose that directory in the remote command environment. Running terminal-code --setup-ssh user@server still reports that terminal-code is missing.

Recommended fix: Resolve both aliases through the configured bin directory and the remote PATH, keeping the default directory as a fallback for noninteractive SSH shells.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/remote.ts
Comment on lines +53 to +65
export function targets(enabled = readSettings().enabled): Target[] {
const found: Target[] = tunnelSockets().map((socketFile) => ({
route: "tunnel" as const,
label: `ssh tunnel ${path.basename(socketFile)}`,
connect: { path: socketFile },
socketFile,
}));
const address = enabled ? localAddress() : null;
if (address) {
found.push({
route: "direct",
label: `${address.includes(":") ? `[${address}]` : address}:${pairPort()}`,
connect: { host: address, port: pairPort() },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Tunnel priority contradicts the README

targets puts SSH tunnels first, and renderLocally tries them in order. The SSH guide says direct connections come first.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/pair/attempt.ts Outdated
Comment on lines +49 to +52
function thisServer(): string {
const server = sshEndpoints()?.server ?? os.hostname();
return `${os.userInfo().username}@${server.includes(":") ? `[${server}]` : server}`;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Unusable SSH recovery commands

thisServer drops the SSH port and emits bracketed IPv6 destinations. The setup command uses Pixel’s parser, which rejects those IPv6 destinations.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

- server only connects directly to tailnet (or trusted) addresses
- each streamed editor gets its own browser session
- --setup-ssh keeps the destination typed at its prompt
- only editor launches render locally, not the setup wizards
- verify the listener pid before killing it
- disabling local rendering on a server also stops tunnels
- --setup-ssh finds installs on XDG_BIN_HOME and PATH
- upgrade and install restart the listener
- suggested --setup-ssh commands keep the ssh port and parse ipv6

This branch was successfully deployed

1 active deployment
Preview — 77730854 Deployed Nov 24, 2026 by vercel[bot]
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.

How to use terminal-code with Herdr for remote development while keeping the client local?

1 participant