Skip to content

Dylan/feat/reducers editor tool #19

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

Open
wants to merge 245 commits into
base: master
Choose a base branch
from

Conversation

dylanh724
Copy link
Contributor

@dylanh724 dylanh724 commented Mar 4, 2024

About

GUI Reducer listing/calling with prefilled with the CLI-default server/identity (and module name, if cached from previously using the other "Publisher" tool).

image

Why?

With the Publisher tool, we took away numerous CLI burdens and tossed it into a GUI with persistence to remember your prefs.

The effort continues! Less CLI burdens, more GUI, easier onboarding/reducer testing.

Prerequisites

Branched from clockworklabs/com.clockworklabs.spacetimedbsdk#17 - resolve this PR 1st

Feats

  • Get default selected server/identity from CLI and load it into UI @ init

  • Get last-published module Name and load it into a TreeView UI @ init, if any

  • Parses spacetime describe into a model

  • Parses describe into an EntityInfo model with extra info, such as [formatted] syntax hints and more

  • Refresh button, in case we changed something after init

  • "Call Reducer" button for reducers with results shown below

  • UX: Local validation, btn enable/disables on ready/done, progressive UI reveal, btn status labels on click, window wrapped in ScrollView, result labels wrapped in ScrollView (in case of lengthy errs), can dock to editor UI as a tab

  • Minor Publish optimizations (since closely related and templated from)

    • Some fixes, some tweaks, some consistency.
    • Centralized some common elements back to /Common
    • EDIT: --as-identity support
      image
  • Err handling:

    • Implicit #VisualElement name integrity
    • Refer to Publisher tool on server<>identity errs

⚙️ Editor tool only: This won't bloat builds.
⚙️ Tested in Unity 2022.3.20 LTS

Ideas for future PRs:

  1. From Reducer window, have an "Open Publisher Tool" button on identity/server err
  2. From Publisher window, have an "Open Reducers Tool" button on Publish success in the Result Foldout.
  3. Since we parse the entire spacetime describe into a common model, there are likely other fun tools to be made from this.
  4. TreeView supports sub elements, if we ever wanted to do something "extra" with a selected reducer, such as describing what each arg does (if we ever add arg docs within spacetime describe results, for example).
  5. Caching last known set of reducers (but can cause confusion on desyncs).

Testing

  • Tested via Zeke's demo project, which includes pretty much everything- including custom types and deep nested.
  • Currently showing premade funcs like Init; unsure what to do with these:
    image

TODO

  • Add this tool to the README with a GIF
  • Wrap short if() with if(){} (I learned this internal pref later)
  • Emulation support as a player ("bot").
    • Eg: Let's say I want to call the tutorial's chat_message - I get an err response "Player not found"
      image

- Runs cross-platform CLI commands in the background and parses them for friendly results
- Features:
  * Detects and cross-platform installs SpacetimeDB CLI if !detected
  * View list of servers|identities
  * Add server|identity
  * Change server|identity
  * Ensure identities are bound to servers (refresh on server change)
  * FilePicker for publish/to/module path
  * Publish result with DateTime, Host, IsOptimizedBuild
  * Detection of `wasm-opt` for optimization; show install button if !found (in post-publish result cache)
  * Regenerate local|testnet servers if 0 servers found
  * Cleanly-exited Process via cancel token support
  * Progress bars and status labels
  * CLI Error handling
  * Some persistence cache, but we mostly get live updates from the CLI
  * UX: Prettified, responsive design, Local validation, groups, focus/selectAll when applicable, status labels, integrity checks, top banner click links to docs, body wraped in scrollView, fonts and colors match docs
- For future Editor tools that may coincide with Publisher, I added a `Common` dir
- Moved core CLI commands to a common `SpacetimeDbCli.cs`
- Created a "common" USS stylesheet so future editor tools can utilize this with a core, templated style.
  - Set the non-common USS stylesheet as active at the top (custom one *must* be at top, as that's what's default set active)
- Better USS/UXML naming
- Added sanity checks for USS/UXML loading
- For future Editor tools that may coincide with Publisher, I added a `Common` dir
- Moved core CLI commands to a common `SpacetimeDbCli.cs`
- Created a "common" USS stylesheet so future editor tools can utilize this with a core, templated style.
  - Set the non-common USS stylesheet as active at the top (custom one *must* be at top, as that's what's default set active)
- Better USS/UXML naming
- Added sanity checks for USS/UXML loading
- fix: HasIdentitiesButNoDefault + HasServersButNoDefault were resulting in opposite expectations
- Currently has the Publish window template UI; will strip this next commit (keeping what we need)
…ditor-tool

# Conflicts:
#	Scripts/Editor/Common/SpacetimeDbCli/Models/GetIdentitiesResult.cs
#	Scripts/Editor/Common/SpacetimeDbCli/Models/PublishResult.cs
#	Scripts/Editor/Common/SpacetimeDbCli/Models/PublishResult.cs.meta
#	Scripts/Editor/Common/SpacetimeDbCli/Models/PublishServerModuleResult.cs
#	Scripts/Editor/Common/SpacetimeDbCli/Models/PublishServerModuleResult.cs.meta
#	Scripts/Editor/Common/SpacetimeDbCli/SpacetimeDbCli.cs
#	Scripts/Editor/Common/SpacetimeDbCli/SpacetimeDbPublisherCli.cs
#	Scripts/Editor/Common/SpacetimeMeta.cs
#	Scripts/Editor/SpacetimePublisher/PublisherWindowComponents.uxml
#	Scripts/Editor/SpacetimePublisher/Scripts/Models/PublishServerModuleResult.cs
#	Scripts/Editor/SpacetimePublisher/Scripts/Models/PublishServerModuleResult.cs.meta
#	Scripts/Editor/SpacetimePublisher/Scripts/PublisherWindowActions.cs
…ditor-tool

# Conflicts:
#	Scripts/Editor/Common/SpacetimeDbCli/Models/GetIdentitiesResult.cs
#	Scripts/Editor/Common/SpacetimeDbCli/SpacetimeDbPublisherCli.cs
#	Scripts/Editor/SpacetimePublisher/Scripts/PublisherWindowActions.cs
- Pulls data from Publisher, if previously published, to get the default module name.
…ditor-tool

# Conflicts:
#	Scripts/Editor/SpacetimePublisher/Scripts/PublisherWindowActions.cs
- Also fix an async naming/discard convention
…ditor-tool

# Conflicts:
#	Scripts/Editor/SpacetimePublisher/Scripts/PublisherWindowActions.cs
@dylanh724 dylanh724 added the enhancement New feature or request label Mar 4, 2024
@dylanh724 dylanh724 requested review from bfops and jdetter March 4, 2024 02:41
- Plus, remove testing placeholders
- Rn "Call" btn val to "Call Reducer"
- Bring bold back to buttons when done (the orig text restored)
@dylanh724 dylanh724 requested a review from cloutiertyler April 29, 2024 01:53
@jdetter jdetter removed their request for review November 8, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants