zed icon indicating copy to clipboard operation
zed copied to clipboard

Storybook: Picker story is now crashing

Open stormasm opened this issue 1 year ago • 5 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

Picker Story is now crashing and was introduced by #10620

Reason being is that the Picker needs a single line editor which now needs ProjectSettings because of this new line of code added...

 git_blame_inline_enabled: ProjectSettings::get_global(cx).git.inline_blame_enabled(),

But there is no project crate inside the storybook crate...

I can go ahead and add a Project crate dependency to the storybook crate which would be a quick fix / hack.

I don't think the Picker should actually need to depend on a having a Project in the first place...

I have run into this issue before when trying to decouple Project from Workspace...

Workspace => docks / tabs / panes / toolbar / status bars don't really care about Projects...

Any way we can discuss further as I have lots of opinions on this subject and how to decouple Project from other crates --- more tightly coupling Project to storybook is not the right solution...

And from a more global point of view --- developers who want to use the single line editor should not have to have the baggage of a Project 😄

Environment

Zed: v0.131.6 (Zed) OS: macOS 14.2.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

stormasm avatar Apr 18 '24 19:04 stormasm

Choose a story to run:: picker

thread 'main' panicked at /Users/ma/j/tmp08/zed/crates/settings/src/settings_store.rs:262:32:
unregistered setting type project::project_settings::ProjectSettings
stack backtrace:
   0: rust_begin_unwind
             at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/panicking.rs:72:14
   2: <settings::settings_store::SettingsStore>::get::<project::project_settings::ProjectSettings>::{closure#0}
             at /Users/ma/j/tmp08/zed/crates/settings/src/settings_store.rs:262:32
   3: <core::option::Option<&alloc::boxed::Box<dyn settings::settings_store::AnySettingValue>>>::unwrap_or_else::<<settings::settings_store::SettingsStore>::get<project::project_settings::ProjectSettings>::{closure#0}>
             at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/option.rs:976:21
   4: <settings::settings_store::SettingsStore>::get::<project::project_settings::ProjectSettings>
             at /Users/ma/j/tmp08/zed/crates/settings/src/settings_store.rs:260:9
   5: <project::project_settings::ProjectSettings as settings::settings_store::Settings>::get_global
             at /Users/ma/j/tmp08/zed/crates/settings/src/settings_store.rs:70:9
   6: <editor::Editor>::new
             at /Users/ma/j/tmp08/zed/crates/editor/src/editor.rs:1508:39
   7: <editor::Editor>::single_line
             at /Users/ma/j/tmp08/zed/crates/editor/src/editor.rs:1341:9
   8: <picker::head::Head>::editor::<picker::Picker<storybook::stories::picker::Delegate>, <picker::Picker<storybook::stories::picker::Delegate>>::on_input_editor_event>::{closure#0}
             at /Users/ma/j/tmp08/zed/crates/picker/src/head.rs:23:30
   9: <gpui::window::WindowContext as gpui::VisualContext>::new_view::<editor::Editor, <picker::head::Head>::editor<picker::Picker<storybook::stories::picker::Delegate>, <picker::Picker<storybook::stories::picker::Delegate>>::on_input_editor_event>::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/window.rs:1923:22
  10: <gpui::window::ViewContext<picker::Picker<storybook::stories::picker::Delegate>> as gpui::VisualContext>::new_view::<editor::Editor, <picker::head::Head>::editor<picker::Picker<storybook::stories::picker::Delegate>, <picker::Picker<storybook::stories::picker::Delegate>>::on_input_editor_event>::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/window.rs:2552:9
  11: <picker::head::Head>::editor::<picker::Picker<storybook::stories::picker::Delegate>, <picker::Picker<storybook::stories::picker::Delegate>>::on_input_editor_event>
             at /Users/ma/j/tmp08/zed/crates/picker/src/head.rs:22:22
  12: <picker::Picker<storybook::stories::picker::Delegate>>::uniform_list
             at /Users/ma/j/tmp08/zed/crates/picker/src/picker.rs:125:20
  13: <storybook::stories::picker::PickerStory>::new::{closure#0}::{closure#0}
             at ./src/stories/picker.rs:193:34
  14: <gpui::window::WindowContext as gpui::VisualContext>::new_view::<picker::Picker<storybook::stories::picker::Delegate>, <storybook::stories::picker::PickerStory>::new::{closure#0}::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/window.rs:1923:22
  15: <gpui::window::ViewContext<storybook::stories::picker::PickerStory> as gpui::VisualContext>::new_view::<picker::Picker<storybook::stories::picker::Delegate>, <storybook::stories::picker::PickerStory>::new::{closure#0}::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/window.rs:2552:9
  16: <storybook::stories::picker::PickerStory>::new::{closure#0}
             at ./src/stories/picker.rs:139:25
  17: <gpui::window::WindowContext as gpui::VisualContext>::new_view::<storybook::stories::picker::PickerStory, <storybook::stories::picker::PickerStory>::new::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/window.rs:1923:22
  18: <storybook::stories::picker::PickerStory>::new
             at ./src/stories/picker.rs:119:9
  19: <storybook::story_selector::ComponentStory>::story
             at ./src/story_selector.rs:71:29
  20: <storybook::story_selector::StorySelector>::story
             at ./src/story_selector.rs:108:49
  21: storybook::main::{closure#1}::{closure#0}::{closure#0}
             at ./src/storybook.rs:98:52
  22: <gpui::window::WindowContext as gpui::VisualContext>::new_view::<storybook::StoryWrapper, storybook::main::{closure#1}::{closure#0}::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/window.rs:1923:22
  23: storybook::main::{closure#1}::{closure#0}
             at ./src/storybook.rs:98:17
  24: <gpui::app::AppContext>::open_window::<storybook::StoryWrapper, storybook::main::{closure#1}::{closure#0}>::{closure#0}
             at /Users/ma/j/tmp08/zed/crates/gpui/src/app.rs:499:29
  25: <gpui::app::AppContext>::update::<gpui::window::WindowHandle<storybook::StoryWrapper>, <gpui::app::AppContext>::open_window<storybook::StoryWrapper, storybook::main::{closure#1}::{closure#0}>::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/app.rs:363:22
  26: <gpui::app::AppContext>::open_window::<storybook::StoryWrapper, storybook::main::{closure#1}::{closure#0}>
             at /Users/ma/j/tmp08/zed/crates/gpui/src/app.rs:495:9
  27: storybook::main::{closure#1}
             at ./src/storybook.rs:89:23
  28: <gpui::app::App>::run::<storybook::main::{closure#1}>::{closure#0}
             at /Users/ma/j/tmp08/zed/crates/gpui/src/app.rs:144:13
  29: <<gpui::app::App>::run<storybook::main::{closure#1}>::{closure#0} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/ops/function.rs:250:5
  30: <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()>> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2015:9
  31: gpui::platform::mac::platform::did_finish_launching
             at /Users/ma/j/tmp08/zed/crates/gpui/src/platform/mac/platform.rs:1078:13

stormasm avatar Apr 18 '24 19:04 stormasm

Quick fix would be to add the project crate dependency to storybook and add this line of code into storybook.rs

Project::init_settings(cx);

Which I could do but don't think this is the correct long term solution... Please advise (should I do the quick fix for now ?)

stormasm avatar Apr 18 '24 19:04 stormasm

cc: @mrnugget

JosephTLyons avatar Apr 19 '24 20:04 JosephTLyons

I think that's an acceptable solution @stormasm

mikayla-maki avatar Apr 19 '24 20:04 mikayla-maki

I think that's an acceptable solution @stormasm

@mikayla-maki thank you for taking the time to

  • review my suggestion and issue and then
  • giving me the green light to write
  • #10793

stormasm avatar Apr 20 '24 02:04 stormasm

Sorry about that!

mrnugget avatar Apr 22 '24 07:04 mrnugget