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 @@ -17,6 +17,8 @@ export const acpAgentsConfigAppearanceDescriptor: AppearanceSurfaceDescriptor =
{ id: 'status' },
{ id: 'confirmation' },
{ id: 'remoteList' },
{ id: 'hiddenRemoteList' },
{ id: 'hiddenRemoteRow' },
{ id: 'remoteServer' },
{ id: 'remoteHeader' },
{ id: 'remoteAgents' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,29 @@
gap: $size-gap-3;
}

&__hidden-remote-list {
display: flex;
flex-direction: column;
margin-top: $size-gap-3;
overflow: hidden;
border: 1px solid var(--bf-appearance-token-border-subtle);
border-radius: $size-radius-base;
}

&__hidden-remote-row {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: $size-gap-3;
align-items: center;
min-width: 0;
padding: $size-gap-3;
border-bottom: 1px solid var(--bf-appearance-token-border-subtle);

&:last-child {
border-bottom: 0;
}
}

&__remote-server {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -328,7 +351,8 @@
@media (max-width: 860px) {
&__toolbar,
&__registry-row,
&__remote-head {
&__remote-head,
&__hidden-remote-row {
grid-template-columns: 1fr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ vi.mock('@/component-library', () => ({
{children}
</button>
),
IconButton: ({
children,
disabled,
isLoading,
onClick,
tooltip: _tooltip,
...props
}: React.ButtonHTMLAttributes<HTMLButtonElement> & {
children: React.ReactNode;
isLoading?: boolean;
tooltip?: React.ReactNode;
}) => (
<button type="button" disabled={disabled || isLoading} onClick={onClick} {...props}>
{children}
</button>
),
Input: ({
value,
onChange,
Expand Down Expand Up @@ -84,13 +100,18 @@ vi.mock('./common', () => ({
children,
title,
description,
extra,
}: {
children: React.ReactNode;
title: string;
description?: string;
extra?: React.ReactNode;
}) => (
<section>
<h2>{title}</h2>
<div>
<h2>{title}</h2>
{extra}
</div>
{description ? <p>{description}</p> : null}
{children}
</section>
Expand Down Expand Up @@ -141,6 +162,7 @@ describe('AcpAgentsConfig', () => {

beforeEach(() => {
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
localStorage.clear();
loadJsonConfigMock.mockResolvedValue(JSON.stringify({
acpClients: {
opencode: {
Expand Down Expand Up @@ -233,6 +255,116 @@ describe('AcpAgentsConfig', () => {
});
});

it('hides a saved remote server without deleting its SSH connection', async () => {
listSavedConnectionsMock.mockResolvedValue([{
id: 'huawei-server',
name: 'Huawei Server',
host: '119.8.182.138',
port: 22,
username: 'ssh-root',
authType: { type: 'Password' },
}]);

await act(async () => {
root.render(<AcpAgentsConfig />);
});
await act(async () => {
await Promise.resolve();
await Promise.resolve();
});

const hideButton = container.querySelector<HTMLButtonElement>(
'button[aria-label="remote.hideConnection"]'
);
expect(hideButton).not.toBeNull();

await act(async () => {
hideButton?.click();
await Promise.resolve();
});

expect(listSavedConnectionsMock).toHaveBeenCalledTimes(1);
expect(container.textContent).not.toContain('Huawei Server');
expect(JSON.parse(localStorage.getItem('bitfun:settings:acp-agents:hidden-remote-connections:v1') || '[]'))
.toEqual(['huawei-server']);
expect(container.textContent).toContain('remote.showHiddenConnections');
});

it('restores a hidden remote server from the hidden list', async () => {
localStorage.setItem(
'bitfun:settings:acp-agents:hidden-remote-connections:v1',
JSON.stringify(['huawei-server'])
);
listSavedConnectionsMock.mockResolvedValue([{
id: 'huawei-server',
name: 'Huawei Server',
host: '119.8.182.138',
port: 22,
username: 'ssh-root',
authType: { type: 'Password' },
}]);

await act(async () => {
root.render(<AcpAgentsConfig />);
});
await act(async () => {
await Promise.resolve();
await Promise.resolve();
});

const showHiddenButton = Array.from(container.querySelectorAll('button'))
.find(button => button.textContent?.includes('remote.showHiddenConnections'));
expect(showHiddenButton).not.toBeUndefined();

await act(async () => {
showHiddenButton?.click();
await Promise.resolve();
});

const restoreButton = container.querySelector<HTMLButtonElement>(
'button[aria-label="remote.restoreConnection"]'
);
expect(restoreButton).not.toBeNull();

await act(async () => {
restoreButton?.click();
await Promise.resolve();
await Promise.resolve();
});

expect(localStorage.getItem('bitfun:settings:acp-agents:hidden-remote-connections:v1'))
.toBe('[]');
expect(container.textContent).toContain('Huawei Server');
});

it('does not probe hidden remote servers until they are restored', async () => {
localStorage.setItem(
'bitfun:settings:acp-agents:hidden-remote-connections:v1',
JSON.stringify(['huawei-server'])
);
listSavedConnectionsMock.mockResolvedValue([{
id: 'huawei-server',
name: 'Huawei Server',
host: '119.8.182.138',
port: 22,
username: 'ssh-root',
authType: { type: 'Password' },
}]);

await act(async () => {
root.render(<AcpAgentsConfig />);
});
await act(async () => {
await Promise.resolve();
await Promise.resolve();
});

expect(probeClientRequirementsMock).not.toHaveBeenCalledWith({
remoteConnectionId: 'huawei-server',
force: undefined,
});
});

it('configures a preset adapter when the CLI is ready but the ACP layer is missing', async () => {
probeClientRequirementsMock.mockResolvedValue([
{
Expand Down
Loading