Files
buzz/desktop/src/testing/e2eBridgeSearch.test.mjs
Salman Mohammed 59328d5ae3 feat(desktop): add thread-scoped ACP session experiment (#6909)
## Why

Thread-scoped ACP sessions from #6732 need an opt-in desktop rollout
that preserves today’s channel policy by default.

## What

- Add the default-off “Thread Scoped ACP Sessions” toggle under Settings
→ Experiments using the existing feature-override persistence.
- Map the persisted setting to `BUZZ_ACP_SESSION_POLICY=channel|thread`
for every local and provider-backed managed ACP launch. Changes apply
when managed agents next start; DMs remain conversation-scoped by the
backend.
- Keep the desktop setting authoritative over descriptor environment and
cover the UI, persistence, local spawn, provider payload, and existing
Projects/Workflows experiments.

## Risk Assessment

Low. The experiment defaults off and explicitly preserves `channel`;
changes are limited to managed-agent launch configuration. Existing
running agents are unchanged until their next start.

## Testing

- `. ./bin/activate-hermit && just ci` — passed on the final restacked
tree, including 5,674 desktop tests, 2,796 Tauri tests, and 1,860 mobile
tests.
- `cd desktop && pnpm build:e2e && pnpm exec playwright test
tests/e2e/experimental-features.spec.ts --project=smoke` — 1 passed.
- `. ./bin/activate-hermit && cargo test --manifest-path
desktop/src-tauri/Cargo.toml session_policy --lib` — 4 passed.
- `. ./bin/activate-hermit && cargo test --manifest-path
desktop/src-tauri/Cargo.toml commands::agents::deploy::tests --lib` — 15
passed.
- `. ./bin/activate-hermit && cargo test -p buzz-backend-kubernetes
--test wire_fixtures` — 4 passed.

## Stack Info

Stacked on #6732. This PR depends on #6732 and should merge after it.

Generated with Codex

---------

Signed-off-by: Salman Mohammed <smohammed@squareup.com>
Signed-off-by: Leo <5faf251baee50ee6bcde338aef6acdd70bb3e60115664c2cd490d94a55dfc488@buzz.block.builderlab.xyz>
Co-authored-by: Leo <5faf251baee50ee6bcde338aef6acdd70bb3e60115664c2cd490d94a55dfc488@buzz.block.builderlab.xyz>
2026-09-01 08:37:27 -05:00

82 lines
2.3 KiB
JavaScript

/**
* Unit tests for the e2e bridge's mock `search_messages` predicate.
*
* The mock stands in for the relay in identity-less E2E runs, so its `since` /
* `until` comparators must match the relay's inclusive NIP-01 bounds
* (`crates/buzz-core/src/filter.rs` keeps `since <= created_at <= until`).
* `before:YYYY-MM-DD` gets its exclusivity from `parseSearchOperators`, which
* emits `localMidnight - 1`; a mock that also excluded its own bound would
* drop the last second of the range that production returns.
*/
import assert from "node:assert/strict";
import test from "node:test";
import { mockSearchHitMatches } from "./e2eBridgeSearch.ts";
const NO_FILTERS = { query: "", authorSet: null };
function hitAt(created_at) {
return {
event_id: "hit",
content: "deploy notes",
kind: 9,
pubkey: "a".repeat(64),
channel_id: "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50",
channel_name: "general",
created_at,
score: 1,
};
}
test("until is inclusive, so a before: bound keeps its own second", () => {
const localMidnight = Math.floor(new Date(2024, 1, 1).getTime() / 1000);
// What parseSearchOperators emits for `before:2024-02-01`.
const until = localMidnight - 1;
assert.equal(
mockSearchHitMatches(hitAt(until), { ...NO_FILTERS, until }),
true,
);
assert.equal(
mockSearchHitMatches(hitAt(localMidnight), { ...NO_FILTERS, until }),
false,
);
});
test("since is inclusive and excludes only earlier timestamps", () => {
const since = Math.floor(new Date(2024, 0, 15).getTime() / 1000);
assert.equal(
mockSearchHitMatches(hitAt(since), { ...NO_FILTERS, since }),
true,
);
assert.equal(
mockSearchHitMatches(hitAt(since - 1), { ...NO_FILTERS, since }),
false,
);
});
test("channel, author, and text filters still narrow results", () => {
const hit = hitAt(1_700_000_000);
assert.equal(
mockSearchHitMatches(hit, { ...NO_FILTERS, channelId: "other-channel" }),
false,
);
assert.equal(
mockSearchHitMatches(hit, {
...NO_FILTERS,
authorSet: new Set(["b".repeat(64)]),
}),
false,
);
assert.equal(
mockSearchHitMatches(hit, { query: "zzz", authorSet: null }),
false,
);
assert.equal(
mockSearchHitMatches(hit, { query: "deploy", authorSet: null }),
true,
);
});