forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'worktree-agent-a7e2dece8fc2fdc01'

Browse files at this commit

3673e65a29fa71cf4ea5a5c3d711d6824cec6f40Ahmet Kaan GümüşParent: 4710509034b772
crates/app/src/player/cards.rsmodified+11 -0
@@ -1836,6 +1836,17 @@ impl Player {
1836 "c" => self.cycle_export_picture(),1836 "c" => self.cycle_export_picture(),
1837 "b" => self.cycle_audio_kbps(),1837 "b" => self.cycle_audio_kbps(),
1838 "g" => self.cycle_encoder(cx),1838 "g" => self.cycle_encoder(cx),
1839+ // The Level row's own three, and they have to be *here*:
1840+ // this page counts as a card in [`Self::card_open`], so a
1841+ // stroke that falls through this branch is swallowed by the
1842+ // darkroom's modal guard rather than reaching the keymap --
1843+ // `m` did nothing at all with the page up (caught in the
1844+ // harness, not by a guard). Same setter the keymap's
1845+ // [`ActionId::ToggleMute`]/`VolumeUp`/`VolumeDown` call, so
1846+ // the row cannot drift from the chord it wears.
1847+ "m" => self.set_volume(|volume| volume.muted = !volume.muted, cx),
1848+ "=" => self.set_volume(|volume| volume.step(true), cx),
1849+ "-" => self.set_volume(|volume| volume.step(false), cx),
1839 _ => return false,1850 _ => return false,
1840 }1851 }
1841 return true;1852 return true;
crates/app/src/tests/layout.rsmodified+100 -12
@@ -2564,18 +2564,6 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
2564 ActionId::Loop,2564 ActionId::Loop,
2565 "KEYS tab + key: the loop toggle left the band in cleanse round 2",2565 "KEYS tab + key: the loop toggle left the band in cleanse round 2",
2566 ),2566 ),
2567- (
2568- ActionId::ToggleMute,
2569- "KEYS tab + key: the monitoring cluster left the band in cleanse round 2",
2570- ),
2571- (
2572- ActionId::VolumeUp,
2573- "KEYS tab + key: the monitoring cluster left the band in cleanse round 2",
2574- ),
2575- (
2576- ActionId::VolumeDown,
2577- "KEYS tab + key: the monitoring cluster left the band in cleanse round 2",
2578- ),
2579 (2567 (
2580 ActionId::ClearRange,2568 ActionId::ClearRange,
2581 "KEYS tab + key: `I O ×` left the band in cleanse round 2 -- in and out \2569 "KEYS tab + key: `I O ×` left the band in cleanse round 2 -- in and out \
@@ -3914,3 +3902,103 @@ fn no_region_root_wears_a_focus_ring() {
3914 }3902 }
3915 }3903 }
3916 }3904 }
3905+
3906+
3907+/// The monitoring level's home. Cleanse round 2 took the mute button, the
3908+/// `- +` pair and the slider off the time band on the promise that the level
3909+/// "lives in Settings" (DESIGN 5) -- a promise nothing kept until this row,
3910+/// which is why the volume trio sat in
3911+/// [`every_action_has_a_darkroom_widget_home_or_explicit_owner`]'s exemption
3912+/// list. A source scan, like every other guard on this page: the EDITOR
3913+/// section carries the row, the row wears the mute chord (`m`), and the wheel
3914+/// over it moves the level through the very actions the keys do -- no second
3915+/// setter, no slider growing back.
3916+#[test]
3917+fn the_editor_section_owns_the_monitoring_level_row() {
3918+ let source = src_text("ui/settings_stance.rs");
3919+ let editor_start = source
3920+ .find("fn editor_section(")
3921+ .expect("the editor section");
3922+ let render_start = source
3923+ .find("pub(crate) fn render(")
3924+ .expect("the page's render fn");
3925+ let editor_body = &source[editor_start..render_start];
3926+ for needle in [
3927+ "\"settings-level\"",
3928+ "\"Level\"",
3929+ "ActionId::ToggleMute",
3930+ "ActionId::VolumeUp",
3931+ "ActionId::VolumeDown",
3932+ ".on_scroll_wheel(",
3933+ ] {
3934+ assert!(
3935+ editor_body.contains(needle),
3936+ "the EDITOR section's Level row is missing {needle}"
3937+ );
3938+ }
3939+ // The chord the row draws is the keymap's own, so the badge reads `m`
3940+ // wherever this test's reader looks for it.
3941+ assert_eq!(
3942+ crate::keymap::Keymap::defaults().chord(crate::ActionId::ToggleMute),
3943+ "m",
3944+ "the mute chord moved -- the Level row's badge is no longer `m`"
3945+ );
3946+ // Muted reads as a word in the quieter ink, never as `0%`: the level is
3947+ // what unmuting comes back to and the row must not lie about it.
3948+ assert!(
3949+ editor_body.contains("\"muted\".to_string()"),
3950+ "the Level row must say `muted` rather than a number when silenced"
3951+ );
3952+ // A readout, not a widget: the slider stayed dead (DESIGN 5).
3953+ assert!(
3954+ !editor_body.contains("volume_bar") && !editor_body.contains("drag_volume"),
3955+ "the level slider grew back in Settings"
3956+ );
3957+ // The page counts as a card ([`Player::card_open`]), so the darkroom's
3958+ // modal guard eats every stroke this branch does not answer: without
3959+ // these three arms the row wears a chord that does nothing while the page
3960+ // is the visible thing on screen (what the first harness run showed).
3961+ let cards = src_text("player/cards.rs");
3962+ let branch_start = cards
3963+ .find("if self.settings_open {")
3964+ .expect("the settings key branch");
3965+ let branch = &cards[branch_start..(branch_start + 1600).min(cards.len())];
3966+ for arm in ["\"m\" =>", "\"=\" =>", "\"-\" =>"] {
3967+ assert!(
3968+ branch.contains(arm),
3969+ "the settings key branch does not answer {arm} -- the Level row's \
3970+ chord is swallowed by the modal guard while the page is up"
3971+ );
3972+ }
3973+}
3974+
3975+/// The wheel's own arithmetic: one notch is one key press (5%), and the count
3976+/// stops at both ends rather than wrapping silence into full volume -- the
3977+/// saturating pair [`Volume::step`] is written for. Pure, so it runs without
3978+/// a window.
3979+#[test]
3980+fn the_level_wheel_steps_five_percent_and_clamps_at_both_ends() {
3981+ use crate::transport::Volume;
3982+ let mut volume = Volume::default();
3983+ assert_eq!(volume.percent(), 100);
3984+ for expected in [95, 90, 85, 80] {
3985+ volume.step(false);
3986+ assert_eq!(volume.percent(), expected, "a notch down is 5%");
3987+ }
3988+ for _ in 0..40 {
3989+ volume.step(false);
3990+ }
3991+ assert_eq!(volume.percent(), 0, "the level floors at silence");
3992+ volume.step(false);
3993+ assert_eq!(volume.percent(), 0, "a notch below silence is silence");
3994+ for _ in 0..40 {
3995+ volume.step(true);
3996+ }
3997+ assert_eq!(volume.percent(), 100, "the level ceilings at full");
3998+ volume.step(true);
3999+ assert_eq!(volume.percent(), 100, "a notch above full is full");
4000+ // Turning it down while muted is not what makes sound come out.
4001+ volume.muted = true;
4002+ volume.step(false);
4003+ assert!(volume.muted && volume.percent() == 95);
4004+}
crates/app/src/transport.rsmodified+8 -1
@@ -77,12 +77,19 @@ impl Volume {
77 f32::from(self.steps) / f32::from(Self::MAX_STEPS)77 f32::from(self.steps) / f32::from(Self::MAX_STEPS)
78 }78 }
79 79
80+ /// The level as a number to read out, 0..=100 -- what the settings page's
81+ /// Level row says (`100%`), the one place the level is written since the
82+ /// time band lost its slider.
83+ pub(crate) fn percent(self) -> u32 {
84+ u32::from(self.steps) * 100 / u32::from(Self::MAX_STEPS)
85+ }
86+
80 /// What the button read before the mute state became a glyph and a colour87 /// What the button read before the mute state became a glyph and a colour
81 /// ([`Player::toolbar`]): the guards still hold the wording to it, so it88 /// ([`Player::toolbar`]): the guards still hold the wording to it, so it
82 /// sits with them rather than in the binary.89 /// sits with them rather than in the binary.
83 #[cfg(test)]90 #[cfg(test)]
84 pub(crate) fn label(self) -> String {91 pub(crate) fn label(self) -> String {
85- let percent = u32::from(self.steps) * 100 / u32::from(Self::MAX_STEPS);92+ let percent = self.percent();
86 if self.muted {93 if self.muted {
87 format!("Muted {percent}%")94 format!("Muted {percent}%")
88 } else {95 } else {
crates/app/src/ui/settings_stance.rsmodified+53 -0
@@ -406,6 +406,59 @@ fn editor_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
406 .flex_col()406 .flex_col()
407 .gap(px(2.))407 .gap(px(2.))
408 .child(section_head("EDITOR · this machine, this window"))408 .child(section_head("EDITOR · this machine, this window"))
409+ // The monitoring level, which lost its slider when the time band was
410+ // cleansed (DESIGN §5 -- "the level lives in Settings"). A readout and
411+ // not a widget: the number is spent rarely, so the wheel over the row
412+ // moves it and `m` silences it, exactly what the keys already do
413+ // ([`ActionId::VolumeUp`]/[`ActionId::VolumeDown`] reach the same
414+ // setter while this page is up, since the settings key branch passes
415+ // every stroke but its own three through to the keymap). Session-only:
416+ // nothing in ~/.config/edith holds a level, and a muted window that
417+ // stayed muted across a launch is a bug report, not a preference.
418+ .child(
419+ div()
420+ .id("settings-level-wheel")
421+ .flex_none()
422+ .on_scroll_wheel(cx.listener(
423+ |this, event: &ScrollWheelEvent, window, cx| {
424+ let by = wheel_delta(event);
425+ if by == 0. {
426+ return;
427+ }
428+ // One notch is one press: the wheel lands on the same
429+ // 5% grid the keys do, never a second finer one.
430+ this.act(
431+ if by > 0. {
432+ ActionId::VolumeUp
433+ } else {
434+ ActionId::VolumeDown
435+ },
436+ window,
437+ cx,
438+ );
439+ cx.stop_propagation();
440+ },
441+ ))
442+ .child(row_full(
443+ "settings-level",
444+ "Level",
445+ match player.volume.muted {
446+ true => "muted".to_string(),
447+ false => format!("{}%", player.volume.percent()),
448+ },
449+ "Monitoring level -- the wheel over this row moves it 5% at a time; kept for this window, never written into a project",
450+ Some(player.keymap.chord(ActionId::ToggleMute).into()),
451+ None,
452+ player,
453+ cx.listener(|this, _: &ClickEvent, _, cx| {
454+ this.set_volume(|volume| volume.muted = !volume.muted, cx)
455+ }),
456+ match player.volume.muted {
457+ true => INK3(),
458+ false => INK1(),
459+ },
460+ )),
461+ )
409 .child(row_keyed(462 .child(row_keyed(
410 "settings-proxies",463 "settings-proxies",
411 "Proxies",464 "Proxies",