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
1 change: 1 addition & 0 deletions frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,7 @@
"ariaLabel": "Pod inspector",
"close": "Close inspector",
"noAgents": "no agents yet",
"addAgent": "Add an agent",
"needsYou": "Needs you",
"nothingOpen": "Nothing open.",
"nothingWorking_one": "Nothing. {{agents}} is working.",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,7 @@
"ariaLabel": "Pod 检视器",
"close": "关闭检视器",
"noAgents": "暂无智能体",
"addAgent": "添加智能体",
"needsYou": "需要你处理",
"nothingOpen": "没有待处理项。",
"nothingWorking_other": "没有需要你处理的事项。{{agents}} 正在工作。",
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/v2/__tests__/V2Inspector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,30 @@ describe('V2Inspector', () => {
expect(mockNavigate).toHaveBeenCalledWith('/v2/agents');
});

// F370 #5: the pod's Agents fold adds an agent with this pod already chosen,
// and only where Bring your own can select it: a member, invites on, and a
// pod that isn't public or DM-shaped.
test('the Agents fold adds an agent to this pod, only where Bring your own can pick it', () => {
const memberId = 'u1';
const withMe = { ...detail, members: [{ _id: memberId, username: 'sam' }] };
const view = renderInspector({ currentUserId: memberId, detail: withMe as any });
fireEvent.click(screen.getByTestId('inspector-add-agent'));
expect(mockNavigate).toHaveBeenCalledWith('/v2/agents/byo?pod=pod-1');
expect(screen.getByTestId('inspector-add-agent')).toHaveTextContent('Add an agent');
view.unmount();
const hidden: Array<Partial<React.ComponentProps<typeof V2Inspector>>> = [
{ currentUserId: memberId, detail: withMe as any, onOpenInvite: undefined },
{ currentUserId: 'not-a-member', detail: withMe as any },
{ currentUserId: memberId, detail: { ...withMe, pod: { ...detail.pod, publicRead: true } } as any },
{ currentUserId: memberId, detail: { ...withMe, pod: { ...detail.pod, type: 'agent-admin' } } as any },
];
hidden.forEach((props) => {
const next = renderInspector(props);
expect(screen.queryByTestId('inspector-add-agent')).toBeNull();
next.unmount();
});
});

test('lists this pod\'s own queue rows even when the global slice misses them', async () => {
mockGet.mockImplementation((url: string) => Promise.resolve(url.startsWith('/api/activity/decision-queue?podId=pod-1')
? { items: [{ id: 'pod-row', kind: 'decision', title: 'Pod-only decision', podId: 'pod-1' }] }
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/v2/chat/chat-inspector.css
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,23 @@
background: var(--v2-surface-hover);
}

/* F370 #5: the add row lines up with the agent rows; its mark is an empty
avatar slot, quieter than a face. */
.v2-root button.v2-workspace-inspector__add-agent { grid-template-columns: 28px minmax(0, 1fr); cursor: pointer; }
.v2-root button.v2-workspace-inspector__add-agent .v2-workspace-inspector__agent-name { color: var(--v2-text-secondary); }
.v2-root button.v2-workspace-inspector__add-agent:hover .v2-workspace-inspector__agent-name { color: var(--v2-text-primary); }
.v2-workspace-inspector__add-agent-mark {
display: inline-flex;
width: 28px;
height: 28px;
box-sizing: border-box;
align-items: center;
justify-content: center;
border: 1px dashed var(--v2-text-muted);
border-radius: 4px;
color: var(--v2-text-secondary);
}

.v2-workspace-inspector__avatar.v2-avatar {
width: 28px;
height: 28px;
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/v2/components/V2Inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ const V2Inspector: React.FC<V2InspectorProps> = ({ detail, currentUserId, onPodC
if (!pod) return null;

const isOwner = Boolean(currentUserId && pod.createdBy?._id === currentUserId);
// F370 #5: offered only where Bring your own can select this pod: a member,
// in a pod that isn't public or a DM-shaped room (V2AgentBYO's pod filter).
const canAddAgent = Boolean(onOpenInvite) && pod.publicRead !== true
&& !['agent-room', 'agent-dm', 'agent-admin'].includes(String(pod.type))
&& Boolean(currentUserId && detail.members.some((member) => member._id === currentUserId));
const changeJoinPolicy = async (next: 'open' | 'invite-only') => {
if (!isOwner || policyBusy || next === joinPolicy) return;
setPolicyBusy(true);
Expand Down Expand Up @@ -472,6 +477,19 @@ const V2Inspector: React.FC<V2InspectorProps> = ({ detail, currentUserId, onPodC
</button>
);
})}
{/* F370 #5: the pod is where a person notices an agent is missing,
so the add path starts here, with this pod already chosen. */}
{canAddAgent && (
<button
type="button"
className="v2-workspace-inspector__agent v2-workspace-inspector__add-agent"
data-testid="inspector-add-agent"
onClick={() => navigate(`/v2/agents/byo?pod=${encodeURIComponent(pod._id)}`)}
>
<span className="v2-workspace-inspector__add-agent-mark" aria-hidden="true"><ShellGlyph name="plus" /></span>
<span className="v2-workspace-inspector__agent-name">{t('inspector.workspace.addAgent')}</span>
</button>
)}
</div>
), agents.length > 0 && (
<span className="v2-workspace-inspector__fold-stack" aria-hidden="true">
Expand Down
Loading