Skip to content

Commit 419cb99

Browse files
committed
Merge remote-tracking branch 'origin/main' into duncan/guard-public-relay-skills
* origin/main: feat(desktop): close Buzz window with Cmd+W (#6314) refactor(prompt): simplify Buzz agent guidance (#6340) Signed-off-by: Will Pfleger <[email protected]>
2 parents d244921 + e5d1dfe commit 419cb99

6 files changed

Lines changed: 111 additions & 18 deletions

File tree

‎crates/buzz-acp/src/base_prompt.md‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ To assign an issue to someone, run `buzz issues assign --issue <event-id> --repo
3737

3838
## Conversational Agent Creation
3939

40-
When someone asks to create an agent, ask for at most two things: the agent's name and what it should do day-to-day. Turn the user's rough purpose into the `--system-prompt` yourself; do not separately ask for purpose, tone, constraints, access, runtime, provider, or model unless the user's request is genuinely ambiguous.
40+
When someone asks to create an agent, ask for at most two things: its name and what it should do day-to-day. Write the `--system-prompt` yourself. Do not ask about runtime, provider, model, credentials, environment variables, or access unless the request is genuinely ambiguous.
4141

42-
`buzz agents draft-create --channel <current-channel-uuid> --display-name <name> --system-prompt <instructions>`
43-
44-
Use the channel UUID from `[Context]`. Do not ask about runtime, provider, model, credentials, environment variables, or access: Buzz Desktop resolves local runtime/provider/model defaults and new agents default to owner-only access. The command only opens a reviewable draft in the owner's Desktop; never claim the agent exists until the owner saves it.
45-
46-
For explicit changes to an existing personal agent, use `buzz agents draft-update --help`. Draft updates also require owner review and save.
42+
Open an owner-reviewed draft with `buzz agents draft-create --channel <current-channel-uuid> --display-name <name> --system-prompt <instructions>`, using the UUID from `[Context]`. Never claim the agent exists until the owner saves it. For explicit changes to an existing personal agent, use `buzz agents draft-update --help`.
4743

4844
## Communication Patterns
4945

‎crates/buzz-cli/src/lib.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,9 @@ pub enum ChannelsCmd {
582582
/// Channel description
583583
#[arg(long)]
584584
description: Option<String>,
585-
/// Make the channel ephemeral: lifetime in seconds. The relay archives
586-
/// it once this many seconds pass without a new message.
585+
/// Make the channel temporary/ephemeral: idle lifetime in seconds. If
586+
/// omitted, the channel is permanent. The relay archives it once this
587+
/// many seconds pass without a new message.
587588
#[arg(long, value_name = "SECONDS")]
588589
ttl: Option<i64>,
589590
/// Apply a desktop-local channel template by name (case-insensitive):

‎desktop/src-tauri/src/app_menu.rs‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55
//! `close_window` item in both the File and Window submenus, and muda gives
66
//! that item a Cmd+W key equivalent bound to `performClose:`.
77
//!
8-
//! Two consequences, both wrong for Buzz:
8+
//! That default cannot express Buzz's context-dependent behavior:
99
//!
1010
//! 1. `CloseRequested` on the main window is intercepted in `lib.rs` and turned
11-
//! into hide-to-tray, so Cmd+W never closed a window -- it hid the whole
12-
//! app. That is already redundant with Cmd+H (Hide), which stays.
11+
//! into hide-to-tray. Cmd+W should take that path in normal Buzz mode.
1312
//! 2. macOS resolves a menu key equivalent before the webview receives any key
1413
//! event, so Buzz Term could never bind Cmd+W to "close this terminal tab"
1514
//! while the accelerator was claimed here.
1615
//!
1716
//! So this module builds the standard menu minus both `close_window` items.
18-
//! Everything else matches `Menu::default()` deliberately: the goal is to drop
19-
//! one item, not to design a menu.
20-
//!
21-
//! If hide-on-Cmd+W is ever wanted back in Buzz mode, the revisit path is to
22-
//! restore the item and disable it while the terminal owns input (a disabled
23-
//! item does not consume its key equivalent) -- at the cost of an owner->Rust
24-
//! IPC hop this approach does not need.
17+
//! Everything else matches `Menu::default()` deliberately. The webview routes
18+
//! Cmd+W conditionally instead: Buzz Term consumes it in capture phase while
19+
//! it owns input, and `useCloseWindowShortcut` closes the current window in
20+
//! normal Buzz mode.
2521
2622
#[cfg(target_os = "macos")]
2723
use tauri::menu::{

‎desktop/src/app/App.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { deriveShellRoute } from "@/app/AppShell.helpers";
2121
import { ThemeGrainientBackground } from "@/app/ThemeGrainientBackground";
2222
import { CommunityThemeController } from "@/shared/theme/CommunityThemeController";
2323
import { useReloadShortcut } from "@/app/useReloadShortcut";
24+
import { useCloseWindowShortcut } from "@/app/useCloseWindowShortcut";
2425
import { KnownAgentPubkeysProvider } from "@/features/agents/useKnownAgentPubkeys";
2526
import { huddleWindowChannelId } from "@/features/huddle/lib/huddleWindow";
2627
import { useAppOnboardingState } from "@/features/onboarding/hooks";
@@ -769,6 +770,7 @@ function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) {
769770

770771
export function App() {
771772
useReloadShortcut();
773+
useCloseWindowShortcut();
772774
useInitialRenderReady();
773775
const [sharedIdentity, setSharedIdentity] = useState<boolean | null>(null);
774776
const [queryClient] = useState(createBuzzQueryClient);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
4+
import { isCloseWindowShortcut } from "./useCloseWindowShortcut.ts";
5+
6+
function chord(overrides = {}) {
7+
return {
8+
altKey: false,
9+
code: "KeyW",
10+
ctrlKey: false,
11+
defaultPrevented: false,
12+
isComposing: false,
13+
metaKey: true,
14+
repeat: false,
15+
shiftKey: false,
16+
...overrides,
17+
};
18+
}
19+
20+
test("Cmd+W closes a window on macOS", () => {
21+
assert.equal(isCloseWindowShortcut(chord(), true), true);
22+
});
23+
24+
test("the close-window shortcut rejects other platforms and modified chords", () => {
25+
assert.equal(isCloseWindowShortcut(chord(), false), false);
26+
assert.equal(isCloseWindowShortcut(chord({ metaKey: false }), true), false);
27+
assert.equal(isCloseWindowShortcut(chord({ ctrlKey: true }), true), false);
28+
assert.equal(isCloseWindowShortcut(chord({ altKey: true }), true), false);
29+
assert.equal(isCloseWindowShortcut(chord({ shiftKey: true }), true), false);
30+
assert.equal(isCloseWindowShortcut(chord({ code: "KeyQ" }), true), false);
31+
});
32+
33+
test("handled, composing, and repeated events are left alone", () => {
34+
assert.equal(
35+
isCloseWindowShortcut(chord({ defaultPrevented: true }), true),
36+
false,
37+
);
38+
assert.equal(
39+
isCloseWindowShortcut(chord({ isComposing: true }), true),
40+
false,
41+
);
42+
assert.equal(isCloseWindowShortcut(chord({ repeat: true }), true), false);
43+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import * as React from "react";
2+
import { isTauri } from "@tauri-apps/api/core";
3+
import { getCurrentWindow } from "@tauri-apps/api/window";
4+
5+
import { isMacPlatform } from "@/shared/lib/platform";
6+
7+
type CloseWindowChord = Pick<
8+
KeyboardEvent,
9+
| "altKey"
10+
| "code"
11+
| "ctrlKey"
12+
| "defaultPrevented"
13+
| "isComposing"
14+
| "metaKey"
15+
| "repeat"
16+
| "shiftKey"
17+
>;
18+
19+
export function isCloseWindowShortcut(
20+
event: CloseWindowChord,
21+
isMac: boolean,
22+
): boolean {
23+
return (
24+
isMac &&
25+
event.code === "KeyW" &&
26+
event.metaKey &&
27+
!event.ctrlKey &&
28+
!event.altKey &&
29+
!event.shiftKey &&
30+
!event.defaultPrevented &&
31+
!event.isComposing &&
32+
!event.repeat
33+
);
34+
}
35+
36+
/**
37+
* Restores the standard macOS Cmd+W behavior without reclaiming the native
38+
* menu accelerator. Buzz Term handles the chord first in capture phase while
39+
* it owns input; otherwise this bubble-phase listener closes the current
40+
* window. The main window's Rust close handler turns that into hide-to-tray.
41+
*/
42+
export function useCloseWindowShortcut() {
43+
React.useEffect(() => {
44+
if (!isTauri()) return;
45+
46+
function handleKeyDown(event: KeyboardEvent) {
47+
if (!isCloseWindowShortcut(event, isMacPlatform())) return;
48+
event.preventDefault();
49+
void getCurrentWindow().close();
50+
}
51+
52+
window.addEventListener("keydown", handleKeyDown);
53+
return () => window.removeEventListener("keydown", handleKeyDown);
54+
}, []);
55+
}

0 commit comments

Comments
 (0)