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 @@ -57,6 +57,15 @@ const INSTANCE: DaemonChannelInstanceSnapshot = {
runtime: { state: 'stopped' },
};

const PAIRING_INSTANCE: DaemonChannelInstanceSnapshot = {
...INSTANCE,
config: {
...INSTANCE.config,
senderPolicy: 'pairing',
allowedUsers: ['configured-user'],
},
};

const { ChannelEditorDialog } = await import('./ChannelEditorDialog');
const { I18nProvider } = await import('../../i18n');

Expand All @@ -79,6 +88,8 @@ async function renderDialog(
onReload={vi.fn().mockResolvedValue(undefined)}
listPairingRequests={vi.fn().mockResolvedValue({ requests: [] })}
approvePairingRequest={vi.fn()}
listPairingApprovals={vi.fn().mockResolvedValue({ senderIds: [] })}
revokePairingApproval={vi.fn()}
{...props}
/>
</I18nProvider>,
Expand Down Expand Up @@ -237,4 +248,22 @@ describe('ChannelEditorDialog', () => {
);
expect(document.querySelector('[role="dialog"]')).not.toBeNull();
});

it('shows the configured allowlist for a pairing Channel and hides it without one', async () => {
await renderDialog({ instance: PAIRING_INSTANCE });

expect(document.body.textContent).toContain('Configured allowlist');
expect(document.body.textContent).toContain('configured-user');
});

it('does not show the allowlist alert when no users are configured', async () => {
const pairingNoAllowlist: DaemonChannelInstanceSnapshot = {
...INSTANCE,
config: { ...INSTANCE.config, senderPolicy: 'pairing' },
};
await renderDialog({ instance: pairingNoAllowlist });

expect(document.body.textContent).toContain('Pairing approvals');
expect(document.body.textContent).not.toContain('Configured allowlist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import type {
DaemonChannelConfigFieldDescriptor,
DaemonChannelInstanceSnapshot,
DaemonChannelPairingApprovalResult,
DaemonChannelPairingApprovalsSnapshot,
DaemonChannelPairingRequestsSnapshot,
DaemonChannelPairingRevocationResult,
DaemonChannelTypeDescriptor,
DaemonChannelUpsertRequest,
} from '@qwen-code/sdk/daemon';
Expand Down Expand Up @@ -95,6 +97,20 @@ export interface ChannelEditorDialogProps {
name: string,
code: string,
) => Promise<DaemonChannelPairingApprovalResult>;
listPairingApprovals: (
name: string,
) => Promise<DaemonChannelPairingApprovalsSnapshot>;
revokePairingApproval: (
name: string,
senderId: string,
) => Promise<DaemonChannelPairingRevocationResult>;
}

function configuredAllowedUsers(instance?: DaemonChannelInstanceSnapshot) {
const value = instance?.config['allowedUsers'];
return Array.isArray(value)
Comment thread
qwen-code-dev-bot marked this conversation as resolved.
? value.filter((item): item is string => typeof item === 'string')
: [];
}

function FieldShell({
Expand Down Expand Up @@ -146,6 +162,8 @@ export function ChannelEditorDialog({
onReload,
listPairingRequests,
approvePairingRequest,
listPairingApprovals,
revokePairingApproval,
}: ChannelEditorDialogProps) {
const { t } = useI18n();
const formId = useId();
Expand Down Expand Up @@ -537,6 +555,9 @@ export function ChannelEditorDialog({
channelName={instance.name}
listRequests={listPairingRequests}
approveRequest={approvePairingRequest}
listApprovals={listPairingApprovals}
revokeApproval={revokePairingApproval}
staticAllowedUsers={configuredAllowedUsers(instance)}
/>
) : (
<Alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
gap: 4px;
}

.divider {
height: 1px;
margin-block: 2px;
background: var(--border);
}

.success {
display: flex;
align-items: center;
Expand Down Expand Up @@ -91,6 +97,44 @@
background: var(--card);
}

.approval {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 9px 10px;
border: 1px solid var(--border);
border-radius: var(--radius-md);
background: var(--card);
}

.approvalIdentity {
display: flex;
min-width: 0;
align-items: center;
gap: 8px;
}

.approvalIdentity > svg {
width: 15px;
height: 15px;
flex: 0 0 auto;
color: var(--muted-foreground);
}

.approvalSenderId,
.allowlist {
overflow-wrap: anywhere;
font-family: var(--font-mono);
font-size: 11px;
}

.allowlist {
display: block;
margin-top: 5px;
color: var(--foreground);
}

.requestIdentity {
display: flex;
min-width: 0;
Expand Down Expand Up @@ -133,4 +177,9 @@
.requestIdentity {
grid-column: 1 / -1;
}

.approval {
align-items: flex-start;
flex-direction: column;
}
}
Loading
Loading