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
16 changes: 16 additions & 0 deletions frontend/src/v2/__tests__/V2AgentBYOName.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ afterEach(() => {
});

describe('BYO default agent name follows where it runs', () => {
test('pressing the connect action keeps the name field focused until click', async () => {
mockGet();
renderAt();
await waitFor(() => expect(screen.getByTestId('byo-mode-byo')).toBeInTheDocument());
fireEvent.click(screen.getByTestId('byo-mode-byo'));
const action = screen.getByRole('button', { name: /get my connect command/i });
await waitFor(() => expect(action).toBeEnabled());
nameInput().focus();
expect(nameInput()).toHaveFocus();
expect(fireEvent.mouseDown(action, { cancelable: true })).toBe(false);
expect(nameInput()).toHaveFocus();
const moreWays = screen.getByTestId('byo-more-ways').querySelector('summary');
expect(fireEvent.mouseDown(moreWays, { cancelable: true })).toBe(false);
expect(nameInput()).toHaveFocus();
});

test('reconnect deep link keeps the name and rotates a revoked key with one action', async () => {
mockGet([{ name: 'local', installedBy: 'u1', runtime: { runtimeType: 'webhook' },
connection: { state: 'revoked', lastSeenAt: null } }]);
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/v2/__tests__/v2-layout-invariants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ describe('v2 layout invariants (CSS rule presence)', () => {
expect(ruleBody(v2, '.v2-byo__hint')).toContain('margin: 0');
});

test('BYO field hints take no space until focused or in error', () => {
expect(ruleBody(v2, '.v2-byo__field > .v2-byo__hint')).toContain('display: none');
expect(selectorRuleBody(v2, '.v2-byo__field:focus-within > .v2-byo__hint,\n.v2-byo__field--error > .v2-byo__hint'))
.toContain('display: block');
});

// #2287 (QA BYO walk 1): "Other ways to connect" folds the alternatives so the
// page shows one command, and the needs line is read before the Copy button.
// jsdom cannot see either; sprint-review deleted all three rules and every
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/v2/components/V2AgentBYO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,8 @@ const V2AgentBYO: React.FC = () => {
{t('agentByo.actions.chooseFirst')}
</div>
) : canReconnect ? (
<button type="button" className="v2-byo__submit" disabled={submitting || !podId} onClick={() => {
<button type="button" className="v2-byo__submit" disabled={submitting || !podId}
onMouseDown={(event) => event.preventDefault()} onClick={() => {
if (existingConnection.runtimeType === 'wrapper') void requestMachineReconnect(sanitizeAgentName(name));
else void replaceRunningKey({ agentName: sanitizeAgentName(name), podId });
}}>
Expand All @@ -1210,6 +1211,9 @@ const V2AgentBYO: React.FC = () => {
) : isOtherOwner ? null : (
<button
type="button"
// Keep the focused field's hint visible through the press. If blur
// hides it on mousedown, this button can move before mouseup.
onMouseDown={(event) => event.preventDefault()}
onClick={submit}
disabled={submitting || (mode === 'byo' && !namesReady) || !podId}
className="v2-byo__submit"
Expand All @@ -1224,7 +1228,10 @@ const V2AgentBYO: React.FC = () => {
{/* One command is THE path (QA BYO walk 1): the daemon and the SDK
are real alternatives, but shown as equals beside the button they
read as a choice a stranger has to make before starting. */}
<details className="v2-byo__more" data-testid="byo-more-ways">
<details className="v2-byo__more" data-testid="byo-more-ways"
onMouseDownCapture={(event) => {
if ((event.target as Element).closest('summary, button, a')) event.preventDefault();
}}>
<summary>{t('agentByo.otherWays.title')}</summary>
{machines.length === 0 && (
<div className="v2-byo__add-computer" data-testid="byo-add-computer">
Expand Down
Loading