Skip to content

Commit fae228d

Browse files
committed
feat(ui): click the desktop to take control
View-only desktop connections now escalate to control by clicking anywhere on the desktop stage (transparent overlay button, keyboard accessible, same 'Take control' accessible name). The toolbar button is removed; the connecting status overlay becomes click-through so control can still be requested mid-connect.
1 parent 7235943 commit fae228d

5 files changed

Lines changed: 44 additions & 14 deletions

File tree

‎docs/gateway/cloud-workers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Set `"desktop": true` in a crabbox profile's `settings` to lease worker boxes wi
204204

205205
Operators with `operator.admin` access watch and control the desktop from the Control UI **Desktop** panel (also in the command palette). The panel lists desktop-capable environments from `environments.list`, shows only apps the provider advertised, and launches those apps through `worker.desktop.launch`. It connects through the Gateway, which forwards the box's loopback VNC over the same pinned SSH transport used for worker traffic — the desktop is never exposed on the box's network, and the VNC password is delivered only inside the authenticated `worker.desktop.observe` RPC result, never stored by the Gateway.
206206

207-
Connections start view-only. **Take control** requests an input-capable connection; only one controller is active at a time, and taking control disconnects the previous controller (they are downgraded to view-only). Up to 8 observers can watch one environment. The desktop forward starts on first observe and shuts down about a minute after the last observer disconnects; stopping or reclaiming the environment tears it down immediately.
207+
Connections start view-only. Clicking the desktop takes control (an input-capable connection); only one controller is active at a time, and taking control disconnects the previous controller (they are downgraded to view-only). Up to 8 observers can watch one environment. The desktop forward starts on first observe and shuts down about a minute after the last observer disconnects; stopping or reclaiming the environment tears it down immediately.
208208

209209
The Browser launcher starts one visible Chrome or Chromium process on the worker display with raw CDP bound to `127.0.0.1` and a fresh lease-scoped user-data directory. It does not import cookies, attach the Chrome extension relay, or use Chrome MCP. The operator toolbar and cloud-worker agent share this process. A worker turn receives the normal `browser` tool only when the lease advertises Browser, the bundled Browser plugin is active, and normal tool policy allows `browser`; workers without that capability keep the existing coding-tool catalog. Generic desktop `computer` control is not part of this Labs surface.
210210

‎ui/src/components/desktop/desktop-panel-launcher-styles.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export const desktopPanelLauncherStyles = css`
5555
.desktop-connecting {
5656
position: absolute;
5757
inset: 0;
58+
/* Status overlay only; clicks must reach the take-control surface below. */
59+
pointer-events: none;
5860
display: flex;
5961
align-items: center;
6062
justify-content: center;

‎ui/src/components/desktop/desktop-panel-styles.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,17 @@ export const desktopPanelStyles = css`
161161
inset: 0;
162162
background: var(--bg);
163163
}
164+
/* View-only affordance: clicking anywhere on the desktop takes control. */
165+
.desktop-stage__take-control {
166+
position: absolute;
167+
inset: 0;
168+
border: 0;
169+
padding: 0;
170+
background: transparent;
171+
cursor: pointer;
172+
}
173+
.desktop-stage__take-control:focus-visible {
174+
outline: 2px solid var(--accent, #ff5c5c);
175+
outline-offset: -2px;
176+
}
164177
`;

‎ui/src/components/desktop/desktop-panel.ts‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -596,18 +596,6 @@ class OpenClawDesktopPanel extends OpenClawLitElement {
596596
</div>`
597597
: nothing}
598598
<span class="desktop-toolbar__spacer"></span>
599-
${!this.controlling
600-
? html`<button
601-
class="desktop-toolbar-action"
602-
type="button"
603-
title=${t("desktop.takeControl")}
604-
aria-label=${t("desktop.takeControl")}
605-
@click=${() =>
606-
this.environmentId && void this.connectEnvironment(this.environmentId, true)}
607-
>
608-
${t("desktop.takeControl")}
609-
</button>`
610-
: nothing}
611599
<button
612600
class="desktop-toolbar-action"
613601
type="button"
@@ -620,6 +608,16 @@ class OpenClawDesktopPanel extends OpenClawLitElement {
620608
</div>
621609
<div class="desktop-stage">
622610
<div class="desktop-surface"></div>
611+
${!this.controlling
612+
? html`<button
613+
class="desktop-stage__take-control"
614+
type="button"
615+
title=${t("desktop.takeControl")}
616+
aria-label=${t("desktop.takeControl")}
617+
@click=${() =>
618+
this.environmentId && void this.connectEnvironment(this.environmentId, true)}
619+
></button>`
620+
: nothing}
623621
${this.state === "connecting"
624622
? html`<div class="desktop-connecting" role="status" aria-live="polite">
625623
<span class="desktop-connecting__monitor" aria-hidden="true">${icons.monitor}</span>

‎ui/src/e2e/desktop-panel.e2e.test.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,24 @@ suite.define(() => {
668668
await panel.getByRole("button", { name: "Connect", exact: true }).click();
669669
await expect.poll(async () => (await gateway.getRequests("desktop.observe")).length).toBe(2);
670670

671-
await panel.getByRole("button", { name: "Take control", exact: true }).click();
671+
const takeControl = panel.getByRole("button", { name: "Take control", exact: true });
672+
const overlayCoversStage = await panel.evaluate((element) => {
673+
const stage = element.shadowRoot?.querySelector<HTMLElement>(".desktop-stage");
674+
const overlay = element.shadowRoot?.querySelector<HTMLElement>(
675+
".desktop-stage__take-control",
676+
);
677+
if (!stage || !overlay) {
678+
return false;
679+
}
680+
const stageRect = stage.getBoundingClientRect();
681+
const overlayRect = overlay.getBoundingClientRect();
682+
return (
683+
Math.abs(stageRect.width - overlayRect.width) < 1 &&
684+
Math.abs(stageRect.height - overlayRect.height) < 1
685+
);
686+
});
687+
expect(overlayCoversStage).toBe(true);
688+
await takeControl.click();
672689
await expect.poll(async () => (await gateway.getRequests("desktop.observe")).length).toBe(3);
673690
const observeRequests = await gateway.getRequests("desktop.observe");
674691
expect(observeRequests[2]?.params).toEqual({

0 commit comments

Comments
 (0)