Skip to content

feat(window-wrapper): generic window registry for focus-existing-or-open-new - #19

Merged
devnull03 merged 5 commits into
mainfrom
worktree-asnt-13-window-registry
Jul 11, 2026
Merged

devnull03 merged 5 commits into
mainfrom
worktree-asnt-13-window-registry

Conversation

@devnull03

Copy link
Copy Markdown
Owner

Summary

  • Adds WindowRegistry (crates/window-wrapper) keyed by window-kind string, generalizing the Settings-only SettingsWindowHandle pattern per ASNT-13.
  • WindowRegistry::focus_or_clear also calls Window::activate_window(), so a second open request actually foregrounds the window instead of no-oping.
  • Wires OpenSettings in crates/app/src/main.rs through the new registry; removes SettingsWindowHandle from the settings crate.
  • Ready to reuse for the upcoming Project Creation window (ASNT-15).

Test plan

  • cargo build
  • cargo clippy --all-targets -- -D warnings
  • Manual: cargo run, open Settings twice — confirm the second attempt focuses the existing window instead of duplicating (native GUI, needs a human — not drivable from this session)

devnull03 added 2 commits July 9, 2026 21:57
…or-open-new

Extracts the ad-hoc SettingsWindowHandle pattern into a reusable
WindowRegistry keyed by window-kind, so any window type gets
duplicate-prevention for free. Also fixes focus: reopening an
already-open window now calls Window::activate_window() to bring it
forward, instead of silently no-oping.
…NT-13

Adds crates/app/src/debug.rs: a mock startup window with a button to open
the real main window, and a "Debug: Open Settings + Project" menu action
that opens Settings plus a stub project window together, so WindowRegistry
dedup/focus can be exercised by hand across multiple window kinds at once.
Everything is isolated behind DEBUG comments and marked for removal once
ASNT-13 is manually verified, before ASNT-15 replaces the stub with the
real project-creation wizard.
@devnull03

Copy link
Copy Markdown
Owner Author

Pushed a second commit (17a014b, debug(app): add temporary multi-window manual test scaffolding) on top of this — throwaway scaffolding to manually test the WindowRegistry change end-to-end:

  • cargo run now opens a small mock "project management" window at startup instead of the real main window. Its one button opens the real main window (via a new debug::open_main_window, registered under WindowRegistry too) and closes the mock window.
  • The App menu gets a "Debug: Open Settings + Project" item that opens Settings and a bare-bones project stub window together, so two different WindowRegistry kinds can be exercised live at once.

Everything is isolated in crates/app/src/debug.rs, marked with DEBUG comments at every call site, and meant to be reverted once the manual multi-window check is done (before ASNT-15 lands the real project-creation wizard). Safe to drop this commit independently of aa9755d if you'd rather review the registry change alone.

crate::App (this crate's main window struct) and gpui::App (the context
type) share a name. An explicit `use crate::App` in debug.rs, and an
untyped `&mut App` param in main.rs's extracted open_settings_window,
both silently resolved to the local struct instead of gpui::App since
explicit imports/same-module items win over glob imports regardless of
source order. Fixes it by aliasing the local import and spelling out
gpui::App where needed.
Unrelated to ASNT-13, but was blocking this PR's CI entirely since the
format-check step runs before clippy/build/test and was already failing
on main: rustfmt drift in crates/table (panel.rs, selection.rs) and a
clippy redundant-closure lint in status_items/mod.rs. Verified with the
exact CI command (cargo fmt --all --check, cargo build, cargo clippy
--workspace --all-targets -- -D warnings -A dead_code) — all pass now.
@devnull03
devnull03 marked this pull request as ready for review July 11, 2026 11:34
Copilot AI review requested due to automatic review settings July 11, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a reusable WindowRegistry global (in crates/window-wrapper) to deduplicate “focus existing or open new” behavior across different window kinds (starting with Settings), and updates the app to use it. It also adds temporary debug scaffolding to manually exercise multi-window behavior.

Changes:

  • Added WindowRegistry keyed by window kind, with focus_or_clear that activates an existing window or clears stale handles.
  • Rewired Settings window opening in crates/app/src/main.rs to use WindowRegistry, removing the old Settings-specific global handle from the settings crate.
  • Added debug-only (intended) scaffolding: debug menu action and debug startup window to test multi-window behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/window-wrapper/src/window_registry.rs New global registry for per-kind window handle tracking and focus/clear behavior.
crates/window-wrapper/src/lib.rs Exposes window_registry module and re-exports WindowRegistry.
crates/table/src/selection.rs Formatting change in an if condition (currently not rustfmt-compliant).
crates/table/src/panel.rs Minor refactor/formatting simplification for cx.new(...) call.
crates/settings/src/lib.rs Removes SettingsWindowHandle global in favor of generic registry.
crates/app/src/status_items/mod.rs Minor closure simplification (cx.new(CellLocation::new)).
crates/app/src/main.rs Uses WindowRegistry for Settings; adds debug scaffolding and (currently) changes startup behavior.
crates/app/src/debug.rs New debug scaffolding module for manual multi-window testing.
crates/app/src/app_menus.rs Adds debug menu item (currently unconditional).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to 34
if delegate.editing
== (EditState::Editing {
row: row_ix,
col: col_ix,
})
{
return Input::new(&delegate.editor).into_any_element();
}
Comment thread crates/app/src/main.rs
mod app_menus;
mod app_settings;
mod components;
mod debug; // DEBUG (ASNT-13 manual test scaffolding) — see crates/app/src/debug.rs
Comment thread crates/app/src/main.rs
Comment on lines 22 to 29
use crate::app_settings::build_pages;
use crate::{
actions::{ToggleBottomDock, ToggleLeftDock, ToggleRightDock},
app_menus::{OpenSettings, Quit, app_menus},
debug::register_debug_menu_action, // DEBUG (ASNT-13 manual test scaffolding)
status_items::build_status_bar_registry,
title_items::build_title_bar_registry,
};
Comment on lines +3 to 14
use crate::debug::DebugOpenBoth; // DEBUG (ASNT-13 manual test scaffolding)

actions!(nav, [OpenSettings, Quit]);

pub fn app_menus() -> Vec<Menu> {
vec![Menu {
name: "App".into(),
items: vec![
MenuItem::action("Settings", OpenSettings),
// DEBUG (ASNT-13 manual test scaffolding): remove once ASNT-13 is verified.
MenuItem::action("Debug: Open Settings + Project", DebugOpenBoth),
MenuItem::Separator,
Comment thread crates/app/src/main.rs
Comment on lines +180 to +191
// DEBUG (ASNT-13 manual test scaffolding): opens Settings + a stub
// project window together via the "Debug: Open Settings + Project"
// menu item. See crates/app/src/debug.rs.
register_debug_menu_action(cx);

// DEBUG (ASNT-13 manual test scaffolding): the startup window is a mock
// project-management window instead of the real main window, so the real
// main window, Settings, and the stub project window can all be opened
// independently to test WindowRegistry. Its button calls
// debug::open_main_window. Revert this block to open `App::new` directly
// once ASNT-13 has been manually verified.
let window_options = debug::mock_startup_window_options(cx);
@devnull03
devnull03 merged commit cc9154d into main Jul 11, 2026
3 checks passed
@devnull03
devnull03 deleted the worktree-asnt-13-window-registry branch July 11, 2026 11:52
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.

2 participants