Skip to content

Conversation

@LilithSilver
Copy link
Collaborator

@LilithSilver LilithSilver commented Nov 20, 2025

Problem

Currently, the UI is very tightly coupled with the underlying implementation of GodotProject. The UI is directly responsible for control and sometimes syncing logic. Not good!

This means any extraneous UI refreshes come with a backend performance penalty.

Instead, this PR encapsulates GDScript-visible APIs as much as possible, and moves as much core functionality to Rust as possible.

API Architecture

As such, a new file godot_project_api.rs defines a trait (name negotiable):

trait GodotProjectViewModel {}

The GodotProjectViewModel provides a Rust API that any UI can communicate with, to do atomic (or as atomic-as-possible) user interactions on the project.

GodotProject exactly wraps this Rust API, converting everything to Godot-compatible data. (Unfortunately I don't think #[godot_api] supports custom traits, or I'd make that one into a trait too, to ensure API agreement).

String ID deprecation

Also in this PR, I'm phasing out usage of String in lieu of ex. DocumentId and ChangeHash across the codebase. That way, parameters are converted to and from a String when absolutely necessary (i.e. when we're talking to the UI) but most of the time they use the more type-safe (and much faster) version.

Change Caching

Another important piece: changes are now cached per update. Rather than the UI calling the expensive get_changes() directly, GodotProjectImpl can simply ingest_changes() whenever it thinks there are new changes to ingest, and notify the UI to refresh.

As a result, we no longer have to worry about efficiency on the UI side: we can just call Rust methods whenever we need data to display.

Async/Await

Much of the UI code has been refactored, so I removed a lot of the old callback approach and added await.

User-Facing Changes

While the focus of this PR isn't to edit any functionality, some has been altered for clarity or simplicity:

  • The initial prompt to create a branch is gone, now, since it was bad UI.
  • Rather than displaying the branch diff, when a setup commit is selected, the diff panel will inform that there is no valid diff.

To-Do

To get this PR out of draft...

  • Get initial feedback from Nikita on architecture
  • Ensure diff refactor doesn't explode if I start touching diffs
  • Add more API methods/move more stuff from GDScript to Rust
  • Figure out folder/module structure. Probably spinning GodotProject into a submodule. (maybe a separate submodule for the Godot-visible API versus the rust API -- that feels good.)
  • Regressions
    • Initial commits aren't disabled anymore
    • Diff hovers broken
    • Perf/logging regressions: lots of erroneous UI updates, especially on startup. Debounce that and remove "tried to get checked out branch state when nothing is checked out" probably

if not check_and_prompt_for_user_name(self._check_for_user_branch):
return

# todo: miserable UI that waits 5 seconds before nagging the user to make a branch, make better
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should just remove this feature entirely. It adds more confusion than it helps

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.

3 participants