open markdown files in the reader, not the editor

The files panel and the Claude Config tab called ipc.request('editor.open')
for every file, which targets the editor — so a .md click never reached the
right-side markdown reader (it opens only when something publishes
('builtin.markdown','selection')). Route .md clicks from the files panel
(tree + filtered rows), the Config tab's file-backed rows, and .md wiki links
in the viewer to that channel; non-.md files still open in the editor. Also
remove the dead DaemonEvent fallback that listened for 'editor.buffer_activated'
(the registry emits 'editor.active-changed').

T-187.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-31 16:16:34 +02:00
co-authored by Claude
parent 4340dc38d0
commit c56b60622b
7 changed files with 369 additions and 49 deletions
+4 -11
View File
@@ -16,7 +16,6 @@ class _MarkdownViewerState extends State<MarkdownViewer> {
String? _content;
String? _error;
StreamSubscription<Message>? _selectionSub;
StreamSubscription<DaemonEvent>? _editorSub;
@override
void didChangeDependencies() {
@@ -27,20 +26,11 @@ class _MarkdownViewerState extends State<MarkdownViewer> {
final path = msg.data['path'] as String?;
if (path != null) _loadFile(path);
});
_editorSub = kernel.events.on<DaemonEvent>().listen((e) {
if (e.kind == 'editor.buffer_activated') {
final path = e.data['path'] as String?;
if (path != null && path.endsWith('.md')) {
_loadFile(path);
}
}
});
}
@override
void dispose() {
_selectionSub?.cancel();
_editorSub?.cancel();
super.dispose();
}
@@ -62,7 +52,10 @@ class _MarkdownViewerState extends State<MarkdownViewer> {
void _navigateToRecord(BuildContext context, String id) {
final kernel = ClideKernel.of(context);
if (id.startsWith('T-')) {
if (id.toLowerCase().endsWith('.md')) {
// Wiki-link to another .md file — open it in the reader.
kernel.messages.publish('builtin.markdown', 'selection', {'path': id});
} else if (id.startsWith('T-')) {
kernel.messages.publish('builtin.tickets', 'selection', {'id': id});
} else {
kernel.messages.publish('builtin.decisions', 'selection', {'id': id});