anitnilay20 / anitnilay20/thoth

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

Abierto
#97 0 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Rust
Estrellas
70
Forks
5
Merge medio
10 h 33 min
PR fusionados (30 d)
2

Descripción

## 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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.