decouple Pane from PtySession so the web build compiles
test / unit + widget + golden + a11y (push) Failing after 37s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped

Pane is now a pure data class — id, kind, pid, argv, cwd, title,
isClosed. The daemon-side PaneRegistry holds a parallel map of
PtySession keyed on id; registry methods look up both sides when
writing / resizing / closing.

The `clide.dart` barrel no longer re-exports `src/pty/*`,
`src/panes/registry.dart`, or the `*_commands.dart` modules — all
three transitively import `dart:ffi` which isn't available when
compiling to WebAssembly. The daemon entrypoint (bin/clide.dart) +
core tests import them via deep paths now. Pane / PaneKind /
DaemonEventSink / RecordingEventSink stay in the barrel since
they're pure data the Flutter app references over IPC.

Verified: `dart analyze` clean, 53 core tests green, 174 app tests
green, `make ui-smoke` compiles + serves + Playwright smoke passes,
daemon boots + ping round-trips + SIGTERMs cleanly.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-04-22 10:01:06 +02:00
co-authored by Claude
parent b9fbcd43a2
commit 37108230f2
8 changed files with 44 additions and 27 deletions
+6
View File
@@ -13,6 +13,12 @@ import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
// Daemon-only deep imports — these pull in dart:ffi (PTY) and
// daemon-subsystem wiring that the Flutter app doesn't need and
// can't compile for web. See lib/clide.dart for the barrel split.
import 'package:clide/src/daemon/files_commands.dart';
import 'package:clide/src/daemon/pane_commands.dart';
import 'package:clide/src/panes/registry.dart';
Future<void> main(List<String> argv) async {
if (argv.isEmpty) {
+8 -6
View File
@@ -8,21 +8,23 @@
/// * `decisions/architecture.md` `D-006` — CLI + event contract.
library;
// Flutter-app-visible surface. Deliberately **does not** export the
// `pty/` or `panes/registry.dart` modules — those import `dart:ffi`
// and pull in the PTY machinery that only runs on desktop. The
// daemon entrypoint (`bin/clide.dart`) imports them via deep paths.
//
// `Pane` + `PaneKind` + the event-sink interfaces travel here because
// they're pure data types that both the app and the daemon reference.
export 'src/daemon/dispatcher.dart';
export 'src/daemon/files_commands.dart';
export 'src/daemon/pane_commands.dart';
export 'src/files/ignore.dart';
export 'src/files/listing.dart' show FileEntry, listDir;
export 'src/files/watcher.dart';
export 'src/ipc/envelope.dart';
export 'src/ipc/paths.dart';
export 'src/ipc/schema_v1.dart';
export 'src/ipc/server.dart';
export 'src/panes/event_sink.dart';
export 'src/panes/pane.dart' show Pane, PaneKind;
export 'src/panes/registry.dart' show PaneRegistry;
export 'src/pty/errors.dart' show PtyException;
export 'src/pty/pty.dart';
/// Build-time-stamped version string.
///
+12 -14
View File
@@ -1,13 +1,11 @@
/// A single active pane in the daemon.
/// A single active pane. Pure data — no PTY coupling so this type
/// travels cleanly into the Flutter app (which can't depend on
/// `dart:ffi`-using code for the web build).
///
/// Owns a [PtySession] plus whatever pane-level metadata the UI +
/// CLI need. The `kind:` field distinguishes general-purpose terminal
/// panes from Claude panes (D-041, not yet landed) from whatever
/// future pane-shaped surface Tier 1+ grows.
/// The daemon's [PaneRegistry] keeps a parallel `PtySession` keyed on
/// [id] and mutates [isClosed] when the session exits.
library;
import '../pty/session.dart';
/// Kind of a pane. Keep this enum small and explicit — each kind
/// typically pairs with a bundled extension that manages its
/// lifecycle (`builtin.terminal`, `builtin.claude`).
@@ -25,28 +23,28 @@ enum PaneKind {
}
}
/// A live pane. Thin wrapper over [PtySession] — the registry is what
/// owns the session lifecycle; consumers of this class read state and
/// call [write] / [resize] via the session.
class Pane {
Pane({
required this.id,
required this.kind,
required this.session,
required this.pid,
required this.argv,
this.cwd,
this.title,
this.isClosed = false,
});
final String id;
final PaneKind kind;
final PtySession session;
final int pid;
final List<String> argv;
final String? cwd;
final String? title;
int get pid => session.pid;
bool get isClosed => session.isClosed;
/// Mutated by the registry when the child exits or the session
/// closes. Kept mutable so registry state doesn't need to replace
/// [Pane] instances on transition.
bool isClosed;
Map<String, Object?> toJson() => {
'id': id,
+13 -6
View File
@@ -20,6 +20,7 @@ class PaneRegistry {
final DaemonEventSink events;
final Map<String, Pane> _panes = {};
final Map<String, PtySession> _sessions = {};
final Map<String, StreamSubscription<Uint8List>> _subs = {};
int _nextId = 1;
@@ -55,12 +56,13 @@ class PaneRegistry {
final pane = Pane(
id: id,
kind: kind,
session: session,
pid: session.pid,
argv: argv,
cwd: cwd,
title: title,
);
_panes[id] = pane;
_sessions[id] = session;
_emit('pane.spawned', id, pane.toJson());
@@ -77,15 +79,17 @@ class PaneRegistry {
/// Send bytes to a pane's stdin.
int write(String id, List<int> bytes) {
final p = _panes[id];
if (p == null || p.isClosed) return 0;
return p.session.write(bytes);
final s = _sessions[id];
if (p == null || p.isClosed || s == null) return 0;
return s.write(bytes);
}
/// Resize a pane + emit `pane.resized`.
void resize(String id, {required int cols, required int rows}) {
final p = _panes[id];
if (p == null || p.isClosed) return;
p.session.resize(cols: cols, rows: rows);
final s = _sessions[id];
if (p == null || p.isClosed || s == null) return;
s.resize(cols: cols, rows: rows);
_emit('pane.resized', id, {'cols': cols, 'rows': rows});
}
@@ -93,9 +97,11 @@ class PaneRegistry {
Future<void> close(String id) async {
final p = _panes[id];
if (p == null) return;
await p.session.close();
final s = _sessions[id];
if (s != null) await s.close();
await _subs[id]?.cancel();
_subs.remove(id);
_sessions.remove(id);
_panes.remove(id);
_emit('pane.closed', id, const {});
}
@@ -111,6 +117,7 @@ class PaneRegistry {
void _onExit(Pane p) {
if (_panes.containsKey(p.id)) {
p.isClosed = true;
_emit('pane.exit', p.id, const {});
// Don't auto-close — keep the pane entry so `list` can show the
// exited state until the consumer explicitly closes. A future
+1
View File
@@ -4,6 +4,7 @@ library;
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/src/daemon/files_commands.dart';
import 'package:test/test.dart';
void main() {
+2
View File
@@ -9,6 +9,8 @@ import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/src/daemon/pane_commands.dart';
import 'package:clide/src/panes/registry.dart';
import 'package:test/test.dart';
void main() {
+1
View File
@@ -10,6 +10,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/src/panes/registry.dart';
import 'package:test/test.dart';
void main() {
+1 -1
View File
@@ -9,7 +9,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/src/pty/pty.dart';
import 'package:test/test.dart';
void main() {