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

Feature: Named views #5532

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

Feature: Named views #5532

wants to merge 37 commits into from

Conversation

nadr0
Copy link
Collaborator

@nadr0 nadr0 commented Feb 26, 2025

relates #4217

Gotchas

  • I need to clean up this branch further
  • This does not work on the current engine since this websocket API is not in production yet. This will fail if you test it on deployed engines.

Issue

  • Unable to easily set default view for user
  • Users cannot share a KCL part with a specific view point
  • Changing default view for users bricks E2E tests or screenshots because the initial view would be different

What this solves

  • We can now have project.toml definitions for NamedViews
  • We can load a NamedView whenever we want.
  • We can change the default view point for users but we can then save the initial view point for all E2E tests and have all the E2E tests safely load that initial view point so tests will not break in place. We should have a way to globally do this for all tests instead of updating each one.
  • We can support sharing a view point with the share KCL url part feature. We can share the part and share the specific viewpoint of the part

Implementation

  • Implemented NamedViews and NamedView on the settings project.toml (per project)
  • Created a NamedView format with _version:1.0 since the websocket API may change in the future if we fix camera related issues within the engine
  • All NamedViews are stored in the per project project.toml. You can share this in github with co workers to all share the same NamedViews
  • Added No results found copy to inputType:options in the command bar. e.g. When you do the command Load named view if you have no view points, it will say no results found since the filtered options is empty. We did this for the commandBar commands but not the options within a command that is "active".
  • Fucked with let value: Configuration = serde_json::from_str(json).map_err(|e| e.to_string())?;.
  • Added 3 new commands
    • Load named view - instantly calls the engine API to load that view point
    • Create named view - calls the engine API to get the camera values then writes it to disk in project.toml
    • Delete named view - deletes that specific viewpoint from project.toml

rabbit hole for serde_json

  • I needed the ability to automatically append metadata (_id, _version) to a NamedView if a user creates one via the Rust execution.
  • I force the json_str to be a Configuration to case it from a Value to the real thing called Configuration which will generate all the default values deeply within the settings which will end up creating my default values of _id and _version for the user automatically.

e.g. The user supplies camera data from the engine but when we write the data to disk in project.toml I want the rust code to automatically append _id: uuid::Uuid::new_v4() and _version:1.0 so the TS side does not need to know about this.

Video demo

2025-02-26.16-27-57.mp4

lol I realized my camera was overlapping the viewpoint when I saved the first one...

Copy link

qa-wolf bot commented Feb 26, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Feb 28, 2025 1:57am

@jessfraz
Copy link
Contributor

one thing ill add is, we have like 150 open bugs, should we really be adding another feature which might break on top...

@Irev-Dev
Copy link
Collaborator

one thing ill add is, we have like 150 open bugs, should we really be adding another feature which might break on top...

fwiw I think this is bug adjacent because it solves problems internal for devs (definitely tests) and has helped reveal a tone of bugs in the engine's camera.

while also solving a problem for users and adding polish.

But of course 100% agree with you we need to crush bugs.

@jessfraz
Copy link
Contributor

yeah fair enough

@lf94 lf94 marked this pull request as ready for review February 28, 2025 01:46
Copy link
Contributor

@lf94 lf94 left a comment

Choose a reason for hiding this comment

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

Played around with it manually and looked working. I specifically was curious about changing themes and then loading the new views, and also duplicate named views.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 97.60479% with 4 lines in your changes missing coverage. Please review.

Project coverage is 86.46%. Comparing base (a0924bc) to head (32243dd).

Files with missing lines Patch % Lines
src/wasm-lib/kcl/src/settings/types/mod.rs 72.72% 3 Missing ⚠️
src/wasm-lib/kcl/src/settings/types/project.rs 99.35% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5532      +/-   ##
==========================================
+ Coverage   86.43%   86.46%   +0.02%     
==========================================
  Files          97       97              
  Lines       37224    37385     +161     
==========================================
+ Hits        32176    32326     +150     
- Misses       5048     5059      +11     
Flag Coverage Δ
wasm-lib 86.46% <97.60%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

5 participants