Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to AntD TreeTable and remove deprecated code #32

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

haydar-metin
Copy link
Contributor

@haydar-metin haydar-metin commented Nov 28, 2024

Closes #27

TreeTable.mp4

Tree

This PR removes the PrimeReact Tree and TreeTable, as well as the VSCode Tree. Instead, it introduces the Ant Design (AntD) Tree Table, which is allows virtualization and provides a simpler API. Alongside this, all deprecated code has been removed, ensuring the project now exclusively uses the new component.

Model

One major issue with the slow rendering was the back-and-forth communication between the VSCode extension and the webview. To address this, the peripheral model structure has been separated into three layers:

  • Peripheral Model (e.g., PeripheralNode): Handles data loading and updating.
  • Serialization Model (e.g., PeripheralNodeDTO): Contains the serialized data of the peripheral model, which is transferred to the webview.
  • Display Model (e.g., CDTTreeItem): Renders the tree table in the webview.

UI-specific aspects have been moved to a custom converter (e.g., PeripheralNodeConverter). This converter uses the serialized data to create the tree for rendering (Serialization Model -> Display Model).

The webview only sees the Serialization Model / Display Model.

Communication

UI-specific actions like expansion and pinning are handled directly in the webview, which updates the display model immediately. However, these updates are also propagated back to the extension to update the domain model when needed.

The webview can request a resync if necessary. In such cases, after an action is triggered, the entire serialized domain model is sent back to the webview to recreate the display model.

This means expansion happens instantly, and if any data changes, the extension can sync the local model accordingly.

Follow-up

  1. I’ve tried to be as cautious as possible and avoided changing the peripheral model too much. It still includes "pinned" and "expansion" properties for now, but we should consider removing these in a follow-up PR.

  2. While the tree feels smoother now, there’s still room for improvement. For instance, caching the peripheral models and serializing only the changes could make it even faster.

  3. Instead of saving the expanded/pinned state directly in the Peripheral Model. We should move it to a custom service.

  4. Most of the commands are not necessary anymore (e.g., Pin, Set Format). We should remove them and handle those cases directly in the webview. For example, we could show a context menu with the different formats instead of using the VSCode quick select.

PS: Most of the changes are moving functionality around.

Copy link
Contributor

@jreineckearm jreineckearm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See some comments.

src/common/format.ts Show resolved Hide resolved
src/common/peripheral.ts Show resolved Hide resolved
src/common/vscode.ts Show resolved Hide resolved
src/manifest.ts Show resolved Hide resolved
package.json Show resolved Hide resolved
src/svd-parser.ts Show resolved Hide resolved
@jreineckearm
Copy link
Contributor

One finding from testing:

  • I see this behavior if I reduce the width of the panel so that there is not enough space to show all text of the name column:
    image

@jreineckearm
Copy link
Contributor

Some more findings:

  • With the original TreeView implementation it was possible to navigate via the keyboard. And hence to select a node. We should try to restore that. This may also help with navigating the tree in combination with the search functionality.
  • We have now two additional context menu entries Undo and Redo (compared to TreeView implementation). What history would these use? Only user input? Or also values from updates due to executing code? We might want to consider removing those for the time being. If they haven't been added by purpose.
  • The display of pinned values looks slightly different (compared to the TreeView and the PrimeReact implementation). Is it possible to remove the extra node by adding the pin icon inline?
    Before
    image
    After
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider Ant Design Table as UI Framework
3 participants