Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(web): offer a newly added private Agent in the @ picker

shoudi zheng293f593deccd
diff --git a/apps/web/src/features/rooms/chat/room-projection.test.ts b/apps/web/src/features/rooms/chat/room-projection.test.ts
index c8d5dd24..a3e6c325 100644
--- a/apps/web/src/features/rooms/chat/room-projection.test.ts
+++ b/apps/web/src/features/rooms/chat/room-projection.test.ts
@@ -11,9 +11,11 @@ import type { TeamHubWorkItem } from "@/features/teamhub/teamhub-types";
import {
roomDocumentCommentThreadsQueryKey,
+ roomMembersQueryKey,
roomMessagesQueryKey,
roomTeamMdQueryKey,
tenantActorsQueryKey,
+ tenantAgentAvailabilityQueryKey,
tenantAgentsQueryKey,
} from "../room-queries";
import { createHttpTeamHubClient } from "@/features/teamhub/teamhub-client";
@@ -640,6 +642,49 @@ describe("Room projection", () => {
expect(projection.getLastAppliedRoomSeq()).toBe(1);
});
+ it("refreshes the Agent directory when an Agent joins so the @ picker can offer it", async () => {
+ const queryClient = new QueryClient();
+ const invalidateQueries = vi.spyOn(queryClient, "invalidateQueries");
+ const projection = createRoomProjection({
+ queryClient,
+ roomId: "room-1",
+ tenantId: "tenant-1",
+ });
+
+ await projection.applyEvent(memberAddedEvent("agent"));
+
+ expect(invalidateQueries.mock.calls.map(([filters]) => filters)).toEqual([
+ {
+ queryKey: roomMembersQueryKey("tenant-1", "room-1"),
+ refetchType: "none",
+ },
+ { queryKey: tenantAgentsQueryKey("tenant-1"), refetchType: "none" },
+ {
+ queryKey: tenantAgentAvailabilityQueryKey("tenant-1"),
+ refetchType: "none",
+ },
+ ]);
+ });
+
+ it("refreshes only the members when a human joins", async () => {
+ const queryClient = new QueryClient();
+ const invalidateQueries = vi.spyOn(queryClient, "invalidateQueries");
+ const projection = createRoomProjection({
+ queryClient,
+ roomId: "room-1",
+ tenantId: "tenant-1",
+ });
+
+ await projection.applyEvent(memberAddedEvent("human"));
+
+ expect(invalidateQueries.mock.calls.map(([filters]) => filters)).toEqual([
+ {
+ queryKey: roomMembersQueryKey("tenant-1", "room-1"),
+ refetchType: "none",
+ },
+ ]);
+ });
+
it("leaves the active Room when it is deleted", async () => {
const onRoomAccessInvalidated = vi.fn();
const projection = createRoomProjection({
@@ -668,6 +713,38 @@ describe("Room projection", () => {
});
});
+function memberAddedEvent(kind: "agent" | "human"): TeamHubRoomEvent {
+ return {
+ event_id: "event-member-added",
+ event_type: "room.member.added",
+ occurred_at: "2026-07-23T10:00:00Z",
+ payload: {
+ kind: "room.member.added",
+ member: {
+ actor: {
+ display_name: "New Member",
+ id: "actor-new",
+ kind,
+ tenant_id: "tenant-1",
+ },
+ added_by: {
+ display_name: "Owner",
+ id: "actor-owner",
+ kind: "human",
+ tenant_id: "tenant-1",
+ },
+ joined_at: "2026-07-23T10:00:00Z",
+ role: "member",
+ room_id: "room-1",
+ updated_at: "2026-07-23T10:00:00Z",
+ },
+ },
+ room_id: "room-1",
+ room_seq: 1,
+ tenant_id: "tenant-1",
+ };
+}
+
function compactedEvent() {
return {
event_id: "event-1",
diff --git a/apps/web/src/features/rooms/chat/room-projection.ts b/apps/web/src/features/rooms/chat/room-projection.ts
index 06e77e8c..e95a313b 100644
--- a/apps/web/src/features/rooms/chat/room-projection.ts
+++ b/apps/web/src/features/rooms/chat/room-projection.ts
@@ -29,6 +29,7 @@ import {
roomRoutinesQueryKey,
roomTeamMdQueryKey,
tenantActorsQueryKey,
+ tenantAgentAvailabilityQueryKey,
tenantAgentsQueryKey,
tenantRoomsQueryKey,
} from "../room-queries";
@@ -233,6 +234,24 @@ async function projectEvent(
});
return;
case "room.member.added":
+ await Promise.all([
+ refreshQueriesInBackground(queryClient, {
+ queryKey: roomMembersQueryKey(tenantId, roomId),
+ }),
+ // A private Agent becomes visible in the caller's Agent directory once
+ // it shares a Room with them; the @ picker hides members missing there.
+ ...(payload.member.actor.kind === "agent"
+ ? [
+ refreshQueriesInBackground(queryClient, {
+ queryKey: tenantAgentsQueryKey(tenantId),
+ }),
+ refreshQueriesInBackground(queryClient, {
+ queryKey: tenantAgentAvailabilityQueryKey(tenantId),
+ }),
+ ]
+ : []),
+ ]);
+ return;
case "room.member.role_changed":
await refreshQueriesInBackground(queryClient, {
queryKey: roomMembersQueryKey(tenantId, roomId),