anitnilay20 / anitnilay20/thoth

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

Aberta
#97 0 comentários 0 reações 0 responsáveis Ver no GitHub
enhancement
Linguagem predominante
Rust
Estrelas
70
Forks
5
Merge médio
10h 33min
PRs com merge (30d)
2

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.