Repository navigation
Share native App Server connections between computers - #2281
Conversation
zerob13
left a comment
There was a problem hiding this comment.
Reviewed add24d24563cbd7d890529bb6e4ebc428084bcb3 against the sharing milestone. There are two blocking correctness and lifecycle findings from static review.
- A command entered through the remote CLI must not silently act on the keyboard computer. The Alpha guide describes the command form as targeting the selected computer, but the shared client starts the local CLI, where database maintenance is dispatched before transport setup (
npm/README.alpha.md:49–51,crates/dim-cli/src/lib.rs:923–938,crates/dim-cli/src/maintenance.rs:6–25). This can report success after modifying local state instead of the intended target. Acceptance: supported commands act on the selected target; commands outside this milestone fail clearly before producing any local side effects. - A finished RPC stream must release its Windows target connection. The relay waits for the response side after forwarding end-of-input, but the Windows named pipe write shutdown does not signal EOF to the target (
crates/dim-terminal-transport/src/proxy.rs:34–60,crates/dim-terminal-transport/src/streams.rs:196–205). The target can retain a stream that has finished, even though the shared link stays online. Acceptance: normal completion releases that stream promptly on a Windows target; another stream on the same shared link continues to work. This finding is from tracing the pinned transport implementation and has not been exercised on Windows hardware.
The isolated Alpha packaging check passed. Exact CI had macOS native, Windows CLI, scripts, Web and other static checks green; Linux was still running. Windows CLI CI is not Windows sharing acceptance. Two-host LAN discovery and handoff remain unverified here.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
At add24d24, the PR shares a native App Server between two computers: Settings remote access, token pairing, the TLS link, terminal transport, the UI return stream, packaging and the Alpha guide. The interactive device and session pickers, named CLI targets, and target-side directory and resource operations remain #2276 and #2277 scope. I reviewed the full main...head diff against 7d9148bb and the accepted #2278 design.
I agree with the two blocking findings already posted at this head and do not repeat them below.
P2: A broken optional sharing helper fails the whole App Server
Problem: crates/dim-app-server/src/cli.rs:668 uses .spawn()? for the optional dim-sharing helper. helper.is_file() checks only that a file exists, so a helper that is present but not executable, built for another architecture, replaced during an update, or temporarily unspawnable makes the App Server return an error during startup. The App Server never prints its endpoint, so the local daemon and all normal CLI and TUI startup fail even though sharing is optional.
Failure scenario: A user has a stale or copied dim-sharing beside dimcode with the wrong mode or architecture and starts dimcode. The sharing helper cannot be spawned, serve startup aborts, and the user loses the local App Server. dima share disable also starts the local App Server before it changes settings, so it fails the same way and cannot be used to recover. The user must repair or remove the helper and restart.
Fix: Treat a spawn error as sharing unavailable: log it and set sharing to None, or start a monitored helper whose failure cannot stop App Server startup. A helper that exits after startup should also be monitored or restarted; currently sharing stays down until the daemon restarts.
Non-blocking observations
runtime/native-sharing/server.go:130: a failed mDNS announcement is not retried while the name and addresses stay the same, so a transient helper or network failure at enable time can leave LAN discovery off until a settings change or daemon restart. Manual addresses and direct connect still work.crates/dim-cli/src/ui/remote_access.rs:88: in Settings, the token and reset entries exist only whenStatus.tokenis present, and the helper returns the token only while sharing is enabled, so rotating the stored token while sharing is off requires enabling it first.
No other unique blocking findings.
Verification: go test -race ./... in runtime/native-sharing passed at this head. CI at this head has ci-ok success; all listed check runs are successful and acp-registry is skipped. I did not run the packaged native flow or Windows runtime; those remain unverified here.
REQUEST_CHANGES
Reject machine-local operations at the shared client boundary. Keep the App Server available when the optional sharing process fails and retry independently. Close only the finished Windows RPC pipe while retaining half-close for byte streams that support it.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
At 444092b7, the PR shares a native App Server between two computers: remote access settings, token pairing, the TLS link, terminal transport, the UI return stream, packaging and the Alpha guide. This head adds a restarting helper supervisor, rejects local-only commands on a shared connection, retries LAN announcements, shows reset while sharing is disabled, and changes the Windows stream close path. I reviewed the full main...head diff against ee223ff6 and the accepted #2278 design.
The prior findings are fixed and withdrawn: a broken optional dim-sharing helper no longer stops App Server startup and is retried; a failed mDNS announcement is retried; reset is available while sharing is disabled; the local-only command guard covers database export and maintenance, and the new flow script covers seven refused commands. The remote CLI guard also covers the database-maintenance path from the earlier review, and the Windows release path now closes the target stream for a full close. I do not repeat those findings.
No blocking findings.
P3 (optional). Windows half-close remains a documented limit. finish_write closes the whole stream when the local input reaches EOF (crates/dim-terminal-transport/src/streams.rs:198-203), and the concurrent read returns gone (:176-181), so a Windows client that half-closes its write side and keeps reading loses the reply. docs/architecture/build.md:14 scopes half-close to POSIX sockets and the TCP UI return stream, and the new test covers the documented full-close release (crates/dim-terminal-transport/tests/windows_pipe_flow.rs:46-47), so I do not block. If the broad half-close wording in the PR body is meant to include Windows target streams, state that limit in the Alpha guide or add a half-close test.
Verification: go test -race ./... in runtime/native-sharing passed. cargo test -p dim-terminal-transport compiled; its Windows test is cfg(windows) and ran zero cases here. Targeted dim-cli and dim-app-server library filters compiled with zero matching tests. cargo fmt --all -- --check, git diff --check and the changed script syntax pass. CI at this head has changes, macos-native, scripts, static-checks, web and windows-cli successful; dependencies failed in actions/checkout on a self-hosted runner before the dependency check ran, verify (linux) was in progress, and ci-ok had not completed. I did not run the packaged native flow, Windows hardware, or two-host LAN and Tailscale acceptance; those remain unverified here. The PR is open, not draft, mergeable true and blocked.
APPROVE
zerob13
left a comment
There was a problem hiding this comment.
Re-reviewed 444092b78205fe19f6e81b22008de781c9ccae32. The local-command guard, Windows single-stream cleanup, and isolation of sharing-helper startup failure meet the previous acceptance conditions. One new regression in the supervisor remains.
A remote shutdown must report the actual shutdown outcome before disconnecting. The new supervisor starts tearing down the sharing link when shutdown is signalled (crates/dim-app-server/src/cli.rs:646–678), but the App Server sends the shutdown reply only after cleanup settles (crates/dim-app-server/src/transport.rs:848–871). If cleanup takes longer than link teardown, a normal remote stop reports a connection error even when the target shut down successfully, or loses the actual cleanup error. This is a static ordering finding. Acceptance: a normal remote stop with delayed cleanup receives the same success or cleanup error as a local request, then the sharing connection closes.
The exact CI run passed the Windows named-pipe checks and macOS native tests. Linux timed out in goal_suite before the sharing flow ran; the cause is unconfirmed. The dependency job failed during checkout, before checking dependencies.
zerob13
left a comment
There was a problem hiding this comment.
Re-reviewed 735c5398bb4e4fcb198050d21d003973507e1076. The supervisor now lets the owner finish cleanup and send its shutdown response before draining the sharing link. The earlier local-command, target-stream cleanup and optional-helper isolation findings remain closed.
Windows keyboard-side shutdown still needs to complete after the reply. When the remote side ends its RPC stream, the proxy only shuts down the write half of the local named pipe (crates/dim-terminal-transport/src/proxy.rs:34–60). On Windows, that does not deliver EOF. The CLI still waits for EOF after a successful reply (crates/dim-cli/src/client.rs:673–684), so it can time out even though the target replied successfully within the command deadline. This follows from the client and transport paths; it was not tested on Windows hardware. Acceptance: when cleanup completes within the current deadline, a Windows keyboard-side client gets the actual success or cleanup error, completes normally, and reports the same result as a direct connection.
Exact CI passed the Windows target-pipe check, which covers the opposite direction. Linux and static checks stopped at rustfmt before the new delayed-shutdown tests could run.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
At 735c5398, the PR shares a native App Server between computers: remote settings and token pairing, the TLS link, terminal transport, the UI return stream, packaging and the Alpha guide. This head separates the sharing helper stop token from the App Server shutdown signal, stops the helper only after the App Server join, and drains active peers before the helper exits. I reviewed the full main...head diff and the accepted #2278 design.
The earlier findings are fixed and withdrawn: a broken optional dim-sharing helper no longer stops App Server startup and is retried; the local-only command guard covers database export and maintenance; a failed mDNS announcement is retried; reset is available while sharing is disabled; the Windows target stream now closes fully on input EOF, and its half-close limit is documented in docs/architecture/build.md and npm/README.alpha.md. The new fixture covers both cleanup outcomes: a remote daemon stop waits for delayed cleanup, reports shutdown_failed when cleanup fails, and matches a direct POSIX connection for both results.
I agree with the existing changes-requested review on the remaining Windows keyboard-side shutdown path and do not repeat it.
P2. CI fails the rustfmt width check at this head.
Problem: the new wait at crates/dim-app-server/src/cli.rs:719 is 101 columns, and the repository runs cargo fmt --all -- --check --config error_on_line_overflow=true in static-checks and verify (linux). The required checks stop at this line before clippy, tests or the native sharing step can run.
Failure scenario: every push at this head leaves static-checks, verify (linux) and ci-ok red, so the PR cannot merge even though the shutdown logic passes its targeted tests.
Evidence: crates/dim-app-server/src/cli.rs:719 is if tokio::time::timeout(Duration::from_secs(15), child.wait()).await.is_err() at 101 columns. The local CI-style check exits 1 on that line, and CI run 46006975825 reports the same error in both jobs.
Fix: wrap the chain by hand, for example:
if tokio::time::timeout(Duration::from_secs(15), child.wait())
.await
.is_err()
{cargo fmt alone leaves this expression on one line, so the manual wrap is required.
Verification at 735c5398: go test -mod=readonly -race ./... in runtime/native-sharing passed. The sharing-shutdown-fixture example built, and the full scripts/native-sharing-flow.mjs passed on macOS with 3 tests, including remote stop waits for successful cleanup and remote stop preserves a delayed cleanup error, with POSIX and shared result parity. The CI-style cargo fmt check fails only at cli.rs:719; git diff --check and node --check scripts/native-sharing-flow.mjs pass. CI at this head: changes, dependencies, macos-native, scripts, web and windows-cli pass; static-checks, verify (linux) and ci-ok fail on the rustfmt error; acp-registry is skipped. The new delayed-shutdown tests did not run in CI because verify (linux) stopped at rustfmt; the local run above covers them. I did not run the flow on Windows, a two-host LAN or Tailscale setup, or a Windows keyboard-side client; those remain unverified here. The PR is open, not draft, mergeable true and blocked.
REQUEST_CHANGES
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
At 85c53f65, the PR shares a native App Server between computers: remote access settings and token pairing, the TLS link, terminal transport, the UI return stream, packaging and the Alpha guide. This head closes the Windows client pipe after the final shared reply, adds the Windows native-sharing flow to CI, and wraps the shutdown wait for the rustfmt width check. I reviewed the complete main...head diff against ee223ff6 and the accepted #2278 design.
The earlier findings are fixed and withdrawn: the optional dim-sharing helper no longer stops App Server startup and is supervised; the local-only command guard covers database export and maintenance; a failed mDNS announcement is retried; reset is available while sharing is disabled; the Windows target stream closes fully on input EOF; a remote shutdown reports the actual cleanup result before the sharing link drains; and the 15-second wait no longer fails rustfmt. The new Windows proxy path delivers the final reply and closes the local RPC pipe when the target stream ends. The prior Windows half-close P3 is also withdrawn because the Alpha guide and docs/architecture/build.md now scope the limit and the new test covers the keyboard-side completion.
No blocking findings. I did not repeat the earlier Windows keyboard-side finding; the new crates/dim-terminal-transport/tests/windows_pipe_flow.rs test covers both an input end and a target end, and the new Windows native-sharing CI step passed at this head.
Verification at 85c53f65: cargo fmt --all -- --check --config error_on_line_overflow=true exits 0; git diff --check exits 0; node --check scripts/native-sharing-flow.mjs exits 0; go test -mod=readonly -race ./... in runtime/native-sharing passed; cargo test --locked -p dim-terminal-transport compiled, with the Windows test correctly running zero cases on macOS. CI: changes, dependencies, macos-native, scripts, static-checks, web and windows-cli pass; verify (linux) was in progress when checked; acp-registry is skipped. The PR is open, not draft and mergeable true.
APPROVE
zerob13
left a comment
There was a problem hiding this comment.
Approved at 85c53f650812a0c965ac0ba3df7a187742db7e7c. The Windows keyboard-side relay now delivers the full reply and EOF. The two-pipe tests cover both directions without closing an unrelated stream, and the exact Windows and Linux sharing CI checks delayed success and cleanup failure against a direct connection. The previous local-command, stream lifetime, and optional-helper isolation findings remain closed. No new blocking findings. The CI evidence is from native pipes and loopback on hosted runners, not a two-computer physical LAN test.
Refs #2275 and #2269. Implements the sharing and connection milestone of the accepted native terminal design. The interactive device and session pickers and named CLI targets are tracked in #2276. Target-side directory and resource operations are tracked in #2277.
User flow
On the target computer, open
/settings → Remote access. Sharing starts off. Enabling it shows the reachable addresses and the complete token. The display name defaults to the hostname and can be edited. On the other computer, rundima share discoveror enter an address withdima share connect <address>. A successful pairing is remembered by verified instance identity.--no-rememberlimits the credential to this connection. Resetting the token revokes the active links. Use--pairto enter the replacement.From a shell,
dima share connect <address>prompts for a token on first use and opens the remote TUI. For a single CLI request,dima share connect <address> -- mcp listprints the target’s result and exits. Both paths use the same remembered pairing. The flow from an already-open Home or conversation (/devices, choose a computer, then choose a session or directory) and the--target <name>CLI entry belong to #2276. The existing/connectcommand manages model providers.Design and ownership
terminalTransportdata face opens independent streams to the existing native endpoint and prepares a one-use return stream for the UI leaf. Bounded chunks carry reads and writes. POSIX sockets and the TCP UI return stream support a write-side half-close. Closing the input of a Windows target RPC closes its named pipe. The target supplies its default working directory and interprets an explicit--cwd.Review fixes
shutdown_failedresult. On a Windows keyboard computer, the proxy closes the local named pipe after forwarding all reply bytes. The Windows job checks EOF with the shared link still open and runs the same CLI shutdown scenarios over a packaged loopback connection.Verification