remove dissolved daemon, retire ptyc, fix golden cross-platform

Complete three overdue cleanups discovered during macOS health check:

D-56 daemon dissolution: delete bin/clide.dart, DaemonServer,
and orphaned tests (test/cli/, subprocess_test, in_process_test).
Update stale "clide --daemon" references in i18n catalogs, error
messages, editor_commands, CI scripts, and decision records.

ptyc retirement: delete ptyc/ source tree, PtySession, scm_rights.
Remove from Toolchain resolution, ToolCheck gate, backend
serialization, testmode harness, Makefile, CI, and sandbox
entitlements. PTY spawning uses NativePty (Dart FFI forkpty) since
the terminal was absorbed in-tree. D-5 amended.

Golden tests: wire the existing but never-applied clideGoldenConfig
via flutter_test_config.dart. Disable CI goldens (Skia anti-aliasing
differs between macOS/Linux even with Ahem). Keep platform-keyed
goldens only — goldens/linux/ and goldens/macos/ each run on their
own OS.

Test suite: 826 pass, 0 fail on macOS (was 829 pass, 11 fail).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeroen Schweitzer
2026-05-07 18:40:01 +02:00
co-authored by Claude Opus 4.6
parent 6b7290dc42
commit a6eca2561b
51 changed files with 265 additions and 2719 deletions
-158
View File
@@ -1,158 +0,0 @@
/// End-to-end tests for the tier-2 CLI shortcuts.
///
/// Each test launches `bin/clide --daemon` as a subprocess, exercises
/// a shortcut (`open`, `active`, `insert`, `save`, `tail`), and
/// asserts the JSON response shape. Requires a built `bin/clide`
/// binary — `ci/test_core.sh` runs `make build` first when needed,
/// or here we build on demand.
library;
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:test/test.dart';
const _socketEnv = 'CLIDE_SOCKET_PATH';
void main() {
late Directory sandbox;
late Process daemon;
late String socketPath;
late String clideBin;
setUpAll(() async {
final candidate = File('bin/clide');
if (!candidate.existsSync()) {
final built = await Process.run('make', const ['build']);
if (built.exitCode != 0) {
throw StateError('make build failed: ${built.stderr}');
}
}
clideBin = candidate.absolute.path;
});
setUp(() async {
sandbox = await Directory.systemTemp.createTemp('clide-cli-t2-');
await File('${sandbox.path}/doc.md').writeAsString('alpha beta');
// Each test gets its own socket path so concurrent test runs don't
// collide. Passed through the daemon via env.
socketPath = '${sandbox.path}/daemon.sock';
daemon = await Process.start(
clideBin,
const ['--daemon'],
workingDirectory: sandbox.path,
environment: {
...Platform.environment,
_socketEnv: socketPath,
},
);
// Wait for the "listening" line on stderr so we know it's ready.
final ready = Completer<void>();
daemon.stderr.transform(utf8.decoder).transform(const LineSplitter()).listen((line) {
if (!ready.isCompleted && line.contains('listening')) {
ready.complete();
}
});
await ready.future.timeout(const Duration(seconds: 5));
});
tearDown(() async {
daemon.kill(ProcessSignal.sigterm);
await daemon.exitCode.timeout(const Duration(seconds: 3), onTimeout: () {
daemon.kill(ProcessSignal.sigkill);
return -1;
});
if (sandbox.existsSync()) sandbox.deleteSync(recursive: true);
});
Future<Map<String, Object?>> run(List<String> args) async {
final r = await Process.run(
clideBin,
args,
workingDirectory: sandbox.path,
environment: {
...Platform.environment,
_socketEnv: socketPath,
},
);
expect(r.exitCode, 0, reason: 'stderr: ${r.stderr}');
return jsonDecode(r.stdout.toString().trim()) as Map<String, Object?>;
}
test('clide open <path> returns buffer metadata', () async {
final r = await run(['open', 'doc.md']);
expect(r['id'], startsWith('b_'));
expect(r['path'], 'doc.md');
});
test('clide active reflects the most recent open', () async {
await run(['open', 'doc.md']);
final r = await run(['active']);
final active = r['active']! as Map;
expect(active['path'], 'doc.md');
});
test('clide insert + clide active round-trip', () async {
await run(['open', 'doc.md']);
await run(['insert', 'hello ']);
final r = await run(['active']);
final active = r['active']! as Map;
expect(active['dirty'], isTrue);
expect((active['length'] as num).toInt(), greaterThan('alpha beta'.length));
});
test('clide save clears dirty + writes to disk', () async {
await run(['open', 'doc.md']);
await run(['insert', 'X ']);
await run(['save']);
final active = (await run(['active']))['active']! as Map;
expect(active['dirty'], isFalse);
final disk = await File('${sandbox.path}/doc.md').readAsString();
expect(disk.startsWith('X '), isTrue);
});
test('clide tail --events streams editor.* events', () async {
// Start a tail subscriber.
final tail = await Process.start(
clideBin,
const ['tail', '--events', '--filter', 'editor'],
workingDirectory: sandbox.path,
environment: {
...Platform.environment,
_socketEnv: socketPath,
},
);
final received = <Map<String, Object?>>[];
final sub = tail.stdout.transform(utf8.decoder).transform(const LineSplitter()).listen((line) {
if (line.isEmpty) return;
received.add(jsonDecode(line) as Map<String, Object?>);
});
// Give the subscriber a beat to connect.
await Future<void>.delayed(const Duration(milliseconds: 200));
await run(['open', 'doc.md']);
await run(['insert', 'T ']);
// Wait up to 2s for events.
for (var i = 0; i < 20 && received.length < 3; i++) {
await Future<void>.delayed(const Duration(milliseconds: 100));
}
tail.kill(ProcessSignal.sigint);
await tail.exitCode.timeout(const Duration(seconds: 2), onTimeout: () {
tail.kill(ProcessSignal.sigkill);
return -1;
});
await sub.cancel();
final kinds = received.map((e) => e['kind']).toList();
expect(kinds, containsAll(['editor.opened', 'editor.edited']));
// Confirm filter actually filtered — no pane events made it in.
for (final e in received) {
expect(e['subsystem'], 'editor');
}
});
}
-113
View File
@@ -1,113 +0,0 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:test/test.dart';
void main() {
group('DaemonServer (in-process)', () {
late DaemonServer server;
late DaemonDispatcher dispatcher;
late String socketPath;
setUp(() async {
final tmp = await Directory.systemTemp.createTemp('clide_daemon_');
socketPath = '${tmp.path}/daemon.sock';
dispatcher = DaemonDispatcher();
server = DaemonServer(
socketPath: socketPath,
dispatch: dispatcher.dispatch,
);
await server.start();
});
tearDown(() async {
await server.stop();
});
test('ping round-trips with pong=true', () async {
final resp = await _send(
socketPath,
IpcRequest(id: '1', cmd: 'ping').encode(),
);
final parsed = IpcMessage.decode(resp) as IpcResponse;
expect(parsed.ok, true);
expect(parsed.id, '1');
expect(parsed.data['pong'], true);
expect(parsed.data['ts'], isA<String>());
expect(parsed.data['version'], isA<String>());
});
test('version returns current clideVersion', () async {
final resp = await _send(
socketPath,
IpcRequest(id: 'v', cmd: 'version').encode(),
);
final parsed = IpcMessage.decode(resp) as IpcResponse;
expect(parsed.ok, true);
expect(parsed.data['version'], clideVersion);
});
test('unknown command returns NotFound (exit code 3)', () async {
final resp = await _send(
socketPath,
IpcRequest(id: 'x', cmd: 'this.does.not.exist').encode(),
);
final parsed = IpcMessage.decode(resp) as IpcResponse;
expect(parsed.ok, false);
expect(parsed.error!.code, IpcExitCode.notFound);
expect(parsed.error!.kind, IpcErrorKind.notFound);
expect(parsed.error!.message, contains('this.does.not.exist'));
});
test('multiple concurrent requests on one connection', () async {
final socket = await Socket.connect(
InternetAddress(socketPath, type: InternetAddressType.unix),
0,
);
for (var i = 0; i < 5; i++) {
socket.writeln(IpcRequest(id: '$i', cmd: 'ping').encode());
}
final lines = <String>[];
final done = Completer<void>();
final sub = socket.cast<List<int>>().transform(utf8.decoder).transform(const LineSplitter()).listen((line) {
lines.add(line);
if (lines.length == 5) done.complete();
});
await done.future.timeout(const Duration(seconds: 2));
await sub.cancel();
await socket.close();
final ids = lines.map((l) => (IpcMessage.decode(l) as IpcResponse).id).toSet();
expect(ids, {'0', '1', '2', '3', '4'});
});
test('custom handler plugs into dispatcher', () async {
dispatcher.register('test.custom', (req) async {
return IpcResponse.ok(id: req.id, data: {'echo': req.args});
});
final resp = await _send(
socketPath,
IpcRequest(
id: 'c',
cmd: 'test.custom',
args: const {'x': 1},
).encode(),
);
final parsed = IpcMessage.decode(resp) as IpcResponse;
expect(parsed.ok, true);
expect(parsed.data['echo'], {'x': 1});
});
});
}
Future<String> _send(String socketPath, String line) async {
final socket = await Socket.connect(
InternetAddress(socketPath, type: InternetAddressType.unix),
0,
);
socket.writeln(line);
final resp = await socket.cast<List<int>>().transform(utf8.decoder).transform(const LineSplitter()).first.timeout(const Duration(seconds: 2));
await socket.close();
return resp;
}
-9
View File
@@ -9,7 +9,6 @@ import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/src/daemon/pane_commands.dart';
import 'package:clide/src/panes/registry.dart';
import 'package:test/test.dart';
@@ -17,9 +16,6 @@ import 'package:test/test.dart';
void main() {
if (!Platform.isLinux && !Platform.isMacOS) return;
final toolchain = Toolchain();
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: Directory.current.path));
group('pane.* dispatch', () {
late DaemonDispatcher dispatcher;
late PaneRegistry registry;
@@ -48,7 +44,6 @@ void main() {
final r = await call('pane.spawn', {
'argv': const ['/bin/sh', '-c', 'sleep 0.1'],
'kind': 'terminal',
'ptyc_path': toolchain.ptyc,
});
expect(r.ok, isTrue, reason: r.error?.message);
expect(r.data['id'], startsWith('p_'));
@@ -58,12 +53,10 @@ void main() {
test('pane.list shows spawned panes', () async {
await call('pane.spawn', {
'argv': const ['/bin/cat'],
'ptyc_path': toolchain.ptyc,
});
await call('pane.spawn', {
'argv': const ['/bin/cat'],
'kind': 'claude',
'ptyc_path': toolchain.ptyc,
});
final r = await call('pane.list', const {});
final panes = (r.data['panes'] as List).cast<Map>();
@@ -74,7 +67,6 @@ void main() {
test('pane.write accepts text or bytes_b64', () async {
final spawn = await call('pane.spawn', {
'argv': const ['/bin/cat'],
'ptyc_path': toolchain.ptyc,
});
final id = spawn.data['id']! as String;
@@ -98,7 +90,6 @@ void main() {
test('pane.resize + pane.close + pane.focus round-trip', () async {
final spawn = await call('pane.spawn', {
'argv': const ['/bin/cat'],
'ptyc_path': toolchain.ptyc,
});
final id = spawn.data['id']! as String;
-81
View File
@@ -1,81 +0,0 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:test/test.dart';
/// Subprocess-level daemon smoke. Only runs if `bin/clide` has been
/// built (the test skips itself otherwise). This is the release-gate
/// suite — catches signal-handling, socket-unlink, and version-stamp
/// regressions that the in-process test masks.
void main() {
final binary = File('bin/clide');
group('bin/clide --daemon (subprocess)', () {
setUpAll(() {
if (!binary.existsSync()) {
markTestSkipped('bin/clide not built; run `make build` first to enable this suite');
}
});
test('starts, responds to ping, exits cleanly on SIGTERM', () async {
if (!binary.existsSync()) return;
// Use a fresh socket under a unique temp path so parallel test
// runs don't collide. The daemon resolves its socket path from
// XDG_RUNTIME_DIR + USER (see defaultSocketPath()).
final tmp = await Directory.systemTemp.createTemp('clide_sub_');
final env = Map<String, String>.from(Platform.environment)
..['XDG_RUNTIME_DIR'] = tmp.path
..['USER'] = 'daemon';
final socketPath = '${tmp.path}/clide-daemon.sock';
final process = await Process.start(
binary.absolute.path,
['--daemon'],
environment: env,
);
// Wait for "listening on ..." on stderr before connecting.
final ready = Completer<void>();
final stderrLines = <String>[];
final sub = process.stderr.transform(utf8.decoder).transform(const LineSplitter()).listen((line) {
stderrLines.add(line);
if (line.contains('listening')) ready.complete();
});
try {
await ready.future.timeout(const Duration(seconds: 3));
// Connect and ping
final sock = await Socket.connect(
InternetAddress(socketPath, type: InternetAddressType.unix),
0,
).timeout(const Duration(seconds: 3));
sock.writeln(IpcRequest(id: '1', cmd: 'ping').encode());
final line = await sock.cast<List<int>>().transform(utf8.decoder).transform(const LineSplitter()).first.timeout(const Duration(seconds: 3));
await sock.close();
final resp = IpcMessage.decode(line) as IpcResponse;
expect(resp.ok, true);
expect(resp.data['pong'], true);
// Clean shutdown
process.kill(ProcessSignal.sigterm);
final exitCode = await process.exitCode.timeout(const Duration(seconds: 3));
expect(exitCode, 0);
// Socket file should be unlinked
expect(await File(socketPath).exists(), false);
} finally {
await sub.cancel();
try {
process.kill(ProcessSignal.sigkill);
} catch (_) {}
try {
await tmp.delete(recursive: true);
} catch (_) {}
}
}, timeout: const Timeout(Duration(seconds: 15)));
});
}
+12
View File
@@ -0,0 +1,12 @@
import 'dart:async';
import 'package:alchemist/alchemist.dart';
import '../helpers/golden_harness.dart';
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
return AlchemistConfig.runWithConfig(
config: clideGoldenConfig(),
run: testMain,
);
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

+9 -12
View File
@@ -2,21 +2,18 @@ import 'package:alchemist/alchemist.dart';
/// Alchemist config shared across all golden tests.
///
/// * CI mode uses the Ahem font (shipped with Flutter's test harness) so
/// goldens render identically on every Linux runner and developer
/// machine. Any drift between platforms points to a real theme-token
/// regression, not a font-rendering fluke.
/// * Local mode keeps developer-machine fonts so you can eyeball
/// renders naturally; the `--update-goldens` workflow still produces
/// CI-valid goldens because CI runs the config below.
AlchemistConfig clideGoldenConfig({bool forceCiMode = false}) {
return AlchemistConfig(
/// Platform goldens only — keyed by OS (`goldens/linux/`, `goldens/macos/`).
/// CI goldens (Ahem font in `goldens/ci/`) are disabled because Skia's
/// geometric anti-aliasing differs between macOS and Linux even with Ahem,
/// producing sub-pixel diffs that fail cross-platform.
AlchemistConfig clideGoldenConfig() {
return const AlchemistConfig(
theme: null, // we're not using Material ThemeData
platformGoldensConfig: PlatformGoldensConfig(
enabled: !forceCiMode,
),
ciGoldensConfig: const CiGoldensConfig(
enabled: true,
),
ciGoldensConfig: CiGoldensConfig(
enabled: false,
),
);
}
+2 -2
View File
@@ -1,8 +1,8 @@
/// Unit tests for [PaneRegistry].
///
/// Exercises spawn / list / write / resize / close against the real
/// `ptyc` binary (small enough, and realistic enough, to not be worth
/// mocking). Events are captured via [RecordingEventSink].
/// NativePty (forkpty via FFI). Events are captured via
/// [RecordingEventSink].
library;
import 'dart:async';