Skip to content

Commit 2f3fa58

Browse files
authored
Polish agent and team sharing and snapshots (#1852)
1 parent c5996e1 commit 2f3fa58

54 files changed

Lines changed: 4192 additions & 3382 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎desktop/playwright.config.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export default defineConfig({
112112
name: "integration",
113113
testMatch: [
114114
"**/agents.spec.ts",
115-
"**/agent-snapshot-send.spec.ts",
116115
"**/agent-snapshot-recipient.spec.ts",
117116
"**/onboarding.spec.ts",
118117
"**/stream.spec.ts",

‎desktop/src-tauri/src/commands/media_download.rs‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,40 @@ pub async fn copy_image_to_clipboard(
223223
.map_err(|_| "clipboard result channel closed unexpectedly".to_string())?
224224
}
225225

226+
/// Write text to the system clipboard through the native shell.
227+
///
228+
/// WebKit can revoke browser clipboard permission after a user action awaits a
229+
/// long-running operation such as snapshot encoding and upload. Keeping the
230+
/// delayed write in the native layer makes that flow reliable on macOS.
231+
#[tauri::command]
232+
pub async fn copy_text_to_clipboard(
233+
text: String,
234+
html: Option<String>,
235+
app: tauri::AppHandle,
236+
) -> Result<(), String> {
237+
let (tx, rx) = std::sync::mpsc::sync_channel::<Result<(), String>>(1);
238+
app.run_on_main_thread(move || {
239+
let result = arboard::Clipboard::new()
240+
.map_err(|e| format!("clipboard error: {e}"))
241+
.and_then(|mut clipboard| {
242+
if let Some(html) = html {
243+
clipboard
244+
.set_html(html, Some(text))
245+
.map_err(|e| format!("clipboard error: {e}"))
246+
} else {
247+
clipboard
248+
.set_text(text)
249+
.map_err(|e| format!("clipboard error: {e}"))
250+
}
251+
});
252+
let _ = tx.send(result);
253+
})
254+
.map_err(|e| format!("main thread dispatch failed: {e}"))?;
255+
256+
rx.recv()
257+
.map_err(|_| "clipboard result channel closed unexpectedly".to_string())?
258+
}
259+
226260
/// Fetch blob bytes from a (pre-validated) relay media URL through the app's
227261
/// HTTP client, enforcing the download size cap. The caller is responsible for
228262
/// validating the URL origin and for any content-type checks on the result.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ pub fn run() {
821821
download_file,
822822
fetch_media_bytes,
823823
copy_image_to_clipboard,
824+
copy_text_to_clipboard,
824825
fetch_snapshot_bytes,
825826
list_relay_members,
826827
get_my_relay_membership,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
4+
import { clearLegacyPersonaCatalogVisibility } from "./legacyPersonaCatalogVisibility.ts";
5+
6+
test("clearLegacyPersonaCatalogVisibility removes the retired preference", () => {
7+
const removedKeys = [];
8+
9+
clearLegacyPersonaCatalogVisibility({
10+
removeItem(key) {
11+
removedKeys.push(key);
12+
},
13+
});
14+
15+
assert.deepEqual(removedKeys, ["buzz-persona-catalog-visibility-v1"]);
16+
});
17+
18+
test("clearLegacyPersonaCatalogVisibility ignores unavailable storage", () => {
19+
assert.doesNotThrow(() => clearLegacyPersonaCatalogVisibility(null));
20+
assert.doesNotThrow(() =>
21+
clearLegacyPersonaCatalogVisibility({
22+
removeItem() {
23+
throw new Error("storage unavailable");
24+
},
25+
}),
26+
);
27+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const LEGACY_PERSONA_CATALOG_VISIBILITY_STORAGE_KEY =
2+
"buzz-persona-catalog-visibility-v1";
3+
4+
/**
5+
* Removes the retired custom-persona catalog preference so it cannot resurface
6+
* agents after the visibility control has been removed.
7+
*/
8+
export function clearLegacyPersonaCatalogVisibility(
9+
storage?: Pick<Storage, "removeItem"> | null,
10+
) {
11+
let targetStorage = storage;
12+
if (targetStorage === undefined) {
13+
if (typeof window === "undefined") return;
14+
15+
try {
16+
targetStorage = window.localStorage;
17+
} catch {
18+
return;
19+
}
20+
}
21+
if (!targetStorage) return;
22+
23+
try {
24+
targetStorage.removeItem(LEGACY_PERSONA_CATALOG_VISIBILITY_STORAGE_KEY);
25+
} catch {
26+
// Catalog cleanup is best-effort and should not block the agents view.
27+
}
28+
}

0 commit comments

Comments
 (0)