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

fix: ensures singleworkspace falls back to the name 'default' as expected in all contexts #8228

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

snorrees
Copy link
Contributor

@snorrees snorrees commented Jan 9, 2025

Description

I honestly cant tell you how this slipped through when building Start in Create, but here we go:

Turns out that if you definedConfig({}) without providing a name, then useWorkspace().name will be undefined.

In other contexts, the name will be default (for instance when building the create manifest).

This is not a problem in multi-workspace settings, where name is required for each config. I suspect I've overindexed on testing multi-workspace.

In short, this ensures that resolved workspace summary and unstable_sources gets a name, by setting single workspace name to 'default' as soon as possible, when it is missing.

The bug occurs in WorkspaceLoader, where the values in unstable_sources are spread over the current workspace config (the former had undefined name property, the latter the value 'default')

Some relevant lines:

Current consequence

This bug specifically breaks "Start in Create" integration for single workspace studios without name.

Current workaround: defineConfig({name: 'default, /* everything else */})

More context

After checking what I've used to test, it turns out my single workspace repos all have name: 'default'set in config.

So this has been a problem for templates or configurations that have not set name.
The config we have in the core tempaltes DO have name, but I suspect some of our next templates dont.

What to review

Is there any problems with this approach?
For the record, the return value of useWorkspace().name is defined as required, so from a type perspective this is not a breaking change, but a bugfix.

Testing

The changed unit test breaks if the code change is reverted. I think it covers everything.

Notes for release

N/A

@snorrees snorrees requested review from a team as code owners January 9, 2025 16:04
@snorrees snorrees requested review from RitaDias and removed request for a team January 9, 2025 16:04
Copy link

vercel bot commented Jan 9, 2025

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

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 4:24pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 4:24pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 4:24pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jan 9, 2025 4:24pm
test-next-studio ⬜️ Ignored (Inspect) Jan 9, 2025 4:24pm

Verified

This commit was signed with the committer’s verified signature.
snorrees Snorre Eskeland Brekke
…defined in config for all contexts
@snorrees snorrees force-pushed the default-workspace-name branch from 55a0bb3 to 2b2071d Compare January 9, 2025 16:16
Copy link
Contributor

github-actions bot commented Jan 9, 2025

No changes to documentation

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Component Testing Report Updated Jan 9, 2025 4:26 PM (UTC)

❌ Failed Tests (1) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 7s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 1m 18s 5 0 1
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 51s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 15s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 27s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 7s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 27s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 38s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 13s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 42s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

github-actions bot commented Jan 9, 2025

⚡️ Editor Performance Report

Updated Thu, 09 Jan 2025 16:29:25 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 22.2 efps (45ms) 23.0 efps (44ms) -2ms (-3.3%)
article (body) 42.2 efps (24ms) 42.9 efps (23ms) -0ms (-1.7%)
article (string inside object) 25.6 efps (39ms) 23.3 efps (43ms) +4ms (+10.3%)
article (string inside array) 21.3 efps (47ms) 20.0 efps (50ms) +3ms (+6.4%)
recipe (name) 47.6 efps (21ms) 50.0 efps (20ms) -1ms (-4.8%)
recipe (description) 52.6 efps (19ms) 55.6 efps (18ms) -1ms (-5.3%)
recipe (instructions) 99.9+ efps (7ms) 99.9+ efps (8ms) +1ms (-/-%)
synthetic (title) 19.0 efps (53ms) 18.2 efps (55ms) +3ms (+4.8%)
synthetic (string inside object) 20.0 efps (50ms) 20.8 efps (48ms) -2ms (-4.0%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 45ms 49ms 79ms 480ms 386ms 11.1s
article (body) 24ms 26ms 41ms 194ms 413ms 6.5s
article (string inside object) 39ms 40ms 44ms 56ms 153ms 7.0s
article (string inside array) 47ms 49ms 57ms 89ms 456ms 7.6s
recipe (name) 21ms 23ms 29ms 43ms 0ms 7.2s
recipe (description) 19ms 21ms 23ms 41ms 0ms 4.6s
recipe (instructions) 7ms 8ms 10ms 14ms 0ms 3.2s
synthetic (title) 53ms 57ms 60ms 96ms 539ms 12.1s
synthetic (string inside object) 50ms 54ms 61ms 413ms 1090ms 8.3s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 44ms 74ms 88ms 483ms 1128ms 11.5s
article (body) 23ms 26ms 63ms 193ms 342ms 6.6s
article (string inside object) 43ms 46ms 50ms 93ms 360ms 7.3s
article (string inside array) 50ms 52ms 60ms 88ms 634ms 8.0s
recipe (name) 20ms 22ms 26ms 39ms 0ms 6.9s
recipe (description) 18ms 19ms 21ms 29ms 0ms 4.5s
recipe (instructions) 8ms 9ms 9ms 12ms 0ms 3.2s
synthetic (title) 55ms 61ms 84ms 365ms 1009ms 13.5s
synthetic (string inside object) 48ms 50ms 56ms 391ms 189ms 7.6s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

@snorrees snorrees changed the title Default workspace name fix: ensures singleworkspace falls back to the name 'default' as expected in all contexts Jan 9, 2025
Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Great catch! Thank you @snorrees

@snorrees snorrees added this pull request to the merge queue Jan 10, 2025
Merged via the queue into next with commit fe708e8 Jan 10, 2025
56 of 60 checks passed
@snorrees snorrees deleted the default-workspace-name branch January 10, 2025 09:35
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.

None yet

2 participants