anitnilay20 / anitnilay20/thoth

feat(plugins): event routing for file-viewer custom-cell widgets

Đang mở
#97 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Rust
Star
70
Fork
5
Merge trung bình
10 giờ 33 phút
Pull request đã merge (30 ngày)
2

Mô tả

## Summary

File-viewer plugins (capability `file-viewer`) render record rows via `render-record`, and in **Custom** display mode each row is a serialized `RenderNode` tree drawn by the host (see `PluginTableViewer` → `TableView::show_rows`). Those rows can contain **interactive** widgets (buttons, inputs, toggles, …), but there is currently **no path to deliver their events back to the plugin** — so a file-viewer's custom cells are effectively read-only.

Surfaced during the #96 review (`src/components/file_viewer/plugin_table_viewer.rs`, ~97–150): the `RenderNode` cells are rendered with a throwaway event sink (`&mut Vec::new()`), and `FileType` / the `FileFormatViewer` trait expose no `handle_event` analogous to the `ui-component` / `data-source` plugins.

## Why it was deferred

The SDK migration (#96) intentionally left this out — it's a cross-cutting feature, not a minimal review fix. There is also no existing consumer: today's bundled viewers only display records.

## Scope / proposed work

Thread a real event channel through the file-viewer path so custom-cell widget events round-trip to the plugin:

1. **WIT**: add a `handle-event` (or `handle-record-event`) export to the `file-viewer` interface (mirroring `ui-component`'s `handle-event(ui-event) -> ui-output`), carrying the `UiEvent { widget_id, kind, value }` plus the record index/row context.
2. **Host**: thread a `&mut Vec` sink through `FileFormatViewer::render` (and the 3 impls + `viewer_trait`/`mod.rs`), collect events from `TableView::show_rows`/custom cells, and dispatch them to the loader, then re-render the affected row(s).
3. **Loader API**: add the corresponding method to `FileType` / the wasm file-viewer loader to forward events to the plugin and apply the returned node update.
4. **SDK/docs**: document the file-viewer event flow in `docs/PLUGIN_SYSTEM.md`; consider a small example in a bundled plugin.

## Acceptance

- A `file-viewer` plugin can render an interactive widget in a Custom-mode cell, receive its event, mutate state, and have the cell re-render.
- Existing read-only viewers are unaffected (no behavior change when a plugin doesn't implement the new export).

Follow-up from #96.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.