add Toolchain, GitClient, native directory picker
Toolchain centralizes binary resolution — replaces five ad-hoc mechanisms (expandedPath, _resolveGit, _resolve, _resolvePtyc, _existsOnPath). Resolves via Future.delayed after runApp to avoid blocking the merged UI/platform thread on macOS. GitClient wraps all git operations with a typed API. Every subprocess call goes through _run() using toolchain.git + toolchain.gitEnv. Replaces free functions in operations.dart. Native directory picker: NSOpenPanel on macOS (method channel in AppDelegate), GtkFileChooserDialog on Linux. Falls back to text-input dialog on web or MissingPluginException. Shows "No git repo found" dialog when the selected directory is not a git repository. PqlClient and pane commands updated to use Toolchain. ToolCheck replaced by Toolchain.missing/allOk. All IPC handlers now catch GitException to prevent unhandled exceptions on the merged thread. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
8edcc78bfe
commit
73e80a55a6
@@ -1,6 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide/kernel/src/toolchain.dart';
|
||||
import 'package:clide/src/git/client.dart';
|
||||
import 'package:clide/src/daemon/git_commands.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -32,7 +34,10 @@ void main() {
|
||||
|
||||
sink = RecordingEventSink();
|
||||
dispatcher = DaemonDispatcher();
|
||||
registerGitCommands(dispatcher, sandbox, sink);
|
||||
final toolchain = Toolchain();
|
||||
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: sandbox.path));
|
||||
final gitClient = GitClient(toolchain: toolchain, workDir: sandbox);
|
||||
registerGitCommands(dispatcher, gitClient, sink);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
||||
@@ -9,6 +9,7 @@ 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';
|
||||
@@ -16,9 +17,8 @@ import 'package:test/test.dart';
|
||||
void main() {
|
||||
if (!Platform.isLinux && !Platform.isMacOS) return;
|
||||
|
||||
final ptycPath = File('ptyc/bin/ptyc').existsSync()
|
||||
? File('ptyc/bin/ptyc').absolute.path
|
||||
: 'ptyc';
|
||||
final toolchain = Toolchain();
|
||||
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: Directory.current.path));
|
||||
|
||||
group('pane.* dispatch', () {
|
||||
late DaemonDispatcher dispatcher;
|
||||
@@ -28,7 +28,7 @@ void main() {
|
||||
final sink = RecordingEventSink();
|
||||
registry = PaneRegistry(events: sink);
|
||||
dispatcher = DaemonDispatcher();
|
||||
registerPaneCommands(dispatcher, registry);
|
||||
registerPaneCommands(dispatcher, registry, toolchain: toolchain);
|
||||
});
|
||||
|
||||
tearDown(() => registry.shutdown());
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
final r = await call('pane.spawn', {
|
||||
'argv': const ['/bin/sh', '-c', 'sleep 0.1'],
|
||||
'kind': 'terminal',
|
||||
'ptyc_path': ptycPath,
|
||||
'ptyc_path': toolchain.ptyc,
|
||||
});
|
||||
expect(r.ok, isTrue, reason: r.error?.message);
|
||||
expect(r.data['id'], startsWith('p_'));
|
||||
@@ -58,12 +58,12 @@ void main() {
|
||||
test('pane.list shows spawned panes', () async {
|
||||
await call('pane.spawn', {
|
||||
'argv': const ['/bin/cat'],
|
||||
'ptyc_path': ptycPath,
|
||||
'ptyc_path': toolchain.ptyc,
|
||||
});
|
||||
await call('pane.spawn', {
|
||||
'argv': const ['/bin/cat'],
|
||||
'kind': 'claude',
|
||||
'ptyc_path': ptycPath,
|
||||
'ptyc_path': toolchain.ptyc,
|
||||
});
|
||||
final r = await call('pane.list', const {});
|
||||
final panes = (r.data['panes'] as List).cast<Map>();
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
test('pane.write accepts text or bytes_b64', () async {
|
||||
final spawn = await call('pane.spawn', {
|
||||
'argv': const ['/bin/cat'],
|
||||
'ptyc_path': ptycPath,
|
||||
'ptyc_path': toolchain.ptyc,
|
||||
});
|
||||
final id = spawn.data['id']! as String;
|
||||
|
||||
@@ -98,7 +98,7 @@ void main() {
|
||||
test('pane.resize + pane.close + pane.focus round-trip', () async {
|
||||
final spawn = await call('pane.spawn', {
|
||||
'argv': const ['/bin/cat'],
|
||||
'ptyc_path': ptycPath,
|
||||
'ptyc_path': toolchain.ptyc,
|
||||
});
|
||||
final id = spawn.data['id']! as String;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide/kernel/src/toolchain.dart';
|
||||
import 'package:clide/src/daemon/pql_commands.dart';
|
||||
import 'package:clide/src/pql/client.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -10,7 +11,9 @@ void main() {
|
||||
late PqlClient pql;
|
||||
|
||||
setUp(() {
|
||||
pql = PqlClient(workDir: Directory.current);
|
||||
final toolchain = Toolchain();
|
||||
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: Directory.current.path));
|
||||
pql = PqlClient(workDir: Directory.current, toolchain: toolchain);
|
||||
dispatcher = DaemonDispatcher();
|
||||
registerPqlCommands(dispatcher, pql);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user