Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,17 @@ describe('registry install — a hosted agent joins with one post', () => {
expect(introPosts()).toHaveLength(1);
expect(introPosts()[0][0].authorKind).toBe('kernel');
});

it('in a personal room, the greeting gets no handle, since plain replies are auto-routed there', async () => {
Pod.findById.mockImplementation(() => {
const doc = { _id: 'pod-1', createdBy: 'user-1', members: ['user-1', 'bot-1'], type: 'agent-room' };
return { ...buildLeanChain(doc), select: () => buildLeanChain(doc) };
});
const res = makeRes();
await installHandler(makeReq('hosted'), res);

expect(res.json).toHaveBeenCalledWith(expect.objectContaining({ success: true }));
expect(mockFireFirstContact).toHaveBeenCalledWith(expect.not.objectContaining({ mentionHandle: expect.anything() }));
expect(mockFireFirstContact).toHaveBeenCalledWith(expect.objectContaining({ hostedAgentUserId: 'bot-1' }));
});
});
6 changes: 5 additions & 1 deletion backend/routes/registry/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const HostedRuntime = require('../../services/hostedRuntimeService');
const HostedEngine = require('../../services/hostedEngine');
const { reservedAgentNameRefusal } = require('../../services/agentNameReservation');
const { normalizeAvatarUrl } = require('../../services/avatarService');
const { isPersonalPodType } = require('../../services/podTypePolicyService');
const {
getUserId,
resolveUsername,
Expand Down Expand Up @@ -871,7 +872,10 @@ installRouter.post('/install', logAgentInstallRefusal('/api/registry/install'),
podId,
installedByUserId: userId,
installerIsAgent: installerUser?.isBot === true,
...(greetsItself ? { mentionHandle: handle } : {}),
// A personal pod (agent-room, agent-dm, agent-admin) auto-routes every
// plain reply to the agent, so the greeting must not tell the person to
// @mention it there. Only a team pod needs the handle.
...(greetsItself && !isPersonalPodType(pod?.type) ? { mentionHandle: handle } : {}),
...(greetsItself ? { hostedAgentUserId: String(agentUser._id) } : {}),
});
} catch (firstContactError: unknown) {
Expand Down
Loading