Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(spaces): pin Spaces and shared machine desktops to the notch (#6163)
ddupontb269d38db580
diff --git a/apps/cua-spaces-desktop/src/bridge/settings.ts b/apps/cua-spaces-desktop/src/bridge/settings.tsindex 0d263a0c5a..d6edabd716 100644--- a/apps/cua-spaces-desktop/src/bridge/settings.ts+++ b/apps/cua-spaces-desktop/src/bridge/settings.ts@@ -113,6 +113,8 @@ export function settingsState(model: AppModel, parts: HostParts) {runtimes: encode(model.runtimesInput()),// The app core's own settings the page changes (`settings.update`).tips: { off: model.settings.tips.off, done: [...model.settings.tips.done] },+ // The Spaces and machine desktops pinned to the notch, in pin order.+ notchPinned: [...model.settings.notchPinned],};}@@ -126,6 +128,11 @@ export function settingsUpdate(args: Record<string, unknown>): Partial<AppModel[if (typeof off !== "boolean" || !Array.isArray(done) || !done.every((d) => typeof d === "string")) throw Failure.badArgs("tips: {off: boolean, done: string[]}");patch.tips = { off, done: done as string[] };}+ if ("notchPinned" in args) {+ const ids = args.notchPinned;+ if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string")) throw Failure.badArgs("notchPinned: string[]");+ patch.notchPinned = ids as string[];+ }if (!Object.keys(patch).length) throw Failure.badArgs("tips");return patch;}@@ -336,7 +343,7 @@ export function settingsMethods(ctx: BridgeContext): Handlers {}},"repoCache.clear": async () => repoCacheView(await model.backend.clearRepoCache()),- // The page's tips (`AppSettings.tips`), saved as given.+ // The page's tips (`AppSettings.tips`) and the notch's pins (`AppSettings.notchPinned`), saved as given."settings.update": (args) => {save(settingsUpdate(args));return settingsState(model, parts());diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.tsindex f8f3a8ad47..c3f078f102 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.ts@@ -1107,6 +1107,11 @@ const DEFINITIONS = {ret: FfiType.RustBuffer,hasRustCallStatus: true,},+ "uniffi_cua_spaces_ffi_fn_func_app_notch_toggle_pin": {+ args: [FfiType.RustBuffer, FfiType.RustBuffer],+ ret: FfiType.RustBuffer,+ hasRustCallStatus: true,+ },"uniffi_cua_spaces_ffi_fn_func_app_notch_view": {args: [FfiType.RustBuffer, FfiType.RustBuffer],ret: FfiType.RustBuffer,@@ -3027,6 +3032,11 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_spaces_ffi_checksum_func_app_notch_toggle_pin": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_spaces_ffi_checksum_func_app_notch_view": {args: [],ret: FfiType.UInt16,@@ -4567,6 +4577,7 @@ interface NativeModuleInterface {uniffi_cua_spaces_ffi_fn_func_app_notch_radii(uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_notch_reduce(state: Uint8Array, event: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_notch_tile_at(layout: Uint8Array, tiles: Uint8Array, row: number, x: number, y: number, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_spaces_ffi_fn_func_app_notch_toggle_pin(pinned: Uint8Array, id: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_notch_view(state: Uint8Array, spaces: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_notifications_from_json(json: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_notifications_plan(feed: Uint8Array, seenMs: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;@@ -4951,6 +4962,7 @@ interface NativeModuleInterface {uniffi_cua_spaces_ffi_checksum_func_app_notch_radii(): number;uniffi_cua_spaces_ffi_checksum_func_app_notch_reduce(): number;uniffi_cua_spaces_ffi_checksum_func_app_notch_tile_at(): number;+ uniffi_cua_spaces_ffi_checksum_func_app_notch_toggle_pin(): number;uniffi_cua_spaces_ffi_checksum_func_app_notch_view(): number;uniffi_cua_spaces_ffi_checksum_func_app_notifications_from_json(): number;uniffi_cua_spaces_ffi_checksum_func_app_notifications_plan(): number;diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.tsindex c6079e3a81..8e8ecfdc60 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts@@ -3033,6 +3033,28 @@ export function appNotchTileAt(layout: AppNotchLayout, tiles: Array<AppNotchTile));}+/**+ * `pinned` (the notch's pins, in pin order) with `id` pinned or, when it+ * already is, unpinned: Pin to notch and Unpin from notch.+ */+export function appNotchTogglePin(pinned: Array<string>, id: string): Array<string> {+ return ((__rb: Uint8Array) => {+ try {+ return FfiConverterSequenceString.lift(__rb);+ } finally {+ nativeModule().rustbuffer_free(__rb);+ }+ })(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_spaces_ffi_fn_func_app_notch_toggle_pin(+ FfiConverterSequenceString.lower(pinned, nativeModule().rustbuffer_alloc),+ FfiConverterString.lower(id, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }+/*** The notch panel as drawn.*/@@ -32667,7 +32689,23 @@ export type AppNotchTile = {/*** Signed in through the Keyvault (and not dismissed): the key badge.*/- signedIn: boolean+ signedIn: boolean,+ /**+ * One of your other machines' desktops, not a Space it provides: the+ * tile reads "Desktop" and opens the same desktop the machine's page+ * does, creating nothing.+ */+ desktop: boolean,+ /**+ * Pinned to the notch (Pin to notch in the Space's "..." menu): the+ * tiles list pinned ones first.+ */+ pinned: boolean,+ /**+ * Why a pinned desktop cannot be opened now ("Offline", "Not+ * shared"); `None` while it can. The tile stays, dimmed, and says it.+ */+ note?: string}/**@@ -32703,7 +32741,10 @@ const FfiConverterTypeAppNotchTile = (() => {location: FfiConverterString.read(from),progress: FfiConverterOptionalUInt32.read(from),progressLabel: FfiConverterOptionalString.read(from),- signedIn: FfiConverterBool.read(from)+ signedIn: FfiConverterBool.read(from),+ desktop: FfiConverterBool.read(from),+ pinned: FfiConverterBool.read(from),+ note: FfiConverterOptionalString.read(from)};}write(value: TypeName, into: RustBuffer): void {@@ -32720,6 +32761,9 @@ const FfiConverterTypeAppNotchTile = (() => {FfiConverterOptionalUInt32.write(value.progress, into);FfiConverterOptionalString.write(value.progressLabel, into);FfiConverterBool.write(value.signedIn, into);+ FfiConverterBool.write(value.desktop, into);+ FfiConverterBool.write(value.pinned, into);+ FfiConverterOptionalString.write(value.note, into);}allocationSize(value: TypeName): number {return FfiConverterString.allocationSize(value.id) +@@ -32734,7 +32778,10 @@ const FfiConverterTypeAppNotchTile = (() => {FfiConverterString.allocationSize(value.location) +FfiConverterOptionalUInt32.allocationSize(value.progress) +FfiConverterOptionalString.allocationSize(value.progressLabel) +- FfiConverterBool.allocationSize(value.signedIn);+ FfiConverterBool.allocationSize(value.signedIn) ++ FfiConverterBool.allocationSize(value.desktop) ++ FfiConverterBool.allocationSize(value.pinned) ++ FfiConverterOptionalString.allocationSize(value.note);}};@@ -33149,6 +33196,11 @@ export type AppNotchState = {* carry the key.*/signedIn: Array<string>,+ /**+ * The Spaces and desktops pinned to the notch, in the order they were+ * pinned (`AppSettings::notch_pinned`): their tiles come first.+ */+ pinned: Array<string>,/*** "Spaces tab in the notch: Hide" (menu bar only): nothing shows in* the notch, and hover, clicks and window drags do nothing.@@ -33187,6 +33239,7 @@ const FfiConverterTypeAppNotchState = (() => {transfer: FfiConverterOptionalTypeAppNotchTransfer.read(from),keyvault: FfiConverterOptionalString.read(from),signedIn: FfiConverterSequenceString.read(from),+ pinned: FfiConverterSequenceString.read(from),hidden: FfiConverterBool.read(from)};}@@ -33201,6 +33254,7 @@ const FfiConverterTypeAppNotchState = (() => {FfiConverterOptionalTypeAppNotchTransfer.write(value.transfer, into);FfiConverterOptionalString.write(value.keyvault, into);FfiConverterSequenceString.write(value.signedIn, into);+ FfiConverterSequenceString.write(value.pinned, into);FfiConverterBool.write(value.hidden, into);}allocationSize(value: TypeName): number {@@ -33214,6 +33268,7 @@ const FfiConverterTypeAppNotchState = (() => {FfiConverterOptionalTypeAppNotchTransfer.allocationSize(value.transfer) +FfiConverterOptionalString.allocationSize(value.keyvault) +FfiConverterSequenceString.allocationSize(value.signedIn) ++ FfiConverterSequenceString.allocationSize(value.pinned) +FfiConverterBool.allocationSize(value.hidden);}@@ -40733,6 +40788,13 @@ export type AppSettings = {* ([`crate::keyvault::view::prune_dismissed`] forgets the gone ones).*/dismissedAccess: Array<string>,+ /**+ * The Spaces and the machines' desktops pinned to the notch ("Pin to+ * notch" in a Space's "..." menu), in the order they were pinned: the+ * notch lists them first ([`crate::notch::tiles_pinned`]). Ids only,+ * nothing secret; an id whose Space is gone is kept and draws nothing.+ */+ notchPinned: Array<string>,/*** Keyvault rows may load a site's icon from Google's favicon service* when the source browser had none (Settings, Keyvault; on by default).@@ -40796,6 +40858,7 @@ const FfiConverterTypeAppSettings = (() => {experiments: FfiConverterTypeAppExperiments.read(from),newUi: FfiConverterOptionalBoolean.read(from),dismissedAccess: FfiConverterSequenceString.read(from),+ notchPinned: FfiConverterSequenceString.read(from),keyvaultSiteIcons: FfiConverterBool.read(from),teleportChoices: FfiConverterSequenceTypeAppRememberedChoice.read(from),autoConnect: FfiConverterBool.read(from),@@ -40816,6 +40879,7 @@ const FfiConverterTypeAppSettings = (() => {FfiConverterTypeAppExperiments.write(value.experiments, into);FfiConverterOptionalBoolean.write(value.newUi, into);FfiConverterSequenceString.write(value.dismissedAccess, into);+ FfiConverterSequenceString.write(value.notchPinned, into);FfiConverterBool.write(value.keyvaultSiteIcons, into);FfiConverterSequenceTypeAppRememberedChoice.write(value.teleportChoices, into);FfiConverterBool.write(value.autoConnect, into);@@ -40835,6 +40899,7 @@ const FfiConverterTypeAppSettings = (() => {FfiConverterTypeAppExperiments.allocationSize(value.experiments) +FfiConverterOptionalBoolean.allocationSize(value.newUi) +FfiConverterSequenceString.allocationSize(value.dismissedAccess) ++ FfiConverterSequenceString.allocationSize(value.notchPinned) +FfiConverterBool.allocationSize(value.keyvaultSiteIcons) +FfiConverterSequenceTypeAppRememberedChoice.allocationSize(value.teleportChoices) +FfiConverterBool.allocationSize(value.autoConnect) +@@ -43758,7 +43823,15 @@ export type AppSpaceMenuInput = {/*** You may leave it.*/- canLeave: boolean+ canLeave: boolean,+ /**+ * It can be pinned to the notch (not This machine).+ */+ canPin: boolean,+ /**+ * It is pinned to the notch now (Unpin from notch).+ */+ pinned: boolean}/**@@ -43792,7 +43865,9 @@ const FfiConverterTypeAppSpaceMenuInput = (() => {canShare: FfiConverterBool.read(from),canRename: FfiConverterBool.read(from),canDelete: FfiConverterBool.read(from),- canLeave: FfiConverterBool.read(from)+ canLeave: FfiConverterBool.read(from),+ canPin: FfiConverterBool.read(from),+ pinned: FfiConverterBool.read(from)};}write(value: TypeName, into: RustBuffer): void {@@ -43807,6 +43882,8 @@ const FfiConverterTypeAppSpaceMenuInput = (() => {FfiConverterBool.write(value.canRename, into);FfiConverterBool.write(value.canDelete, into);FfiConverterBool.write(value.canLeave, into);+ FfiConverterBool.write(value.canPin, into);+ FfiConverterBool.write(value.pinned, into);}allocationSize(value: TypeName): number {return FfiConverterTypeAppSpaceMenuKind.allocationSize(value.kind) +@@ -43819,7 +43896,9 @@ const FfiConverterTypeAppSpaceMenuInput = (() => {FfiConverterBool.allocationSize(value.canShare) +FfiConverterBool.allocationSize(value.canRename) +FfiConverterBool.allocationSize(value.canDelete) +- FfiConverterBool.allocationSize(value.canLeave);+ FfiConverterBool.allocationSize(value.canLeave) ++ FfiConverterBool.allocationSize(value.canPin) ++ FfiConverterBool.allocationSize(value.pinned);}};@@ -43858,7 +43937,11 @@ export enum AppSpaceMenuItemId {/*** Leaves it (asks first: `spaces.bulkConfirm`).*/- Leave = "leave"+ Leave = "leave",+ /**+ * Pins it to the notch, or unpins it (the label says which).+ */+ Pin = "pin"}const FfiConverterTypeAppSpaceMenuItemId = (() => {@@ -43875,6 +43958,7 @@ const FfiConverterTypeAppSpaceMenuItemId = (() => {case 6: return AppSpaceMenuItemId.Rename;case 7: return AppSpaceMenuItemId.Delete;case 8: return AppSpaceMenuItemId.Leave;+ case 9: return AppSpaceMenuItemId.Pin;default: throw new UniffiInternalError.UnexpectedEnumCase();}}@@ -43888,6 +43972,7 @@ const FfiConverterTypeAppSpaceMenuItemId = (() => {case AppSpaceMenuItemId.Rename: return ordinalConverter.write(6, into);case AppSpaceMenuItemId.Delete: return ordinalConverter.write(7, into);case AppSpaceMenuItemId.Leave: return ordinalConverter.write(8, into);+ case AppSpaceMenuItemId.Pin: return ordinalConverter.write(9, into);}}allocationSize(value: TypeName): number {@@ -58454,7 +58539,8 @@ export enum AppNotchEvent_Tags {Escape = "Escape",Visibility = "Visibility",Activity = "Activity",- Keyvault = "Keyvault"+ Keyvault = "Keyvault",+ Pinned = "Pinned"}export const AppNotchEvent = (() => {@@ -58885,6 +58971,41 @@ inner: {label?: string; signedIn: Array<string> }): Keyvault_ {}+ type Pinned__interface = {+ tag: AppNotchEvent_Tags.Pinned;+ inner:+Readonly<{ids: Array<string>}>+ };+ /**+ * The pinned Spaces and desktops changed (Pin to notch, Unpin from+ * notch, or settings read at start): their ids in pin order.+ */+ class Pinned_ extends UniffiEnum implements Pinned__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "AppNotchEvent";+ readonly tag = AppNotchEvent_Tags.Pinned;+ readonly inner:+Readonly<{ids: Array<string>}>;+ constructor(+inner: {ids: Array<string> }) {+ super("AppNotchEvent", "Pinned");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {ids: Array<string> }): Pinned_ {+ return new Pinned_(inner);+ }++ static instanceOf(obj: any): obj is Pinned_ {+ return obj.tag === AppNotchEvent_Tags.Pinned;+ }++ }+function instanceOf(obj: any): obj is AppNotchEvent {return obj[uniffiTypeNameSymbol] === "AppNotchEvent";}@@ -58904,12 +59025,13 @@ inner: {label?: string; signedIn: Array<string> }): Keyvault_ {Escape: Escape_,Visibility: Visibility_,Activity: Activity_,- Keyvault: Keyvault_+ Keyvault: Keyvault_,+ Pinned: Pinned_});})();export type AppNotchEvent = InstanceType<- typeof AppNotchEvent['HoverEnter' | 'HoverExit' | 'DwellElapsed' | 'CloseElapsed' | 'Click' | 'Dismiss' | 'DropTargeted' | 'Drag' | 'DragPermission' | 'Search' | 'Escape' | 'Visibility' | 'Activity' | 'Keyvault']+ typeof AppNotchEvent['HoverEnter' | 'HoverExit' | 'DwellElapsed' | 'CloseElapsed' | 'Click' | 'Dismiss' | 'DropTargeted' | 'Drag' | 'DragPermission' | 'Search' | 'Escape' | 'Visibility' | 'Activity' | 'Keyvault' | 'Pinned']>;// FfiConverter for enum AppNotchEvent@@ -58933,6 +59055,7 @@ const FfiConverterTypeAppNotchEvent = (() => {case 12: return new AppNotchEvent.Visibility({shown: FfiConverterBool.read(from) });case 13: return new AppNotchEvent.Activity({hotspot: FfiConverterBool.read(from), transfer: FfiConverterOptionalTypeAppNotchTransfer.read(from) });case 14: return new AppNotchEvent.Keyvault({label: FfiConverterOptionalString.read(from), signedIn: FfiConverterSequenceString.read(from) });+ case 15: return new AppNotchEvent.Pinned({ids: FfiConverterSequenceString.read(from) });default: throw new UniffiInternalError.UnexpectedEnumCase();}}@@ -59010,6 +59133,12 @@ const FfiConverterTypeAppNotchEvent = (() => {FfiConverterSequenceString.write(inner.signedIn, into);return;}+ case AppNotchEvent_Tags.Pinned: {+ ordinalConverter.write(15, into);+ const inner = value.inner;+ FfiConverterSequenceString.write(inner.ids, into);+ return;+ }default:// Throwing from here means that AppNotchEvent_Tags hasn't matched an ordinal.throw new UniffiInternalError.UnexpectedEnumCase();@@ -59082,6 +59211,12 @@ const FfiConverterTypeAppNotchEvent = (() => {size += FfiConverterSequenceString.allocationSize(inner.signedIn);return size;}+ case AppNotchEvent_Tags.Pinned: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(15);+ size += FfiConverterSequenceString.allocationSize(inner.ids);+ return size;+ }default: throw new UniffiInternalError.UnexpectedEnumCase();}}@@ -71134,6 +71269,9 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_notch_tile_at() !== 23982) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_notch_tile_at");}+ if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_notch_toggle_pin() !== 49031) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_notch_toggle_pin");+ }if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_notch_view() !== 50142) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_notch_view");}diff --git a/apps/cua-spaces-desktop/src/notch-feed.ts b/apps/cua-spaces-desktop/src/notch-feed.tsindex 2b61d6a71d..f8fff1adb6 100644--- a/apps/cua-spaces-desktop/src/notch-feed.ts+++ b/apps/cua-spaces-desktop/src/notch-feed.ts@@ -109,14 +109,17 @@ export function notchTeleport(handle: () => TeleportLike | null): NotchTeleport/*** Feeds the notch the Spaces, the "Spaces tab in the notch" setting, the live* Keyvault sign-ins (less the copies dismissed from the notch: the SwiftUI- * app's `syncNotchKeyvault`) and the activity, now and on every change.+ * app's `syncNotchKeyvault`), the pinned Spaces and desktops and the+ * activity, now and on every change.* Returns the stop.*/-export function feedNotch(notch: Pick<Notch, "setSpaces" | "setShown" | "setActivity" | "setKeyvault">, model: AppModel): () => void {+export function feedNotch(notch: Pick<Notch, "setSpaces" | "setShown" | "setActivity" | "setKeyvault" | "setPinned">, model: AppModel): () => void {const keyvault = () => notch.setKeyvault(model.keyvault.notchLabel, model.keyvault.signedIn(model.spaces, true));const spaces = () => {notch.setSpaces(model.spaces);notch.setShown(!model.settings.menuBar);+ // Pinned tiles come first; the pins follow the settings file.+ notch.setPinned(model.settings.notchPinned);// The tiles' key follows the Spaces too.keyvault();};diff --git a/apps/cua-spaces-desktop/src/notch.ts b/apps/cua-spaces-desktop/src/notch.tsindex 246c64feae..d6db15b6ac 100644--- a/apps/cua-spaces-desktop/src/notch.ts+++ b/apps/cua-spaces-desktop/src/notch.ts@@ -47,6 +47,8 @@ export interface Notch {setSpaces(spaces: readonly unknown[]): void;/** Live Keyvault sign-ins: the core's sharing label less dismissed copies, and the Space ids that carry the key. */setKeyvault(label: string | null | undefined, signedIn?: string[]): void;+ /** The Spaces and desktops pinned to the notch, in pin order (`AppSettings.notchPinned`). */+ setPinned(ids: readonly string[]): void;/** The hotspot, or a transfer (bytes; both unknown while one starts). */setActivity(hotspot: boolean, transfer?: { sent?: number | bigint; total?: number | bigint } | null): void;/** The "Spaces tab in the notch" setting (`!settings.menuBar`). */@@ -169,6 +171,7 @@ export function startNotch(host: NotchHost, options: StartNotchOptions): Notch {return {setSpaces: (spaces) => model.setSpaces(spaces),setKeyvault: (label, signedIn) => model.setKeyvault(label, signedIn),+ setPinned: (ids) => model.setPinned(ids),setActivity: (hotspot, transfer) => model.setActivity(hotspot, transfer),setShown: (shown) => model.setShown(shown),recheckPermission: () => model.recheckPermission(),diff --git a/apps/cua-spaces-desktop/src/notch/core.ts b/apps/cua-spaces-desktop/src/notch/core.tsindex 37a9ba5853..d61193ffb8 100644--- a/apps/cua-spaces-desktop/src/notch/core.ts+++ b/apps/cua-spaces-desktop/src/notch/core.ts@@ -25,6 +25,8 @@ export interface CoreNotchState {transfer?: unknown;keyvault?: string;signedIn: string[];+ /** The pinned Spaces and desktops, in pin order. */+ pinned?: string[];hidden: boolean;}@@ -101,6 +103,10 @@ function tile(t: Obj): Tile {progress: optNum(t.progress),progressLabel: opt(t.progressLabel),signedIn: t.signedIn,+ // Sent only when set (the helper reads a missing field as false).+ ...(t.desktop === true ? { desktop: true } : {}),+ ...(t.pinned === true ? { pinned: true } : {}),+ ...(opt(t.note) !== undefined ? { note: t.note as string } : {}),};}diff --git a/apps/cua-spaces-desktop/src/notch/model.ts b/apps/cua-spaces-desktop/src/notch/model.tsindex fbf8f11db3..976c34e836 100644--- a/apps/cua-spaces-desktop/src/notch/model.ts+++ b/apps/cua-spaces-desktop/src/notch/model.ts@@ -221,6 +221,13 @@ export class NotchModel {this.send({ tag: "Keyvault", inner: { label: l, signedIn } });}+ /** The pinned Spaces and desktops changed (`AppSettings.notchPinned`): their tiles come first. */+ setPinned(ids: readonly string[]): void {+ const pinned = this.state.pinned ?? [];+ if (ids.length === pinned.length && ids.every((id, i) => id === pinned[i])) return;+ this.send({ tag: "Pinned", inner: { ids: [...ids] } });+ }+/** Shows or hides the notch (the "Spaces tab in the notch" setting). */setShown(shown: boolean): void {if (shown) this.show();diff --git a/apps/cua-spaces-desktop/src/notch/protocol.ts b/apps/cua-spaces-desktop/src/notch/protocol.tsindex 376f2db37b..f8ed2820d2 100644--- a/apps/cua-spaces-desktop/src/notch/protocol.ts+++ b/apps/cua-spaces-desktop/src/notch/protocol.ts@@ -43,6 +43,12 @@ export interface Tile {progress?: number;progressLabel?: string;signedIn: boolean;+ /** One of your other machines' desktops, not a Space it provides. */+ desktop?: boolean;+ /** Pinned to the notch. */+ pinned?: boolean;+ /** Why a pinned desktop cannot be opened now ("Offline", "Not shared"). */+ note?: string;}export interface Activity {diff --git a/apps/cua-spaces-desktop/test/bridge-spaces.test.ts b/apps/cua-spaces-desktop/test/bridge-spaces.test.tsindex 28825e91db..c37e33feaf 100644--- a/apps/cua-spaces-desktop/test/bridge-spaces.test.ts+++ b/apps/cua-spaces-desktop/test/bridge-spaces.test.ts@@ -355,11 +355,12 @@ describe.skipIf(!built)("a Space's detail, files, sharing and clouds on the appsetSpaces: (spaces) => calls.push(`spaces:${spaces.length}`),setShown: (shown) => calls.push(`shown:${shown}`),setKeyvault: (label, signedIn) => calls.push(`keyvault:${label ?? "none"}:${signedIn?.length ?? 0}`),+ setPinned: (ids) => calls.push(`pinned:${ids.join(",")}`),setActivity: (hotspot, transfer) => calls.push(`activity:${hotspot}:${transfer ? "transfer" : "none"}`),},model,);- expect(calls).toEqual([`spaces:${model.spaces.length}`, "shown:true", "keyvault:none:0", "activity:false:none"]);+ expect(calls).toEqual([`spaces:${model.spaces.length}`, "shown:true", "pinned:", "keyvault:none:0", "activity:false:none"]);calls.length = 0;const end = model.activity.begin();model.activity.setHotspot(true);diff --git a/apps/cua-spaces-desktop/test/fakeNotchCore.ts b/apps/cua-spaces-desktop/test/fakeNotchCore.tsindex 828960aacc..6262d71db1 100644--- a/apps/cua-spaces-desktop/test/fakeNotchCore.ts+++ b/apps/cua-spaces-desktop/test/fakeNotchCore.ts@@ -21,6 +21,8 @@ export interface FakeSpace {id: string;name: string;live?: boolean;+ /** One of another machine's desktops. */+ desktop?: boolean;}export const MOTION = {@@ -59,6 +61,12 @@ export function layoutFor(screen: ScreenFacts, prompt: boolean): NotchLayout {};}+/** Where a Space sorts: its pin's place, else after every pin (the list keeps its order). */+const rank = (s: FakeState, id: string): number => {+ const i = (s.pinned ?? []).indexOf(id);+ return i < 0 ? Number.MAX_SAFE_INTEGER : i;+};+export function fakeCore() {const events: Tagged[] = [];const triggerEvents: Tagged[] = [];@@ -80,6 +88,7 @@ export function fakeCore() {transfer: undefined,keyvault: undefined,signedIn: [],+ pinned: [],hidden: false,hovering: false,permissionMissing: false,@@ -127,6 +136,9 @@ export function fakeCore() {s.keyvault = inner.label as string | undefined;s.signedIn = inner.signedIn as string[];break;+ case "Pinned":+ s.pinned = inner.ids as string[];+ break;case "DragPermission":s.permissionMissing = !(inner.granted as boolean);break;@@ -157,7 +169,8 @@ export function fakeCore() {const phase = s.open || s.drag.phase === 2 ? 1 : s.drag.phase === 1 ? 2 : 0;return {phase,- tiles: list.map((sp) => ({+ // Pinned first, in pin order (the real core's `tiles_pinned`).+ tiles: list.toSorted((a, b) => (rank(s, a.id) === rank(s, b.id) ? 0 : rank(s, a.id) < rank(s, b.id) ? -1 : 1)).map((sp) => ({id: sp.id,name: sp.name,os: 0,@@ -171,6 +184,9 @@ export function fakeCore() {progress: undefined,progressLabel: undefined,signedIn: s.signedIn.includes(sp.id),+ desktop: sp.desktop === true,+ pinned: (s.pinned ?? []).includes(sp.id),+ note: undefined,})),dropMode: s.drag.phase === 2,prompt: s.drag.phase === 1 ? "Teleport to Cua" : undefined,diff --git a/apps/cua-spaces-desktop/test/host-bridge.test.ts b/apps/cua-spaces-desktop/test/host-bridge.test.tsindex d78351806f..4e2b218db3 100644--- a/apps/cua-spaces-desktop/test/host-bridge.test.ts+++ b/apps/cua-spaces-desktop/test/host-bridge.test.ts@@ -578,6 +578,24 @@ describe.skipIf(!built)("This machine, Devices and Settings on the app core", ()expect(settingsEvents).toBeGreaterThan(0);});+ it("keeps the notch's pins in the app settings (`settings.update`), in pin order, across a restart", async () => {+ const before = (await call("settings.get")) as { notchPinned: string[] };+ expect(before.notchPinned).toEqual([]);+ const after = (await call("settings.update", { notchPinned: ["relay:wsl", "local:aurora"] })) as typeof before;+ expect(after.notchPinned).toEqual(["relay:wsl", "local:aurora"]);+ // Saved with the rest of the app's settings (a launch reads them back); the tips are untouched.+ expect(native.appSettingsLoad(model.settingsPath).notchPinned).toEqual(["relay:wsl", "local:aurora"]);+ expect(model.settings.tips).toEqual({ off: false, done: [] });+ expect(await code("settings.update", { notchPinned: "relay:wsl" })).toBe("bad_args");+ expect(await code("settings.update", { notchPinned: [1] })).toBe("bad_args");+ // The core's rule for Pin to notch: pinned last, unpinned when pinned, never This machine.+ expect(native.appNotchTogglePin(["a"], "b")).toEqual(["a", "b"]);+ expect(native.appNotchTogglePin(["a", "b"], "a")).toEqual(["b"]);+ expect(native.appNotchTogglePin([], "this-mac")).toEqual([]);+ await call("settings.update", { notchPinned: [] });+ expect(native.appSettingsLoad(model.settingsPath).notchPinned).toEqual([]);+ });+it("keeps the page's tips in the app settings (`settings.update`), and Show tips and Reset tips", async () => {const before = (await call("settings.get")) as { tips: unknown };expect(before.tips).toEqual({ off: false, done: [] });@@ -974,6 +992,42 @@ describe.skipIf(!built)("This machine, Devices and Settings on the app core", ()expect(view.tab.count).toBe(String(native.appOnCount(model.spaces)));});+ it("the notch lists a machine's shared desktop, counts it while it runs, and a pin puts it first and keeps it when it goes offline", async () => {+ const { wireView } = await import("../src/notch/core");+ await call("host.setUp", { request: { mode: "direct", direct: "0.0.0.0:3211" } });+ const wsl = { ...backend.rowsNow[2]!, id: "relay:wsl", name: "WSL", provider: "relay", host: undefined, features: ["desktop_stream", "window_stream", "host_spaces"], reachable: true };+ const studio = { ...backend.rowsNow[2]!, id: "relay:studio", name: "Studio", provider: "relay", host: undefined, features: ["host_spaces"], reachable: true };+ backend.rowsNow = [...backend.rowsNow, wsl, studio];+ await model.refresh();+ const core = native as unknown as import("../src/notch/core").NotchCore;+ const open = (pinned: string[]) => {+ const shown = core.appNotchReduce(core.appNotchInitial(), { tag: "Visibility", inner: { shown: true } });+ const clicked = core.appNotchReduce(shown.state, { tag: "Click" });+ const state = core.appNotchReduce(clicked.state, { tag: "Pinned", inner: { ids: pinned } }).state;+ return wireView(core.appNotchView(state, model.spaces));+ };+ // The shared desktop is a tile of its own kind; the machine that only provides Spaces is not.+ let view = open([]);+ const ids = view.tiles.map((t) => t.id);+ expect(ids).toContain("relay:wsl");+ expect(ids).not.toContain("relay:studio");+ expect(view.tiles.find((t) => t.id === "relay:wsl")).toMatchObject({ desktop: true, location: "Desktop" });+ // It counts as a running Space, as the menu's count does.+ expect(view.tab.count).toBe(String(native.appOnCount(model.spaces)));+ expect(native.appOnCount(model.spaces)).toBeGreaterThan(0);+ // Pinned: first, with the pin.+ view = open(["relay:wsl"]);+ expect(view.tiles[0]).toMatchObject({ id: "relay:wsl", pinned: true });+ // The machine goes offline: the unpinned desktop leaves, the pinned one stays dimmed and says so, and neither counts.+ const on = native.appOnCount(model.spaces);+ backend.rowsNow = backend.rowsNow.map((r) => (r.id === "relay:wsl" ? { ...r, reachable: false } : r));+ await model.refresh();+ expect(open([]).tiles.map((t) => t.id)).not.toContain("relay:wsl");+ const kept = open(["relay:wsl"]).tiles.find((t) => t.id === "relay:wsl");+ expect(kept).toMatchObject({ pinned: true, desktop: true, dim: true, note: "Offline" });+ expect(native.appOnCount(model.spaces)).toBe(on - 1);+ });+it("says the launch is still waiting first", async () => {model.startup.phase = { kind: "starting" };const items = menuItems(bridge.context);diff --git a/apps/cua-spaces-desktop/test/notch-model.test.ts b/apps/cua-spaces-desktop/test/notch-model.test.tsindex e1ad41659f..fa80d07469 100644--- a/apps/cua-spaces-desktop/test/notch-model.test.ts+++ b/apps/cua-spaces-desktop/test/notch-model.test.ts@@ -167,6 +167,24 @@ describe("notch model", () => {expect(last().view.tiles[0]?.signedIn).toBe(true);});+ it("feeds the pinned Spaces and desktops only when they change, and the pinned tiles come first", () => {+ const { model, fake, last } = setup();+ const ids = last().view.tiles.map((t) => t.id);+ expect(ids.length).toBeGreaterThan(1);+ model.setPinned([]);+ expect(fake.events).toEqual([]);+ const second = ids[1]!;+ model.setPinned([second]);+ model.setPinned([second]);+ expect(fake.events.filter((e) => e.tag === "Pinned")).toHaveLength(1);+ expect(fake.events.at(-1)?.inner).toEqual({ ids: [second] });+ const tiles = last().view.tiles;+ expect(tiles[0]).toMatchObject({ id: second, pinned: true });+ expect(tiles.slice(1).every((t) => t.pinned !== true)).toBe(true);+ model.setPinned([]);+ expect(last().view.tiles.map((t) => t.id)).toEqual(ids);+ });+it("estimates a ring's progress with the core while it shows, every 200 ms", () => {const { model, clock, last, fake } = setup();model.setActivity(false, { sent: undefined, total: undefined });diff --git a/apps/cua-spaces-desktop/test/vault-native.test.ts b/apps/cua-spaces-desktop/test/vault-native.test.tsindex bd552ffddb..c1834b6fc3 100644--- a/apps/cua-spaces-desktop/test/vault-native.test.ts+++ b/apps/cua-spaces-desktop/test/vault-native.test.ts@@ -530,7 +530,7 @@ describe.skipIf(!built)("Teleport and the Keyvault on the app core", () => {it("feeds the notch the sign-ins live in a Space, and Dismiss hides them there and nowhere else", async () => {await setUp(parityOverview(native, withCopy));const sent: [string | null | undefined, string[] | undefined][] = [];- const stop = feedNotch({ setSpaces: () => {}, setShown: () => {}, setKeyvault: (label, signedIn) => void sent.push([label, signedIn]), setActivity: () => {} }, model);+ const stop = feedNotch({ setSpaces: () => {}, setShown: () => {}, setKeyvault: (label, signedIn) => void sent.push([label, signedIn]), setPinned: () => {}, setActivity: () => {} }, model);expect(sent.at(-1)![0]).toBe(model.keyvault.sharingLabel);expect(sent.at(-1)![1]).toContain("local:aurora");await call("keyvault.dismiss", { imports: ["imp-1"] });diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swiftindex f655872a23..ea37e3374e 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift@@ -231,6 +231,8 @@ public final class AppModel {hostArch: Self.hostArch, lumeSource: nil, linuxSource: nil, storage: nil, clouds: [], hosts: [],experiments: settings.experiments, gpus: nil, nameSeed: nil))self.notch = NotchModel()+ // Pinned Spaces and desktops come first in the notch, across restarts.+ notch.setPinned(settings.notchPinned)// The notch tiles and the preview cover read one thumbnail store,// filled from the SDK's shared cache.notch.thumbnails.fetch = { [backend] id, maxAgeMs in await backend.thumbnail(id: id, maxAgeMs: maxAgeMs) }@@ -1606,6 +1608,21 @@ public final class AppModel {// MARK: - Settings and banners+ /// Pin to notch / Unpin from notch: the Spaces and machine desktops the+ /// notch lists first (`AppSettings.notchPinned`, in pin order). Saved+ /// with the settings, so a pin survives a restart; it grants nothing.+ public func setNotchPinned(_ ids: [String]) {+ guard ids != settings.notchPinned else { return }+ settings.notchPinned = ids+ saveSettings()+ notch.setPinned(ids)+ }++ /// Pins `id` to the notch, or unpins it when it is pinned.+ public func togglePin(_ id: String) {+ setNotchPinned(appNotchTogglePin(pinned: settings.notchPinned, id: id))+ }+public func saveSettings() {try? appSettingsSave(path: settingsPath, settings: settings)}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/NotchModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/NotchModel.swiftindex 8ba94d4b2b..4400d46c16 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/NotchModel.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/NotchModel.swift@@ -81,6 +81,13 @@ public final class NotchModel {send(.keyvault(label: label, signedIn: signedIn))}+ /// The pinned Spaces and desktops changed (Pin to notch, Unpin from+ /// notch, or the settings read at start): their ids in pin order.+ public func setPinned(_ ids: [String]) {+ guard ids != state.pinned else { return }+ send(.pinned(ids: ids))+ }+/// The header's search text.public func search(_ query: String) {guard query != state.query else { return }diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpaceActions.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpaceActions.swiftindex 3af8741bac..60d3ac16e7 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpaceActions.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpaceActions.swift@@ -60,7 +60,11 @@ extension AppModel {// until it does.canRename: false,canDelete: a.canDelete && offers(.delete),- canLeave: a.canLeave)+ canLeave: a.canLeave,+ // Pin to notch is in the web UI's menus (the only Spaces UI); this+ // model-level menu keeps to the actions the classic window had.+ canPin: false,+ pinned: settings.notchPinned.contains(space.id))}/// A Space's right-click menu (none for this Mac's own row).@@ -81,6 +85,7 @@ extension AppModel {case .share, .manageSharing: open(space, then: .share)case .teleport: open(space, then: .teleport)case .rename: break+ case .pin: togglePin(space.id)case .delete, .leave:if removable(space) {askRemove([space])diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchData+Core.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchData+Core.swiftindex 684088d858..0acb73c1d3 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchData+Core.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Notch/NotchData+Core.swift@@ -99,7 +99,8 @@ extension AppNotchTile {var data: NotchData.Tile {NotchData.Tile(id: id, name: name, status: status.notchData, dim: dim, dropTarget: dropTarget,targeted: targeted, symbol: symbol, label: label, location: location, progress: progress,- progressLabel: progressLabel, signedIn: signedIn)+ progressLabel: progressLabel, signedIn: signedIn, desktop: desktop, pinned: pinned,+ note: note)}}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swiftindex f9a3a5762a..51421a0092 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge.swift@@ -612,6 +612,8 @@ final class WebUIBridge: NSObject, WKScriptMessageHandlerWithReply {"runtimes": BridgeValue.encode(model.runtimesInput),// The app core's own settings the page reads and saves (`settings.update`)."tips": ["off": model.settings.tips.off, "done": model.settings.tips.done] as [String: Any],+ // The Spaces and machine desktops pinned to the notch, in pin order.+ "notchPinned": model.settings.notchPinned,]}@@ -1191,16 +1193,23 @@ final class WebUIBridge: NSObject, WKScriptMessageHandlerWithReply {// MARK: - The core's own settings/// `settings.update`: each key given is saved as is (`tips`:- /// `{off, done}`).+ /// `{off, done}`; `notchPinned`: the pinned ids in pin order).func updateSettings(_ args: [String: Any]) throws {var next = model.settingsif let raw = args["tips"] {guard let t = raw as? [String: Any] else { throw Failure.badArgs("tips: {off, done}") }next.tips = AppTipsState(off: t["off"] as? Bool ?? false, done: t["done"] as? [String] ?? [])}+ if let raw = args["notchPinned"] {+ guard let ids = raw as? [String] else { throw Failure.badArgs("notchPinned: string[]") }+ next.notchPinned = ids+ }guard next != model.settings else { return }+ let pinned = next.notchPinnedmodel.settings = nextmodel.saveSettings()+ // The notch lists the pinned first at once.+ model.notch.setPinned(pinned)}// MARK: - Eventsdiff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swiftindex 1740d59d54..3a1086f7c0 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/NotchTests.swift@@ -197,6 +197,8 @@ struct NotchTests {machine.id = "relay:studio"machine.name = "Studio"machine.provider = "relay"+ // It only provides Spaces: no desktop to list.+ machine.features = ["host_spaces"]var provided = FixtureSpacesBackend.sample[0]provided.id = "relay:studio/dev"provided.name = "Dev"@@ -217,6 +219,84 @@ struct NotchTests {#expect(notch.view.tiles.count == Int(appOpenableCount(spaces: notch.spaces)))}+ /// A machine's shared desktop is a Space and shows by default; a+ /// pin puts it first and keeps it, dimmed with its note, when the+ /// machine goes offline. The tab counts it only while it runs.+ @Test func aSharedDesktopShowsCountsWhileItRunsAndAPinKeepsItWhenOffline() async {+ var wsl = FixtureSpacesBackend.sample[0]+ wsl.id = "relay:wsl"+ wsl.name = "WSL"+ wsl.provider = "relay"+ wsl.features = ["desktop_stream", "window_stream", "host_spaces"]+ wsl.power = nil+ wsl.powerState = nil+ var studio = wsl+ studio.id = "relay:studio"+ studio.name = "Studio"+ studio.features = ["host_spaces"]+ let backend = FixtureSpacesBackend(rows: [FixtureSpacesBackend.sample[0], wsl, studio])+ let m = ViewModelTests().makeModel(backend)+ await m.refresh()++ let clock = ManualScheduler()+ let notch = NotchModel(scheduler: clock)+ notch.spaces = m.notch.spaces+ notch.send(.hoverEnter)+ clock.advance(motion.hoverDwellMs)+ let ids = notch.view.tiles.map(\.id)+ #expect(ids.contains("relay:wsl"), "the shared desktop is a tile")+ #expect(!ids.contains("relay:studio"), "a machine without a desktop is not")+ let desktop = notch.view.tiles.first { $0.id == "relay:wsl" }+ #expect(desktop?.desktop == true && desktop?.location == "Desktop" && desktop?.pinned == false)+ #expect(notch.view.tab.count == "2", "the running Space and the running desktop")++ // Pinned: first, with the pin (from the settings, as at launch).+ m.togglePin("relay:wsl")+ #expect(m.settings.notchPinned == ["relay:wsl"])+ #expect(appSettingsLoad(path: m.settingsPath).notchPinned == ["relay:wsl"], "kept across a restart")+ #expect(m.notch.state.pinned == ["relay:wsl"])+ notch.setPinned(m.settings.notchPinned)+ #expect(notch.view.tiles.first?.id == "relay:wsl" && notch.view.tiles.first?.pinned == true)++ // The machine goes offline: the pin stays, dimmed, saying so; it counts nothing.+ wsl.reachable = false+ backend.fixtureRows = [FixtureSpacesBackend.sample[0], wsl, studio]+ await m.refresh()+ notch.spaces = m.notch.spaces+ let offline = notch.view.tiles.first { $0.id == "relay:wsl" }+ #expect(offline?.note == "Offline" && offline?.dim == true && offline?.pinned == true)+ #expect(notch.view.tab.count == "1")++ // Unpinned: gone again.+ m.togglePin("relay:wsl")+ #expect(m.settings.notchPinned.isEmpty)+ notch.setPinned([])+ #expect(!notch.view.tiles.map(\.id).contains("relay:wsl"))+ }++ /// Pin to notch is the core's menu item: it flips to Unpin from notch,+ /// the pins keep their order, and This Mac is never pinned.+ @Test func pinToNotchIsTheCoresMenuItem() async throws {+ let m = ViewModelTests().makeModel()+ await m.refresh()+ let aurora = try #require(m.spaces.first { $0.id == "local:aurora" })+ var input = m.menuInput(aurora)+ input.canPin = true+ #expect(appSpaceMenu(input: input).map(\.label).contains("Pin to notch"))+ m.runMenuItem(.pin, on: aurora)+ #expect(m.settings.notchPinned == ["local:aurora"])+ input.pinned = m.settings.notchPinned.contains(aurora.id)+ let labels = appSpaceMenu(input: input).map(\.label)+ #expect(labels.contains("Unpin from notch") && !labels.contains("Pin to notch"))+ m.togglePin("direct:builder")+ #expect(m.settings.notchPinned == ["local:aurora", "direct:builder"], "in the order pinned")+ m.runMenuItem(.pin, on: aurora)+ #expect(m.settings.notchPinned == ["direct:builder"])+ m.togglePin("this-mac")+ #expect(m.settings.notchPinned == ["direct:builder"])+ #expect(appSettingsLoad(path: m.settingsPath).notchPinned == ["direct:builder"])+ }+// MARK: - The presentation state machine@Test func openingSpringsTheShapeThenFadesTheContentIn() {diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swiftindex d0a0ca6815..b0db550c9d 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift@@ -2481,6 +2481,7 @@ struct ParityTests {case .rename: "rename"case .delete: "delete"case .leave: "leave"+ case .pin: "pin"}}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/TipsTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/TipsTests.swiftindex f1628b87a8..cf662e953d 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/TipsTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/TipsTests.swift@@ -84,4 +84,28 @@ struct TipsTests {_ = try await bridge.handle("settings.choose", ["row": "reset-tips", "option": "press"])#expect(m.settings.tips == AppTipsState(off: false, done: []))}++ /// The notch's pins ride the same settings path as the tips: the page reads+ /// and saves them (`notchPinned`), the notch lists the pinned first at once,+ /// and they survive a restart.+ @Test func theNewUISavesTheNotchPinsThroughTheBridge() async throws {+ let m = ViewModelTests().makeModel()+ let bridge = WebUIBridge(model: m, allowedOrigins: [])+ let before = try #require(try await bridge.handle("settings.get", [:]) as? [String: Any])+ #expect(before["notchPinned"] as? [String] == [])++ let after = try #require(try await bridge.handle("settings.update", [+ "notchPinned": ["relay:wsl", "local:aurora"],+ ]) as? [String: Any])+ #expect(after["notchPinned"] as? [String] == ["relay:wsl", "local:aurora"])+ #expect(settingsOnDisk(m).notchPinned == ["relay:wsl", "local:aurora"])+ #expect(m.notch.state.pinned == ["relay:wsl", "local:aurora"], "the notch follows at once")+ #expect(m.settings.tips == AppTipsState(off: false, done: []), "the tips are untouched")++ // A key left out stays; a wrong one is refused.+ _ = try await bridge.handle("settings.update", [:])+ #expect(m.settings.notchPinned == ["relay:wsl", "local:aurora"])+ await #expect(throws: (any Error).self) { try await bridge.handle("settings.update", ["notchPinned": "relay:wsl"]) }+ await #expect(throws: (any Error).self) { try await bridge.handle("settings.update", ["notchPinned": [1]]) }+ }}diff --git a/apps/cua-spaces-web/src/__tests__/machines-account.test.tsx b/apps/cua-spaces-web/src/__tests__/machines-account.test.tsxindex 99d27caace..2ea694d682 100644--- a/apps/cua-spaces-web/src/__tests__/machines-account.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/machines-account.test.tsx@@ -170,6 +170,16 @@ describe.skipIf(!wasmBuilt)("one list of machines (real routes, wasm core)", ()expect(trust.querySelector("[data-machine-trust-status]")?.textContent).toMatch(/^Trusted until/);// The demo's relay says studio-mac and mac-mini were reached.act(() => q('[data-machine-id="mac-mini"]')?.click());+ // Recent access is a plain text link by Remove from account, not a block on the page.+ const link = await waitFor(() => {+ const l = q("[data-machine-recent-link]");+ if (!l) throw new Error("no See recent access link");+ return l;+ });+ expect(link.textContent).toBe("See recent access");+ expect(q("[data-machine-recent]")).toBeNull();+ expect(q("[data-machine-actions]")?.contains(q("[data-machine-remove]"))).toBe(true);+ act(() => link.click());const recent = await waitFor(() => {const r = q("[data-machine-recent]");if (!r) throw new Error("no recent access");diff --git a/apps/cua-spaces-web/src/__tests__/notch-pin.test.tsx b/apps/cua-spaces-web/src/__tests__/notch-pin.test.tsxnew file mode 100644index 0000000000..53e5570130--- /dev/null+++ b/apps/cua-spaces-web/src/__tests__/notch-pin.test.tsx@@ -0,0 +1,117 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++// Pin to notch (#6160) on the real routes and the wasm core: another machine's+// shared desktop has a "⋯" menu with Open, Pin to notch / Unpin from notch and+// Hide; a Space's menu has the pin above its red Delete Space; This Mac's+// desktop has no menu; a pinned row shows a small pin; the pins are the host's+// settings (`notchPinned`), kept in the order they were made; and the machine's+// page has the same menu on its desktop row.++import { act, cleanup, fireEvent, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it } from "vitest";++import { setFlagOverride } from "@/bridge";+import { wasmBuilt } from "@/bridge/__tests__/testCore";+import { resetHiddenDesktops } from "@/lib/hidden-desktops";+import { mountApp, stubBrowserApis, type TestHost } from "./app-harness";++stubBrowserApis();+beforeEach(() => {+ localStorage.clear();+ resetHiddenDesktops();+ setFlagOverride("spaces_ask_first_home", true);+});+afterEach(cleanup);++const DESKTOP = "relay:linux-box";+const SPACE = "local:design-review";++const thisMac = { id: "this-mac", name: "This Mac", provider: "local", spacesdVersion: "", features: [], reachable: true, os: "macos" };+const host = (extra: Partial<TestHost> = {}): TestHost => ({+ failsCreates: false,+ listsGhost: false,+ demo: { desktops: true },+ answer: (op, out) => (op === "spaces.list" ? [...(out as unknown[]), thisMac] : out),+ ...extra,+});++const tile = (id: string) => document.querySelector<HTMLElement>(`[data-space-id="${id}"]`)?.parentElement ?? null;+const more = (id: string) => document.querySelector<HTMLElement>(`[data-space-more="${id}"]`);+const labels = () => Array.from(document.querySelectorAll<HTMLElement>('[data-space-menu="more"] [role="menuitem"]')).map((e) => e.textContent);+const pinMark = (id: string) => tile(id)?.querySelector("[data-pinned-mark]") ?? null;++async function openMenu(id: string) {+ await waitFor(() => expect(more(id)).not.toBeNull());+ await act(async () => void fireEvent.click(more(id)!));+ await waitFor(() => expect(labels().length).toBeGreaterThan(0));+}++describe.skipIf(!wasmBuilt)("Pin to notch", () => {+ it("another machine's shared desktop has Open, Pin to notch and Hide, and a pin shows on the row and flips the item", async () => {+ await mountApp("/spaces", host());+ await waitFor(() => expect(tile(DESKTOP)).not.toBeNull());+ expect(tile(DESKTOP)!.querySelector("[data-desktop-tag]")?.textContent).toBe("Desktop");+ // Another machine's desktop hides from its menu; the hover button is This Mac's.+ expect(tile(DESKTOP)!.querySelector("[data-tile-hide]")).toBeNull();+ expect(pinMark(DESKTOP)).toBeNull();++ await openMenu(DESKTOP);+ expect(labels()).toEqual(["Open", "Pin to notch", "Hide"]);+ await act(async () => void fireEvent.click(document.querySelector('[data-space-menu="more"] [data-menu-item="pin"]')!));+ await waitFor(() => expect(pinMark(DESKTOP)).not.toBeNull());+ expect(pinMark(DESKTOP)!.getAttribute("aria-label")).toBe("Pinned to notch");++ await openMenu(DESKTOP);+ expect(labels()).toEqual(["Open", "Unpin from notch", "Hide"]);+ await act(async () => void fireEvent.click(document.querySelector('[data-space-menu="more"] [data-menu-item="pin"]')!));+ await waitFor(() => expect(pinMark(DESKTOP)).toBeNull());+ });++ it("Hide in the menu takes the desktop off the list, and pinning does not hide or share anything", async () => {+ await mountApp("/spaces", host());+ await waitFor(() => expect(tile(DESKTOP)).not.toBeNull());+ await openMenu(DESKTOP);+ await act(async () => void fireEvent.click(document.querySelector('[data-space-menu="more"] [data-menu-item="hide"]')!));+ await waitFor(() => expect(tile(DESKTOP)).toBeNull());+ });++ it("a Space's menu has the pin above its red Delete Space, and the pins keep the order they were made in", async () => {+ const saved: unknown[] = [];+ await mountApp("/spaces", host({ intercept: (op, args) => (op === "settings.set" ? void saved.push(args) : undefined) }));+ await waitFor(() => expect(tile(SPACE)).not.toBeNull());+ await openMenu(SPACE);+ const items = labels();+ expect(items.at(-1)).toBe("Delete Space");+ expect(items.at(-2)).toBe("Pin to notch");+ await act(async () => void fireEvent.click(document.querySelector('[data-space-menu="more"] [data-menu-item="pin"]')!));+ await waitFor(() => expect(pinMark(SPACE)).not.toBeNull());++ // A second pin goes last; the host keeps both, in order.+ await openMenu(DESKTOP);+ await act(async () => void fireEvent.click(document.querySelector('[data-space-menu="more"] [data-menu-item="pin"]')!));+ await waitFor(() => expect(pinMark(DESKTOP)).not.toBeNull());+ expect(pinMark(SPACE)).not.toBeNull();+ expect(saved).toEqual([+ { key: "notchPinned", value: [SPACE] },+ { key: "notchPinned", value: [SPACE, DESKTOP] },+ ]);+ });++ it("This Mac's desktop has no menu: it is never a notch tile", async () => {+ await mountApp("/spaces", host());+ await waitFor(() => expect(tile("this-mac")).not.toBeNull());+ expect(more("this-mac")).toBeNull();+ expect(tile("this-mac")!.querySelector("[data-tile-hide]")).not.toBeNull();+ });++ it("the machine's page has the same menu on its shared desktop row", async () => {+ await mountApp("/machines", host());+ const rowOf = () => document.querySelector<HTMLElement>(`[data-space-row="${DESKTOP}"]`);+ await waitFor(() => expect(document.querySelector('[data-machine-id="linux-box"]')).not.toBeNull());+ fireEvent.click(document.querySelector('[data-machine-id="linux-box"]')!);+ await waitFor(() => expect(rowOf()).not.toBeNull());+ await openMenu(DESKTOP);+ expect(labels()).toEqual(["Open", "Pin to notch"]);+ });+});diff --git a/apps/cua-spaces-web/src/__tests__/spaces-page-bulk.test.tsx b/apps/cua-spaces-web/src/__tests__/spaces-page-bulk.test.tsxindex 3c366006be..31d283db59 100644--- a/apps/cua-spaces-web/src/__tests__/spaces-page-bulk.test.tsx+++ b/apps/cua-spaces-web/src/__tests__/spaces-page-bulk.test.tsx@@ -146,8 +146,8 @@ describe.skipIf(!wasmBuilt)("on the page", () => {await mountApp("/spaces", HOST);await waitFor(() => expect(tile(RUNNING)).not.toBeNull());fireEvent.click(document.querySelector(`[data-space-more="${RUNNING}"]`)!);- // Shared with five people: Manage sharing…; Rename stays out (no host renames a Space yet).- await waitFor(() => expect(menuLabels("more")).toEqual(["Open", "Turn off", "Manage sharing…", "Teleport an app…", "Delete Space (red)"]));+ // Shared with five people: Manage sharing…; Rename stays out (no host renames a Space yet); Pin to notch above the red Delete Space.+ await waitFor(() => expect(menuLabels("more")).toEqual(["Open", "Turn off", "Manage sharing…", "Teleport an app…", "Pin to notch", "Delete Space (red)"]));fireEvent.click(document.querySelector('[data-space-menu="more"] [data-menu-item="delete"]')!);const dialog = await waitFor(() => document.querySelector<HTMLElement>("[data-bulk-confirm]") ?? Promise.reject(new Error("no confirm")));expect(dialog.textContent).toContain("Delete design-review?");@@ -157,7 +157,7 @@ describe.skipIf(!wasmBuilt)("on the page", () => {await waitFor(() => expect(document.querySelector("[data-bulk-confirm]")).toBeNull());fireEvent.contextMenu(tile(STOPPED));- await waitFor(() => expect(menuLabels("context")).toEqual(["Open", "Turn on", "Share…", "Teleport an app…", "Delete Space (red)"]));+ await waitFor(() => expect(menuLabels("context")).toEqual(["Open", "Turn on", "Share…", "Teleport an app…", "Pin to notch", "Delete Space (red)"]));});it("checkbox, ⌘-click and ⇧-click pick without opening; ⌘A picks every visible one; Esc clears", async () => {diff --git a/apps/cua-spaces-web/src/bridge/__tests__/spaces-page.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/spaces-page.test.tsindex 5fc0579874..6b568f0767 100644--- a/apps/cua-spaces-web/src/bridge/__tests__/spaces-page.test.ts+++ b/apps/cua-spaces-web/src/bridge/__tests__/spaces-page.test.ts@@ -53,6 +53,23 @@ describe.skipIf(!wasmBuilt)("the new Spaces page's decisions (wasm core)", () =>expect(spaceMenu(core, { kind: "mine", ...all }).at(-1)?.id).toBe("delete");});+ it("Pin to notch / Unpin from notch sit above Delete and Leave, for a Space and for another machine's desktop", async () => {+ const core = await testCore();+ const labels = (input: Parameters<typeof spaceMenu>[1]) => spaceMenu(core, input).map((i) => `${i.separatorBefore ? "--- " : ""}${i.label}`);+ const all = { canPower: true, canTeleport: true, canShare: true, canDelete: true };+ expect(labels({ kind: "mine", power: "running", canPin: true, ...all })).toEqual(["Open", "Turn off", "Share…", "Teleport an app…", "Pin to notch", "--- Delete Space"]);+ expect(labels({ kind: "mine", power: "running", canPin: true, pinned: true, ...all }).at(-2)).toBe("Unpin from notch");+ expect(labels({ kind: "withMe", role: "viewer", power: "running", canPin: true, canLeave: true })).toEqual(["Open", "Pin to notch", "--- Leave"]);+ // A machine's desktop: Open and the pin, nothing to turn on, share or delete.+ expect(labels({ kind: "mine", role: "owner", power: "off", canPin: true })).toEqual(["Open", "Pin to notch"]);+ // Where the host can't keep pins (or for This Mac) there is no item.+ expect(labels({ kind: "mine", role: "owner", power: "off" })).toEqual(["Open"]);+ // The pins' order is the core's: pinned last, unpinned when pinned, never This Mac.+ expect(core.call<string[]>("notch.togglePin", { pinned: ["a"], id: "b" })).toEqual(["a", "b"]);+ expect(core.call<string[]>("notch.togglePin", { pinned: ["a", "b"], id: "a" })).toEqual(["b"]);+ expect(core.call<string[]>("notch.togglePin", { pinned: [], id: "this-mac" })).toEqual([]);+ });+it("asks once for a mixed selection and counts what is freed", async () => {const core = await testCore();const items: BulkItem[] = [diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo-data.ts b/apps/cua-spaces-web/src/bridge/adapters/demo-data.tsindex 6bc329853f..3fdc30164e 100644--- a/apps/cua-spaces-web/src/bridge/adapters/demo-data.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/demo-data.ts@@ -63,6 +63,25 @@ const STREAMS = ["desktop_stream", "window_stream", "audio.desktop", "relay_atta/** `minutesAgo` → RFC 3339, relative to `now`. */const at = (now: number, minutesAgo: number) => new Date(now - minutesAgo * 60_000).toISOString();+/** The Linux box sharing its own desktop over the relay (`?demo=desktops`): a row of its own, no host above it. */+export function demoDesktopRows(now: number): SpaceRow[] {+ return [+ {+ id: "relay:linux-box",+ name: "Linux box",+ provider: "relay",+ spacesdVersion: "0.6.0",+ features: [...STREAMS, "host_spaces"],+ addedAt: at(now, 600),+ os: "linux",+ osName: "Ubuntu",+ osPrettyName: "Ubuntu 24.04.3 LTS",+ arch: "amd64",+ reachable: true,+ },+ ];+}+export function demoSpaceRows(now: number): SpaceRow[] {return [{diff --git a/apps/cua-spaces-web/src/bridge/adapters/demo.ts b/apps/cua-spaces-web/src/bridge/adapters/demo.tsindex 361a33d5d8..cf9858212c 100644--- a/apps/cua-spaces-web/src/bridge/adapters/demo.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/demo.ts@@ -32,6 +32,7 @@ import {demoMachineRows,demoKeyvaultItems,demoKeyvaultOverview,+ demoDesktopRows,demoSpaceRows,demoTelemetry,} from "./demo-data";@@ -86,6 +87,8 @@ export interface DemoOptions {keys?: "none" | "several";/** Start with no Spaces (the first-Space empty state). */noSpaces?: boolean;+ /** `?demo=desktops`: the Linux box also shares its desktop (a Space row of its own, `relay:linux-box`). */+ desktops?: boolean;/** This many more Spaces on the list, for scale (`?demo=scale-1000`;* scripts/scale-bench.mjs). */extraSpaces?: number;@@ -185,6 +188,7 @@ const DEMO_NOTES = "https://github.com/trycua/cua/releases/tag/cua-spaces-v0.9.3* `?demo=low-disk` / `?demo=disk-full` (This Mac almost out of space: New* Space and the first Space offers see it too), and `?demo=intel-mac` /* `?demo=linux-pc` (an Intel Mac, an x64 Linux PC with QEMU), and+ * `?demo=desktops` (the Linux box shares its desktop, a shared desktop row beside the Spaces), and* `?demo=creating-elsewhere` (the Mac mini is creating a Space). *//** The account's signed-in machines that share nothing, as a host lists them (`?demo=signed-in-machines`): one enrolled, and the demo devices that wait. */function demoSignedInRows(nowMs: number): MachineRow[] {@@ -236,6 +240,7 @@ export function demoOptionsFromSearch(search: string): DemoOptions {...(flags.has("claude-expired") ? { claudeLogin: "expired" as const } : flags.has("claude-signed-in") ? { claudeLogin: "signed-in" as const } : flags.has("claude-none") ? { claudeLogin: "none" as const } : {}),...(flags.has("chatgpt-signed-in") ? { chatgptLogin: true } : {}),noSpaces: flags.has("empty"),+ desktops: flags.has("desktops"),...(() => {const scale = [...flags].find((f) => /^scale-\d+$/.test(f));return scale ? { extraSpaces: Math.min(5000, Number(scale.slice(6))) } : {};@@ -332,14 +337,14 @@ export function createDemoAdapter(options: DemoOptions = {}): DataAdapter & { reconst timers = new Set<ReturnType<typeof setTimeout>>();const state: DemoState = {- rows: options.noSpaces ? [] : [...demoSpaceRows(now()), ...demoScaleRows(now(), options.extraSpaces ?? 0)],+ rows: options.noSpaces ? [] : [...demoSpaceRows(now()), ...(options.desktops ? demoDesktopRows(now()) : []), ...demoScaleRows(now(), options.extraSpaces ?? 0)],items: demoKeyvaultItems(now()),keyvaultLocked: Boolean(options.keyvaultLocked),keyvaultDisabled: false,pendingRequests: true,revokedGrants: new Set(),// Kept as the Mac and Electron apps keep the core's settings: tips and the Pro banner's close.- settings: { ...DEFAULT_SETTINGS, launchAtLogin: true, updateChannel: "stable", tips: { off: false, done: [] } },+ settings: { ...DEFAULT_SETTINGS, launchAtLogin: true, updateChannel: "stable", tips: { off: false, done: [] }, notchPinned: [] },identity: options.signedIn === false ? undefined : DEMO_IDENTITY,onboarding: { completed: options.onboarded !== false, mode: options.onboarded === false ? null : "client" },creates: new Map(),diff --git a/apps/cua-spaces-web/src/bridge/adapters/tauri.ts b/apps/cua-spaces-web/src/bridge/adapters/tauri.tsindex e5bee60232..9598341036 100644--- a/apps/cua-spaces-web/src/bridge/adapters/tauri.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/tauri.ts@@ -246,6 +246,7 @@ export function createTauriAdapter(win: HostWindow = globalThis.window as HostWithrow new UnsupportedOperationError("tauri", "settings.set updateChannel");// The app core's own settings file is the Mac and Electron apps'; the page keeps this for the session.case "tips":+ case "notchPinned":throw new UnsupportedOperationError("tauri", `settings.set ${key}`);}return readSettings();diff --git a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts b/apps/cua-spaces-web/src/bridge/adapters/webkit.tsindex 49d7cc444b..7bca7b8975 100644--- a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts+++ b/apps/cua-spaces-web/src/bridge/adapters/webkit.ts@@ -318,6 +318,7 @@ export function toSettingsSnapshot(s: WkSettings, page: Pick<SettingsValues, "th...(rows.has("auto-connect") ? { autoConnect: active(rows.get("auto-connect")) === "on" } : {}),// The core's own settings the page changes (`settings.update`); an older host has none....(s.tips ? { tips: { off: s.tips.off === true, done: Array.isArray(s.tips.done) ? s.tips.done : [] } } : {}),+ ...(Array.isArray(s.notchPinned) ? { notchPinned: s.notchPinned.filter((id): id is string => typeof id === "string") } : {}),},defaultLocation: null,telemetry: telemetry@@ -651,6 +652,7 @@ export function createWebkitAdapter(break;// The app core's own settings (`AppSettings`), saved as given.case "tips":+ case "notchPinned":return toSettingsSnapshot(await request<WkSettings>("settings.update", { [key]: value ?? null }), page);}return settingsSnapshot();diff --git a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.jsonindex 7fd5915233..e3307e05f0 100644--- a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json+++ b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json@@ -4393,6 +4393,12 @@"off","done"]+ },+ "notchPinned": {+ "type": "array",+ "items": {+ "type": "string"+ }}},"required": [@@ -6952,6 +6958,12 @@"done"]},+ "notchPinned": {+ "type": "array",+ "items": {+ "type": "string"+ }+ },"runtimes": {"anyOf": [{diff --git a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts b/apps/cua-spaces-web/src/bridge/contracts/shapes.tsindex 3ca129cfda..35dc25267a 100644--- a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts+++ b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts@@ -381,6 +381,7 @@ const SettingsShape = ref(updateChannel: nullable(oneOf("stable", "beta")),autoConnect: opt(bool),tips: opt(TipsStateShape),+ notchPinned: opt(strings),}),defaultLocation: nullable(obj<DefaultLocation>()({ value: str, source: oneOf("env", "config", "default"), env: opt(str), path: str })),telemetry: nullable(@@ -1625,6 +1626,7 @@ const WkSettingsShape = ref(accountUrl: optNull(str),cli: optNull(object({ name: str, installed: bool })),tips: opt(TipsStateShape),+ notchPinned: opt(strings),runtimes: optNull(RuntimesInputShape),}),);diff --git a/apps/cua-spaces-web/src/bridge/contracts/spaces-page.ts b/apps/cua-spaces-web/src/bridge/contracts/spaces-page.tsindex 3f8223418d..6d099c3caa 100644--- a/apps/cua-spaces-web/src/bridge/contracts/spaces-page.ts+++ b/apps/cua-spaces-web/src/bridge/contracts/spaces-page.ts@@ -29,9 +29,13 @@ export interface SpaceMenuInput {canRename?: boolean;canDelete?: boolean;canLeave?: boolean;+ /** It can be pinned to the notch (not This machine). */+ canPin?: boolean;+ /** It is pinned now (Unpin from notch). */+ pinned?: boolean;}-export type SpaceMenuItemId = "open" | "power" | "share" | "manageSharing" | "teleport" | "rename" | "delete" | "leave";+export type SpaceMenuItemId = "open" | "power" | "share" | "manageSharing" | "teleport" | "rename" | "delete" | "leave" | "pin";export interface SpaceMenuItem {id: SpaceMenuItemId;diff --git a/apps/cua-spaces-web/src/bridge/index.ts b/apps/cua-spaces-web/src/bridge/index.tsindex f2820e11a2..f44497549b 100644--- a/apps/cua-spaces-web/src/bridge/index.ts+++ b/apps/cua-spaces-web/src/bridge/index.ts@@ -135,6 +135,7 @@ export { displayPairingCode, normalizePairingCode, pairingLinkRelay } from "./paexport { BUY_PRO_URL, BUY_TEAMS_URL, expiresInText, FINISHING_SETUP, PAIRING_POLL_MS, pairingUnsupported, planFailure, usePairingCode, type PairingHook, type PairingPhase } from "./pairing";export { READY_STARTUP, type StartupAction, type StartupPhase, type StartupState } from "./ops/startup";export { NO_TIPS, sendTipsEvent, tipsState, useTips, type TipsHook } from "./tips";+export { useNotchPins, type NotchPins } from "./notch-pins";export {CHECKLIST_STEPS,useChecklist,diff --git a/apps/cua-spaces-web/src/bridge/notch-pins.ts b/apps/cua-spaces-web/src/bridge/notch-pins.tsnew file mode 100644index 0000000000..943ac6c5f6--- /dev/null+++ b/apps/cua-spaces-web/src/bridge/notch-pins.ts@@ -0,0 +1,60 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++/**+ * The Spaces and machine desktops pinned to the notch ("Pin to notch" in a+ * Space's "⋯" menu). The notch lists them first.+ *+ * The state is the core's `AppSettings.notchPinned` (ids in the order they+ * were pinned), kept by the host with the rest of the app's settings+ * (`settings.get` answers it in `values.notchPinned`; `settings.set` with key+ * `notchPinned` saves it), so the notch, the SwiftUI app and the Electron+ * app agree and a pin survives a restart. Pinning changes nothing about+ * access: it only says which tiles the notch keeps first.+ *+ * A host that keeps no core settings refuses the save: the page then keeps+ * the pins for this session.+ */++import { useCallback, useMemo, useState } from "react";++import { useBridge, useSettings } from "./hooks";++const NONE: readonly string[] = [];++export interface NotchPins {+ /** The pinned ids, in pin order. */+ ids: readonly string[];+ /** The same, to ask `has(id)`. */+ pinned: ReadonlySet<string>;+ /** The app core can pin (it answers `notch.togglePin`). */+ canPin: boolean;+ /** Pins `id`, or unpins it when it is pinned. */+ toggle(id: string): Promise<void>;+}++/** The pins now, and what changes them. */+export function useNotchPins(): NotchPins {+ const settings = useSettings();+ const { core } = useBridge();+ // Set only when the host refused to keep them.+ const [session, setSession] = useState<readonly string[] | null>(null);+ const ids = session ?? settings.data?.values.notchPinned ?? NONE;+ const pinned = useMemo(() => new Set(ids), [ids]);+ const canPin = core.status === "ready";+ const toggle = useCallback(+ async (id: string) => {+ const next = core.tryCall<string[]>("notch.togglePin", { pinned: ids, id });+ if (!next) return;+ if (session) return void setSession(next);+ try {+ await settings.updateSetting("notchPinned", next);+ } catch {+ // The host keeps no core settings: this window remembers.+ setSession(next);+ }+ },+ [core, ids, session, settings],+ );+ return { ids, pinned, canPin, toggle };+}diff --git a/apps/cua-spaces-web/src/bridge/protocol.ts b/apps/cua-spaces-web/src/bridge/protocol.tsindex f625c279ae..9d1f218701 100644--- a/apps/cua-spaces-web/src/bridge/protocol.ts+++ b/apps/cua-spaces-web/src/bridge/protocol.ts@@ -90,6 +90,10 @@ export interface SettingsValues {/** Tips (`AppSettings.tips`): off, and the ones done. Absent where the* host keeps no core settings (the page keeps them for this session). */tips?: TipsState;+ /** The Spaces and machine desktops pinned to the notch (`AppSettings.notch_pinned`),+ * in pin order. Absent where the host keeps no core settings (the page keeps them+ * for this session). */+ notchPinned?: string[];}export type UpdateChannel = "stable" | "beta";diff --git a/apps/cua-spaces-web/src/bridge/webkit-protocol.ts b/apps/cua-spaces-web/src/bridge/webkit-protocol.tsindex 6a798c718c..04f3400e49 100644--- a/apps/cua-spaces-web/src/bridge/webkit-protocol.ts+++ b/apps/cua-spaces-web/src/bridge/webkit-protocol.ts@@ -380,6 +380,8 @@ export interface WkSettings {cli?: { name: string; installed: boolean } | null;/** `AppSettings.tips`; absent: an older host that keeps none. Saved with `settings.update`. */tips?: { off: boolean; done: string[] };+ /** `AppSettings.notchPinned`: the Spaces and desktops pinned to the notch, in pin order; absent: an older host. Saved with `settings.update`. */+ notchPinned?: string[];/** Settings, Advanced's runtimes as the host read them (`runtimes::RuntimesInput`); absent: not read. */runtimes?: RuntimesInput | null;}diff --git a/apps/cua-spaces-web/src/components/machines/account-parts.tsx b/apps/cua-spaces-web/src/components/machines/account-parts.tsxindex f7fb64a04a..ca663aa07e 100644--- a/apps/cua-spaces-web/src/components/machines/account-parts.tsx+++ b/apps/cua-spaces-web/src/components/machines/account-parts.tsx@@ -174,30 +174,54 @@ export function TrustSection({ trust, onTrust }: { trust: ThisMachineTrust; onTr);}-/** Who reached this machine lately: a few lines, newest first. */+/**+ * "See recent access": a plain text link at the foot of a machine's page that opens who reached the+ * machine, and when, in a small dialog. A failed read of that list stays on the page, since it says why+ * the list may be short.+ */export function RecentAccess({ lines, title, empty, now, error }: { lines: AccessLine[]; title: string; empty: string; now: number; error?: string | null }) {+ const [open, setOpen] = useState(false);return (<>- <h3 className="mt-7 mb-2 text-xs font-semibold text-muted-foreground">{title}</h3>- <div className="border-y" data-machine-recent="">- {lines.length === 0 ? <p className="py-3 text-[13px] text-muted-foreground">{empty}</p> : null}- {lines.map((a, i) => (- <div key={`${a.ts}-${i}`} data-recent-row="" className={`flex min-h-10 items-center justify-between gap-4 py-2 ${i > 0 ? "border-t" : ""}`}>- <span className="flex min-w-0 items-center gap-2 text-[13px]">- {a.notable ? <UsersIcon className="size-3.5 shrink-0 text-warning" aria-label="Another account or an untrusted machine" /> : null}- <span className="select-text" data-recent-text="">- {a.text}- </span>- </span>- <span className="shrink-0 text-xs text-muted-foreground">{relativeText(a.ts, now)}</span>+ <button+ type="button"+ data-machine-recent-link=""+ onClick={() => setOpen(true)}+ className="cursor-default py-1 text-[13px] text-muted-foreground hover:text-foreground hover:underline hover:underline-offset-2"+ >+ See recent access+ </button>+ {error ? (+ <p data-devices-read-error="" className="order-last w-full text-xs break-words text-destructive">+ {error}+ </p>+ ) : null}+ <Dialog open={open} onOpenChange={setOpen}>+ <DialogPopup className="w-[min(480px,calc(100vw-2rem))]">+ <div className="px-5 pt-5 pb-4">+ <DialogTitle className="text-[15px] font-semibold">{title}</DialogTitle>+ <div className="mt-3 max-h-[50vh] overflow-y-auto border-y" data-machine-recent="">+ {lines.length === 0 ? <p className="py-3 text-[13px] text-muted-foreground">{empty}</p> : null}+ {lines.map((a, i) => (+ <div key={`${a.ts}-${i}`} data-recent-row="" className={`flex min-h-10 items-center justify-between gap-4 py-2 ${i > 0 ? "border-t" : ""}`}>+ <span className="flex min-w-0 items-center gap-2 text-[13px]">+ {a.notable ? <UsersIcon className="size-3.5 shrink-0 text-warning" aria-label="Another account or an untrusted machine" /> : null}+ <span className="select-text" data-recent-text="">+ {a.text}+ </span>+ </span>+ <span className="shrink-0 text-xs text-muted-foreground">{relativeText(a.ts, now)}</span>+ </div>+ ))}+ </div></div>- ))}- {error ? (- <p data-devices-read-error="" className="border-t py-2.5 text-xs break-words text-destructive">- {error}- </p>- ) : null}- </div>+ <div className="flex justify-end border-t bg-muted/60 px-5 py-3">+ <Button type="button" variant="outline" onClick={() => setOpen(false)}>+ Close+ </Button>+ </div>+ </DialogPopup>+ </Dialog></>);}diff --git a/apps/cua-spaces-web/src/components/spaces/model.ts b/apps/cua-spaces-web/src/components/spaces/model.tsindex 57fe683e2d..c4938b145a 100644--- a/apps/cua-spaces-web/src/components/spaces/model.ts+++ b/apps/cua-spaces-web/src/components/spaces/model.ts@@ -2,7 +2,7 @@// Copyright (c) 2026 Cua AI, Inc.import type { Space, SpaceAccess } from "@/bridge";-import { isMachineDesktop, isUnsharedDesktop, type SpaceState } from "@/lib/spaces";+import { isMachineDesktop, isThisMacDesktop, isUnsharedDesktop, type SpaceState } from "@/lib/spaces";/** One Space as the Spaces page draws it (a tile or a list row). */export interface SpaceItem {@@ -30,3 +30,13 @@ export function desktopWord(item: Pick<SpaceItem, "desktop" | "space">): stringif (item.desktop === "off") return "Not sharing";return item.desktop === "shared" && item.space.id === "this-mac" ? "Sharing" : undefined;}++/** Whether the row has its "⋯" menu: a Space, and another machine's shared desktop. Not This Mac's desktop, and not a desktop that is not shared. */+export const hasMenu = (item: Pick<SpaceItem, "desktop" | "space">): boolean => !item.desktop || (item.desktop === "shared" && !isThisMacDesktop(item.space));++/** Whether the row has the hover Hide button: This Mac's desktop (another machine's desktop hides from its menu). */+export const hasHideButton = (item: Pick<SpaceItem, "desktop" | "space">): boolean => Boolean(item.desktop) && isThisMacDesktop(item.space);++/** Whether the notch can keep it: a Space that exists, and another machine's desktop. Not This Mac, and not one still being created. */+export const canPinToNotch = (item: Pick<SpaceItem, "desktop" | "space" | "state">): boolean =>+ item.state !== "creating" && !item.space.id.startsWith("pending:") && (!item.desktop || (item.desktop === "shared" && !isThisMacDesktop(item.space)));diff --git a/apps/cua-spaces-web/src/components/spaces/space-list.tsx b/apps/cua-spaces-web/src/components/spaces/space-list.tsxindex 11fe190a9a..cac4c95cee 100644--- a/apps/cua-spaces-web/src/components/spaces/space-list.tsx+++ b/apps/cua-spaces-web/src/components/spaces/space-list.tsx@@ -14,14 +14,14 @@ import type { MouseEvent, ReactNode, RefObject } from "react";import { OsIcon } from "@/components/os-icon";import { StateLabel } from "@/components/state-dot";-import { DesktopTag } from "@/components/spaces/space-tile";+import { DesktopTag, PinnedMark } from "@/components/spaces/space-tile";import { useWindowedRows } from "@/hooks/use-windowed-rows";import { lastUsedText, sizeCell, type SpacesSort } from "@/lib/spaces-page";import { WINDOW_FROM } from "@/lib/windowing";import { cn } from "@/lib/utils";import { PeopleStack, SpaceMark } from "./avatars";-import { desktopWord, type SpaceItem } from "./model";+import { desktopWord, hasHideButton, hasMenu, type SpaceItem } from "./model";export interface SpaceListProps {items: SpaceItem[];@@ -79,7 +79,7 @@ export function SpaceList({ items, sort, onSort, now, selection, menu, more, hid</div><div role="rowgroup" ref={windowed.ref as RefObject<HTMLDivElement>} style={windowed.style}>{items.slice(from, to).map((item) => {- const row = <ListRow key={item.space.id} item={item} cols={cols} now={now} selection={selection} more={item.desktop ? undefined : more?.(item)} hide={item.desktop ? () => hide?.(item) : undefined} />;+ const row = <ListRow key={item.space.id} item={item} cols={cols} now={now} selection={selection} more={hasMenu(item) ? more?.(item) : undefined} hide={hasHideButton(item) ? () => hide?.(item) : undefined} />;return menu ? <div key={item.space.id}>{menu(item, row)}</div> : row;})}</div>@@ -126,6 +126,7 @@ function ListRow({ item, cols, now, selection, more, hide }: { item: SpaceItem;>{space.name}</Link>+ <PinnedMark id={space.id} />{item.desktop ? <DesktopTag /> : null}<PeopleStack access={access} /></span>diff --git a/apps/cua-spaces-web/src/components/spaces/space-menu.tsx b/apps/cua-spaces-web/src/components/spaces/space-menu.tsxindex 084a06c6e7..106b08e103 100644--- a/apps/cua-spaces-web/src/components/spaces/space-menu.tsx+++ b/apps/cua-spaces-web/src/components/spaces/space-menu.tsx@@ -14,15 +14,22 @@ import { useNavigate } from "@tanstack/react-router";import { MoreHorizontalIcon } from "lucide-react";import { Fragment, type ReactNode } from "react";-import { spaceMenu, useBridge, useSession, useShareSheet, useTeleport, type SpaceMenuInput, type SpaceMenuItem } from "@/bridge";+import { spaceMenu, useBridge, useNotchPins, useSession, useShareSheet, useTeleport, type SpaceMenuInput, type SpaceMenuItem } from "@/bridge";+import { toastError } from "@/components/ui/toast";import { cn } from "@/lib/utils";-import type { SpaceItem } from "./model";+import { canPinToNotch, type SpaceItem } from "./model";import { MENU_ITEM, MENU_POPUP } from "./spaces-toolbar";-/** What the core's menu reads for this Space. */-export function menuInput(item: SpaceItem): SpaceMenuInput {+/**+ * What the core's menu reads for this Space. `pinned`: the notch's pins, when the host can keep+ * them (Pin to notch / Unpin from notch); without it the menu has no pin item. One of your other+ * machines' desktops is not a Space to turn on, share or delete: its menu is Open and the pin.+ */+export function menuInput(item: SpaceItem, pinned?: ReadonlySet<string>): SpaceMenuInput {const { access, state, space } = item;+ const pin = pinned && canPinToNotch(item) ? { canPin: true, pinned: pinned.has(space.id) } : {};+ if (item.desktop) return { kind: "mine", role: "owner", power: "off", ...pin };const busy = space.power?.turningOn !== undefined && space.power?.turningOn !== null;return {kind: access.kind,@@ -38,6 +45,7 @@ export function menuInput(item: SpaceItem): SpaceMenuInput {canRename: false,canDelete: access.canDelete && item.mine,canLeave: access.canLeave,+ ...pin,};}@@ -46,21 +54,25 @@ export interface MenuActions {power: (item: SpaceItem, on: boolean) => void;/** Ask to delete or leave it (the bulk confirm, with one Space). */remove: (item: SpaceItem) => void;- /** Hide a machine's desktop row from the list (Hide on its hover). */+ /** Hide a machine's desktop row from the list (Hide on This Mac's hover, in the menu of another machine's). */hide?: (item: SpaceItem) => void;}+/** One menu entry: the core's item, or Hide (the page's own, on another machine's desktop), with what it does. */+type MenuEntry = Omit<SpaceMenuItem, "id"> & { id: SpaceMenuItem["id"] | "hide"; run: () => void };+/** The menu's items, each with what it does. */-export function useSpaceMenu(item: SpaceItem, actions: MenuActions): (SpaceMenuItem & { run: () => void })[] {+export function useSpaceMenu(item: SpaceItem, actions: MenuActions): MenuEntry[] {const { core } = useBridge();const navigate = useNavigate();const share = useShareSheet();const teleport = useTeleport();const { data: session } = useSession();- // A machine's desktop is not a Space: no delete, power or share menu; Hide is its hover button.- if (core.status !== "ready" || item.desktop) return [];- const items = spaceMenu(core, menuInput(item));- const run = (id: SpaceMenuItem["id"]) => {+ const pins = useNotchPins();+ // This Mac's desktop and a desktop that is not shared have no menu: Hide is This Mac's hover button.+ if (core.status !== "ready" || item.desktop === "off" || item.space.id === "this-mac") return [];+ const items = spaceMenu(core, menuInput(item, pins.canPin ? pins.pinned : undefined));+ const run = (id: MenuEntry["id"]) => {switch (id) {case "open":return void navigate({ to: "/spaces/$spaceId", params: { spaceId: item.space.id } });@@ -74,14 +86,21 @@ export function useSpaceMenu(item: SpaceItem, actions: MenuActions): (SpaceMenuIcase "delete":case "leave":return actions.remove(item);+ case "pin":+ return void pins.toggle(item.space.id).catch(toastError(`Couldn't change the notch`));+ case "hide":+ return actions.hide?.(item);case "rename":return undefined;}};- return items.map((i) => ({ ...i, run: () => run(i.id) }));+ const entries: MenuEntry[] = items.map((i) => ({ ...i, run: () => run(i.id) }));+ // Another machine's desktop leaves the list from here (This Mac's has the hover button).+ if (item.desktop && actions.hide) entries.push({ id: "hide", label: "Hide", enabled: true, destructive: false, separatorBefore: false, run: () => run("hide") });+ return entries;}-function Items({ items, Item, Separator }: { items: ReturnType<typeof useSpaceMenu>; Item: typeof MenuPrimitive.Item; Separator: typeof MenuPrimitive.Separator }) {+function Items({ items, Item, Separator }: { items: MenuEntry[]; Item: typeof MenuPrimitive.Item; Separator: typeof MenuPrimitive.Separator }) {return items.map((i) => (<Fragment key={i.id}>{i.separatorBefore ? <Separator className="-mx-1 my-1 h-px bg-foreground/10" /> : null}@@ -167,3 +186,38 @@ export function SpaceContextMenu({ item, actions, children }: { item: SpaceItem;</ContextMenu.Root>);}++/**+ * The "⋯" on a row of a machine's page ("Spaces on this machine": its shared desktop, then the Spaces it+ * provides): Open and Pin to notch / Unpin from notch, the core's menu for what a row there can do. It+ * shows on hover over the row's chevron. Nothing where the app core can't pin.+ */+export function MachineRowMenu({ id, name }: { id: string; name: string }) {+ const { core } = useBridge();+ const navigate = useNavigate();+ const pins = useNotchPins();+ if (core.status !== "ready" || !pins.canPin) return null;+ const items = spaceMenu(core, { kind: "mine", role: "owner", power: "off", canPin: true, pinned: pins.pinned.has(id) });+ const run = (item: SpaceMenuItem) => {+ if (item.id === "open") void navigate({ to: "/spaces/$spaceId", params: { spaceId: id } });+ else if (item.id === "pin") void pins.toggle(id).catch(toastError("Couldn't change the notch"));+ };+ return (+ <MenuPrimitive.Root>+ <MenuPrimitive.Trigger aria-label={`More for ${name}`} data-space-more={id} className={cn(MORE_BUTTON, "absolute top-1/2 right-[-6px] -translate-y-1/2")}>+ <MoreHorizontalIcon className="size-4" />+ </MenuPrimitive.Trigger>+ <MenuPrimitive.Portal>+ <MenuPrimitive.Positioner sideOffset={4} align="end" className="z-50 outline-none">+ <MenuPrimitive.Popup data-space-menu="more" className={MENU_POPUP}>+ {items.map((i) => (+ <MenuPrimitive.Item key={i.id} disabled={!i.enabled} data-menu-item={i.id} onClick={() => run(i)} className={MENU_ITEM}>+ {i.label}+ </MenuPrimitive.Item>+ ))}+ </MenuPrimitive.Popup>+ </MenuPrimitive.Positioner>+ </MenuPrimitive.Portal>+ </MenuPrimitive.Root>+ );+}diff --git a/apps/cua-spaces-web/src/components/spaces/space-tile.tsx b/apps/cua-spaces-web/src/components/spaces/space-tile.tsxindex d4441c10e6..f246a4c39d 100644--- a/apps/cua-spaces-web/src/components/spaces/space-tile.tsx+++ b/apps/cua-spaces-web/src/components/spaces/space-tile.tsx@@ -15,10 +15,10 @@*/import { Link } from "@tanstack/react-router";-import { ArrowDownCircleIcon, EyeOffIcon, KeyRoundIcon, LoaderCircleIcon, PowerIcon } from "lucide-react";+import { ArrowDownCircleIcon, EyeOffIcon, KeyRoundIcon, LoaderCircleIcon, PinIcon, PowerIcon } from "lucide-react";import { useEffect, useRef, useState, type DragEvent, type MouseEvent, type ReactNode } from "react";-import { useBridge, useSpaceFiles, useSpaces, useSpaceThumbnail, useTips, useWindowDropTarget, type Space, type SpaceAccess } from "@/bridge";+import { useBridge, useNotchPins, useSpaceFiles, useSpaces, useSpaceThumbnail, useTips, useWindowDropTarget, type Space, type SpaceAccess } from "@/bridge";import { OsIcon } from "@/components/os-icon";import { StateLabel } from "@/components/state-dot";import { toast, toastError } from "@/components/ui/toast";@@ -96,6 +96,7 @@ export function SpaceTile({ item, accessKey, selected = false, busy = false, top<p data-space-name="" className="min-w-0 flex-1 truncate text-[13px] leading-5 font-semibold">{space.name}</p>+ <PinnedMark id={space.id} />{item.desktop ? <DesktopTag /> : null}{/* The state, in the core's words ("Running", "Suspended", "Turning off…"), flush right; the hover "⋯" takes its place. */}<StateLabel@@ -171,6 +172,13 @@ export function SpaceTile({ item, accessKey, selected = false, busy = false, top);}+/** A small pin after the name of a Space or desktop pinned to the notch (Pin to notch in its "⋯" menu). */+export function PinnedMark({ id }: { id: string }) {+ const { pinned } = useNotchPins();+ if (!pinned.has(id)) return null;+ return <PinIcon data-pinned-mark="" role="img" aria-label="Pinned to notch" className="size-3 shrink-0 self-center text-muted-foreground" />;+}+/** The "Desktop" tag beside a machine's own desktop in the list. */export function DesktopTag() {return (diff --git a/apps/cua-spaces-web/src/routes/machines/index.tsx b/apps/cua-spaces-web/src/routes/machines/index.tsxindex 56ea8bdcae..9c09d19032 100644--- a/apps/cua-spaces-web/src/routes/machines/index.tsx+++ b/apps/cua-spaces-web/src/routes/machines/index.tsx@@ -30,6 +30,7 @@ import { UpsellPrompt } from "@/components/upsell-prompt";import { OsIcon } from "@/components/os-icon";import { EmptyState, Page, PageHeader } from "@/components/page";import { RestartDialog, useUpdateIndicator } from "@/components/shell/update-indicator";+import { MachineRowMenu } from "@/components/spaces/space-menu";import { ThisMachineExtras } from "@/components/this-machine";import { ConfirmDialog } from "@/components/ui/alert-dialog";import { Button } from "@/components/ui/button";@@ -597,23 +598,26 @@ function MachineDetail({ machine: m, row, onRemoved }: { machine: MachinesViewMa<h3 className="mt-7 mb-2 text-xs font-semibold text-muted-foreground">{m.spacesTitle}</h3><div className="border-y" data-machine-spaces>{rows.map((s, i) => (- <Link- key={s.id}- to="/spaces/$spaceId"- params={{ spaceId: s.id }}- title={`Open ${s.name}`}- data-space-row={s.id}- className={cn("flex items-center gap-2.5 py-2.5 text-[13px] outline-none hover:bg-accent/40 focus-visible:bg-accent/50", i > 0 && "border-t")}- >- <span className="truncate font-mono text-xs">{s.name}</span>- {s.label ? <span className="shrink-0 rounded bg-muted px-1.5 text-2xs text-muted-foreground">{s.label}</span> : null}- {s.os ? <span className="truncate text-muted-foreground">{s.os}</span> : null}- <span className="ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground">- <StatusDot online={s.running} className="size-[7px]" />- {s.status}- </span>- <ChevronRightIcon className="size-3.5 shrink-0 text-muted-foreground/60" />- </Link>+ <div key={s.id} className={cn("group/row relative", i > 0 && "border-t")}>+ <Link+ to="/spaces/$spaceId"+ params={{ spaceId: s.id }}+ title={`Open ${s.name}`}+ data-space-row={s.id}+ className="flex items-center gap-2.5 py-2.5 text-[13px] outline-none hover:bg-accent/40 focus-visible:bg-accent/50"+ >+ <span className="truncate font-mono text-xs">{s.name}</span>+ {s.label ? <span className="shrink-0 rounded bg-muted px-1.5 text-2xs text-muted-foreground">{s.label}</span> : null}+ {s.os ? <span className="truncate text-muted-foreground">{s.os}</span> : null}+ <span className="ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground">+ <StatusDot online={s.running} className="size-[7px]" />+ {s.status}+ </span>+ <ChevronRightIcon className="size-3.5 shrink-0 text-muted-foreground/60 group-hover/row:invisible group-focus-within/row:invisible" />+ </Link>+ {/* Not This Mac's own desktop: it is never a notch tile. */}+ {m.current && s.id === m.desktop?.id ? null : <MachineRowMenu id={s.id} name={s.name} />}+ </div>))}{m.spacesEmpty ? <p className={cn("py-3.5 text-xs text-muted-foreground", rows.length > 0 && "border-t")}>{m.spacesEmpty}</p> : null}<div className="border-t py-2.5">@@ -623,7 +627,6 @@ function MachineDetail({ machine: m, row, onRemoved }: { machine: MachinesViewMa</>) : null}- {account ? <RecentAccess lines={accessFor(account.access, m.current ? (row?.relayId ?? m.id) : m.id, m.current ? null : row?.device ? m.id : null)} title={account.recentTitle} empty={account.recentEmpty} now={now} error={m.current && account.thisMachine?.kind === "enrolled" ? account.readError : null} /> : null}<div className="mt-6"><button@@ -652,19 +655,22 @@ function MachineDetail({ machine: m, row, onRemoved }: { machine: MachinesViewMa) : null}</div>- {m.remove ? (- <span title={m.remove.help ?? undefined} className="mt-7 inline-flex">- <button- type="button"- disabled={!m.remove.enabled}- onClick={() => setRemoving(m.remove!)}- className="cursor-default py-1 text-[13px] text-destructive hover:underline hover:underline-offset-2 disabled:opacity-50 disabled:hover:no-underline"- data-machine-remove={m.id}- >- {m.remove.label}- </button>- </span>- ) : null}+ <div className="mt-7 flex flex-wrap items-center gap-x-5" data-machine-actions="">+ {account ? <RecentAccess lines={accessFor(account.access, m.current ? (row?.relayId ?? m.id) : m.id, m.current ? null : row?.device ? m.id : null)} title={account.recentTitle} empty={account.recentEmpty} now={now} error={m.current && account.thisMachine?.kind === "enrolled" ? account.readError : null} /> : null}+ {m.remove ? (+ <span title={m.remove.help ?? undefined} className="inline-flex">+ <button+ type="button"+ disabled={!m.remove.enabled}+ onClick={() => setRemoving(m.remove!)}+ className="cursor-default py-1 text-[13px] text-destructive hover:underline hover:underline-offset-2 disabled:opacity-50 disabled:hover:no-underline"+ data-machine-remove={m.id}+ >+ {m.remove.label}+ </button>+ </span>+ ) : null}+ </div>{removing ? (<ConfirmDialogdiff --git a/apps/cua-spaces-web/src/routes/spaces/index.tsx b/apps/cua-spaces-web/src/routes/spaces/index.tsxindex 50e827e95a..937e6ca6a8 100644--- a/apps/cua-spaces-web/src/routes/spaces/index.tsx+++ b/apps/cua-spaces-web/src/routes/spaces/index.tsx@@ -11,7 +11,7 @@ import { useFirstSpaceMilestones } from "@/components/first-run-guide";import { EmptyState, Page, PageHeader } from "@/components/page";import { ComputerWarnings } from "@/components/resources/computer-resources";import { useListedSpaces } from "@/components/spaces/listed";-import { desktopOf, type SpaceItem } from "@/components/spaces/model";+import { desktopOf, hasHideButton, hasMenu, type SpaceItem } from "@/components/spaces/model";import { BulkConfirmDialog, useBulkRemove } from "@/components/spaces/bulk-remove";import { SpaceList } from "@/components/spaces/space-list";import { SpaceContextMenu, SpaceMoreMenu, type MenuActions } from "@/components/spaces/space-menu";@@ -348,8 +348,8 @@ const GridTile = memo(function GridTile({className="opacity-0 group-focus-within/tile:opacity-100 group-hover/tile:opacity-100 group-data-[picking]/grid:opacity-100"/>}- hide={item.desktop ? () => actions.hide?.(item) : undefined}- more={item.desktop ? undefined : <SpaceMoreMenu item={item} actions={actions} />}+ hide={hasHideButton(item) ? () => actions.hide?.(item) : undefined}+ more={hasMenu(item) ? <SpaceMoreMenu item={item} actions={actions} /> : undefined}/></SpaceContextMenu></li>diff --git a/docs/content/docs/spaces/guides/add-a-computer.mdx b/docs/content/docs/spaces/guides/add-a-computer.mdxindex 9c4ab0b283..5e77e554ac 100644--- a/docs/content/docs/spaces/guides/add-a-computer.mdx+++ b/docs/content/docs/spaces/guides/add-a-computer.mdx@@ -155,6 +155,24 @@ with **Add machine** and **Not me** (Add machine asks for Touch ID or your loginNot me refuses it), and the sidebar shows how many wait. Each machine's page has Rename, Revoke andits recent access (who opened it, and when), and this machine's Details say how far it is trusted.+## Keep a desktop in the notch++On a Mac, the notch lists the Spaces you can open and the shared desktop of each+of your other machines. A desktop tile reads **Desktop** and opens the same+desktop its page under **Machines** does, without creating anything. A machine+that only provides Spaces has no desktop to show, so it is not listed. The+count on the closed notch is the Spaces and desktops that are running; with+none running it disappears.++To keep a desktop or a Space in front, choose **Pin to notch** from its **⋯**+menu, on **Spaces** or on the machine's page under **Machines**, and **Unpin+from notch** to let it go. Pinned tiles come first, in the order you pinned+them, then the rest as usual. A pinned desktop whose machine is off, or no+longer shares its desktop, stays on the notch dimmed and says **Offline** or+**Not shared**, and it is not counted. Pinning only changes what the notch+shows: it doesn't turn sharing on or give anyone access. Pins are saved in the+app's settings on that Mac.+## Share it with your team`--allow` at setup, or later from an enrolled device, shares the computer withdiff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/menu-count.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/menu-count.jsonindex 4c70caef30..b94612a802 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/menu-count.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/menu-count.json@@ -56,28 +56,28 @@{"agree": true,"case": "remote spaces",- "count": 3,+ "count": 4,"menu": [- "status: 3 Spaces running (disabled)",+ "status: 4 Spaces running (disabled)","open: Open Cua Spaces","new-space: New Space…","settings: Settings…","quit: Quit Cua Spaces"],- "notch": "3"+ "notch": "4"},{"agree": true,"case": "remote spaces and hosting",- "count": 2,+ "count": 3,"menu": [- "status: 2 Spaces running (disabled)",+ "status: 3 Spaces running (disabled)","open: Open Cua Spaces","new-space: New Space…","settings: Settings…","quit: Quit Cua Spaces"],- "notch": "2"+ "notch": "3"},{"agree": true,diff --git a/libs/cua/crates/cua-spaces-app-core/parity/menu-count.json b/libs/cua/crates/cua-spaces-app-core/parity/menu-count.jsonindex a95dd2ed0d..fcac16b8f7 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/menu-count.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/menu-count.json@@ -1,6 +1,6 @@{"name": "menu-count",- "about": "The menu bar item and the notch tab count the same Spaces, the ones on or starting (a stopped Space is not counted; never This machine or another machine's own desktop, even while it provides Spaces; the Spaces a machine provides count), and the menu shows Cua Volume's sync state next to the count when sync applies: synced, syncing, conflicts (they open the Volume page) and offline; nothing on this Mac's store with one device; a bucket that has not answered for 30 s is offline.",+ "about": "The menu bar item and the notch tab count the same Spaces, the ones on or starting (a stopped Space is not counted; never This machine; another machine's shared desktop counts while it runs, and a machine with no desktop to show (it only provides Spaces) does not, even while it provides them; the Spaces a machine provides count), and the menu shows Cua Volume's sync state next to the count when sync applies: synced, syncing, conflicts (they open the Volume page) and offline; nothing on this Mac's store with one device; a bucket that has not answered for 30 s is offline.","now": 1800000000000,"cases": [{diff --git a/libs/cua/crates/cua-spaces-app-core/src/dispatch.rs b/libs/cua/crates/cua-spaces-app-core/src/dispatch.rsindex 335137d44b..5f13c71bbf 100644--- a/libs/cua/crates/cua-spaces-app-core/src/dispatch.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/dispatch.rs@@ -222,6 +222,7 @@ pub const METHODS: &[&str] = &["about.allowedChannels","notch.layout","notch.tiles",+ "notch.togglePin","notch.initial","notch.reduce","notch.view",@@ -1103,9 +1104,15 @@ pub fn call_value(method: &str, args: Value) -> Result<Value, CoreError> {&a.get("screen")?,a.get::<Option<bool>>("prompt")?.unwrap_or(false),)),- "notch.tiles" => out(notch::tiles(+ "notch.tiles" => out(notch::tiles_pinned(&a.get::<Vec<Space>>("spaces")?,a.get::<Option<String>>("targeted")?.as_deref(),+ "",+ &a.get::<Option<Vec<String>>>("pinned")?.unwrap_or_default(),+ )),+ "notch.togglePin" => out(notch::toggle_pin(+ &a.get::<Option<Vec<String>>>("pinned")?.unwrap_or_default(),+ &a.get::<String>("id")?,)),"notch.initial" => out(notch::NotchState::default()),"notch.reduce" => out(notch::reduce(&a.get("state")?, &a.get("event")?)),diff --git a/libs/cua/crates/cua-spaces-app-core/src/machines.rs b/libs/cua/crates/cua-spaces-app-core/src/machines.rsindex b1472f7feb..3b5d8afa72 100644--- a/libs/cua/crates/cua-spaces-app-core/src/machines.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/machines.rs@@ -464,7 +464,7 @@ fn shares_own_desktop(spaces: &[Space], space_id: Option<&str>, current: bool, l/// A Space's error says its machine refused because its owner stopped/// sharing it (the web UI's `STOPPED_SHARING_ERROR`).-fn says_stopped_sharing(space: &Space) -> bool {+pub(crate) fn says_stopped_sharing(space: &Space) -> bool {space.sdk.as_ref()diff --git a/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rsindex fd0113c727..e6b94c693b 100644--- a/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/notch/mod.rs@@ -30,7 +30,7 @@ pub use geometry::{DisplayStyle, DisplayStyleSource, LogicalRect, Size, WindowMouse crate::host::THIS_MACHINE_ID;use crate::model::{Space, SpaceOs, SpaceStatus};-use crate::spaces::sort_by_mru;+use crate::spaces::{DesktopAvailability, desktop_availability, is_remote_desktop, sort_by_mru};use crate::teleport::drag::{self, DragOverlayEffect, DragOverlayEvent, DragOverlayPhase, DragOverlayState,};@@ -317,6 +317,19 @@ pub struct NotchTile {/// Signed in through the Keyvault (and not dismissed): the key badge.#[serde(default)]pub signed_in: bool,+ /// One of your other machines' desktops, not a Space it provides: the+ /// tile reads "Desktop" and opens the same desktop the machine's page+ /// does, creating nothing.+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]+ pub desktop: bool,+ /// Pinned to the notch (Pin to notch in the Space's "..." menu): the+ /// tiles list pinned ones first.+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]+ pub pinned: bool,+ /// Why a pinned desktop cannot be opened now ("Offline", "Not+ /// shared"); `None` while it can. The tile stays, dimmed, and says it.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub note: Option<String>,}/// Linux distributions with their own icon: a word in the reported OS@@ -490,52 +503,134 @@ pub fn filter(spaces: &[Space], query: &str) -> Vec<Space> {}/// The Space tiles: the Spaces the user can open-/// ([`crate::spaces::openable_spaces`], never This machine or another-/// machine that only provides Spaces), in MRU order, at most-/// [`MAX_TILES`]. Stopped Spaces are tiles too (dimmed, and they take-/// drops), but the tab counts only the ones that are on.+/// ([`crate::spaces::openable_spaces`]: Spaces, and the desktops of your+/// other machines that are there to open; never This machine or a machine+/// that only provides Spaces), in MRU order, at most [`MAX_TILES`]. Stopped+/// Spaces are tiles too (dimmed, and they take drops), but the tab counts+/// only the ones that are on.pub fn tiles(spaces: &[Space], targeted: Option<&str>) -> Vec<NotchTile> {tiles_matching(spaces, targeted, "")}/// [`tiles`] narrowed by the header's search.pub fn tiles_matching(spaces: &[Space], targeted: Option<&str>, query: &str) -> Vec<NotchTile> {- sort_by_mru(&crate::spaces::openable_spaces(spaces))+ tiles_pinned(spaces, targeted, query, &[])+}++/// Whether `space` gets a tile: a Space you can open, and a pinned desktop+/// of another machine even when it cannot be opened now (offline, or no+/// longer shared), so a pin is never silently dropped.+fn has_tile(space: &Space, pinned: &[String]) -> bool {+ !crate::spaces::is_machine_desktop(space)+ || (is_remote_desktop(space)+ && (desktop_availability(space) == DesktopAvailability::Available+ || pinned.contains(&space.id)))+}++/// [`tiles_matching`] with the pinned Spaces and desktops (`pinned`, in the+/// order they were pinned): pinned tiles first, then the rest in MRU order.+/// A pinned desktop that is offline or no longer shared stays, dimmed, with+/// its note ([`NotchTile::note`]). A pinned id that is no longer in+/// `spaces` has nothing to draw and is skipped.+pub fn tiles_pinned(+ spaces: &[Space],+ targeted: Option<&str>,+ query: &str,+ pinned: &[String],+) -> Vec<NotchTile> {+ let listed: Vec<Space> = spaces+ .iter()+ .filter(|s| has_tile(s, pinned))+ .cloned()+ .collect();+ let mut sorted = sort_by_mru(&listed);+ // Pinned first, in pin order; the rest keep their MRU order.+ sorted.sort_by_key(|s| pinned.iter().position(|p| *p == s.id).unwrap_or(usize::MAX));+ sorted.into_iter().filter(|s| matches(s, query)).take(MAX_TILES)- .map(|s| NotchTile {- location: location(&s, spaces),- dim: !s.status.is_live(),- drop_target: accepts_drop(&s),- targeted: targeted == Some(s.id.as_str()),- symbol: os_icon(s.os, s.os_name.as_deref()).into(),- label: format!(- "{}, {}, {}, {}",- s.name,- s.os.label(),- location(&s, spaces),- crate::spaces::sidebar::status_text(&s)- ),- progress: s- .progress- .as_ref()- .filter(|p| p.error.is_none())- .map(|p| p.permille),- progress_label: if s.status == SpaceStatus::Deleting {- Some(s.status.label().into())+ .map(|s| {+ let desktop = is_remote_desktop(&s);+ let note = if desktop {+ match desktop_availability(&s) {+ DesktopAvailability::Available => None,+ DesktopAvailability::Offline => Some("Offline".to_string()),+ DesktopAvailability::NotShared => Some("Not shared".to_string()),+ }} else {- s.progress.as_ref().map(|p| p.label.clone())- },- signed_in: false,- id: s.id,- name: s.name,- os: s.os,- status: s.status,+ None+ };+ let status_text = note+ .clone()+ .unwrap_or_else(|| crate::spaces::sidebar::status_text(&s));+ let place = if desktop {+ "Desktop".to_string()+ } else {+ location(&s, spaces)+ };+ NotchTile {+ dim: !s.status.is_live() || note.is_some(),+ drop_target: accepts_drop(&s) && note.is_none(),+ targeted: targeted == Some(s.id.as_str()),+ symbol: os_icon(s.os, s.os_name.as_deref()).into(),+ label: format!(+ "{}, {}, {}, {}{}",+ s.name,+ s.os.label(),+ if desktop { "desktop" } else { place.as_str() },+ status_text,+ if pinned.contains(&s.id) {+ ", pinned"+ } else {+ ""+ }+ ),+ location: place,+ progress: s+ .progress+ .as_ref()+ .filter(|p| p.error.is_none())+ .map(|p| p.permille),+ progress_label: if s.status == SpaceStatus::Deleting {+ Some(s.status.label().into())+ } else {+ s.progress.as_ref().map(|p| p.label.clone())+ },+ signed_in: false,+ desktop,+ pinned: pinned.contains(&s.id),+ note,+ id: s.id,+ name: s.name,+ os: s.os,+ status: s.status,+ }}).collect()}+/// The most Spaces and desktops that stay pinned to the notch.+pub const MAX_PINNED: usize = 24;++/// `pinned` with `id` pinned (added last) or, when it already is, unpinned.+/// Only ids the notch can show are pinned: not This machine, and not an+/// empty id. Beyond [`MAX_PINNED`] the oldest pin makes room.+pub fn toggle_pin(pinned: &[String], id: &str) -> Vec<String> {+ if pinned.iter().any(|p| p == id) {+ return pinned.iter().filter(|p| *p != id).cloned().collect();+ }+ if id.is_empty() || id == THIS_MACHINE_ID {+ return pinned.to_vec();+ }+ let mut out = pinned.to_vec();+ out.push(id.to_string());+ while out.len() > MAX_PINNED {+ out.remove(0);+ }+ out+}+/// What the panel shows.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]@@ -581,6 +676,10 @@ pub struct NotchState {/// carry the key.#[serde(default, skip_serializing_if = "Vec::is_empty")]pub signed_in: Vec<String>,+ /// The Spaces and desktops pinned to the notch, in the order they were+ /// pinned (`AppSettings::notch_pinned`): their tiles come first.+ #[serde(default, skip_serializing_if = "Vec::is_empty")]+ pub pinned: Vec<String>,/// "Spaces tab in the notch: Hide" (menu bar only): nothing shows in/// the notch, and hover, clicks and window drags do nothing.#[serde(default)]@@ -612,6 +711,7 @@ impl Default for NotchState {transfer: None,keyvault: None,signed_in: vec![],+ pinned: vec![],hidden: false,}}@@ -677,6 +777,13 @@ pub enum NotchEvent {#[serde(default, rename = "signedIn")]signed_in: Vec<String>,},+ /// The pinned Spaces and desktops changed (Pin to notch, Unpin from+ /// notch, or settings read at start): their ids in pin order.+ Pinned {+ /// The pinned ids.+ #[serde(default)]+ ids: Vec<String>,+ },}/// Something the shell must do.@@ -825,6 +932,9 @@ pub fn reduce(state: &NotchState, event: &NotchEvent) -> NotchTransition {s.keyvault = label.clone();s.signed_in = signed_in.clone();}+ NotchEvent::Pinned { ids } => {+ s.pinned = ids.clone();+ }}// A closed panel forgets its search.if !s.open && !s.drop_targeted && s.drag.phase == DragOverlayPhase::Idle {@@ -1189,6 +1299,24 @@ pub fn accepts_drop(space: &Space) -> bool {&& space.progress.is_none()}+/// The open panel's spoken label: how many Spaces it shows and, when there+/// are any, how many machine desktops ("3 Spaces and 1 desktop"). The tab's+/// count stays the Spaces and desktops that are on ([`tab`]).+fn tiles_label(tiles: &[NotchTile]) -> String {+ let desktops = tiles.iter().filter(|t| t.desktop).count();+ let spaces = tiles.len() - desktops;+ let spaces_part = format!("{spaces} {}", if spaces == 1 { "Space" } else { "Spaces" });+ let desktops_part = format!(+ "{desktops} {}",+ if desktops == 1 { "desktop" } else { "desktops" }+ );+ match (spaces, desktops) {+ (_, 0) => spaces_part,+ (0, _) => desktops_part,+ _ => format!("{spaces_part} and {desktops_part}"),+ }+}+/// The panel as drawn for `spaces`.pub fn view(state: &NotchState, spaces: &[Space]) -> NotchView {let phase = match state.drag.phase {@@ -1210,7 +1338,12 @@ pub fn view(state: &NotchState, spaces: &[Space]) -> NotchView {// A drag drops on any Space: the search only narrows browsing.let query = if drop_mode { "" } else { state.query.trim() };let mut visible = if phase == NotchPhase::Tiles {- tiles_matching(spaces, state.drag.target_space_id.as_deref(), query)+ tiles_pinned(+ spaces,+ state.drag.target_space_id.as_deref(),+ query,+ &state.pinned,+ )} else {Vec::new()};@@ -1271,7 +1404,7 @@ pub fn view(state: &NotchState, spaces: &[Space]) -> NotchView {label: match phase {NotchPhase::Closed => "Cua Spaces".into(),NotchPhase::Prompt => "Teleport to Cua".into(),- NotchPhase::Tiles => format!("{n} {}", if n == 1 { "Space" } else { "Spaces" }),+ NotchPhase::Tiles => tiles_label(&visible),},tiles: visible,drop_mode,@@ -2154,4 +2287,269 @@ mod tests {Some("a"));}++ // ---- Machine desktops and pins ---------------------------------------++ /// One of your other machines (`relay:<machine>`, no host above it) as+ /// the registry reads it: `features` it reported, answering or not.+ fn machine(id: &str, name: &str, features: &[&str], reachable: bool) -> Space {+ let mut s = space(+ &format!("relay:{id}"),+ name,+ SpaceOs::Linux,+ if reachable {+ SpaceStatus::Running+ } else {+ SpaceStatus::Suspended+ },+ );+ s.provider = Some(crate::model::SpaceProvider::Relay);+ s.sdk = Some(crate::model::SpaceSdkRef {+ features: features.iter().map(|f| f.to_string()).collect(),+ spacesd_version: "0.9.0".into(),+ reachable,+ error: None,+ });+ s+ }++ const SHARES: &[&str] = &["desktop_stream", "window_stream", "host_spaces"];+ const SPACES_ONLY: &[&str] = &["host_spaces", "files"];++ fn ids(t: &[NotchTile]) -> Vec<String> {+ t.iter().map(|t| t.id.clone()).collect()+ }++ /// A machine's shared desktop is a Space and shows by default; a machine+ /// without a desktop (it only provides Spaces, is off, or has not+ /// answered) is not one and stays out, as before (CUA-1619).+ #[test]+ fn a_shared_desktop_shows_and_a_machine_without_one_does_not() {+ let wsl = machine("wsl", "WSL", SHARES, true);+ let studio = machine("studio", "Studio", SPACES_ONLY, true);+ let off = machine("old", "Old Mac", SHARES, false);+ let mut silent = machine("new", "New Mac", &[], false);+ silent.sdk = None;+ let this_mac = crate::host::this_machine_space(None, 0, SpaceOs::Macos);+ let spaces = vec![this_mac, wsl, studio, off, silent];++ let t = tiles(&spaces, None);+ assert_eq!(ids(&t), ["relay:wsl"]);+ // It reads as a desktop, not a Space, and names nothing unavailable.+ assert!(t[0].desktop && !t[0].pinned && t[0].note.is_none());+ assert_eq!(t[0].location, "Desktop");+ assert_eq!(t[0].label, "WSL, Linux, desktop, Running");+ assert!(!t[0].dim && t[0].drop_target);+ // One that answers without saying what it shares has no desktop to list.+ let silent = machine("mini", "Mini", &[], true);+ assert!(tiles(&[silent], None).is_empty());+ // A Space a machine provides is a Space as ever.+ let mut provided = machine("studio/dev", "Dev", SHARES, true);+ provided.host = Some("studio".into());+ assert_eq!(ids(&tiles(&[provided], None)), ["relay:studio/dev"]);+ }++ /// A shared desktop that is running counts as a Space; one that is off,+ /// or that no longer shares, counts as nothing. Pinning changes no count.+ #[test]+ fn a_running_desktop_counts_like_a_space_and_the_tab_collapses_at_zero() {+ let wsl = machine("wsl", "WSL", SHARES, true);+ let tab = |spaces: &[Space]| super::tab(spaces).count;+ assert_eq!(tab(std::slice::from_ref(&wsl)), "1");+ assert_eq!(crate::spaces::on_count(std::slice::from_ref(&wsl)), 1);+ let mut local = space("local:a", "A", SpaceOs::Linux, SpaceStatus::Running);+ local.provider = Some(crate::model::SpaceProvider::Local);+ assert_eq!(tab(&[wsl.clone(), local.clone()]), "2");++ let off = machine("wsl", "WSL", SHARES, false);+ let unshared = machine("wsl", "WSL", SPACES_ONLY, true);+ let pinned = NotchState {+ pinned: vec!["relay:wsl".into()],+ ..Default::default()+ };+ for spaces in [vec![off], vec![unshared]] {+ assert_eq!(tab(&spaces), "0");+ // The counter collapses: no tab on the closed notch, though the+ // pinned desktop's tile is there once it opens.+ let closed = view(&pinned, &spaces);+ assert!(!closed.show_tab && closed.count_label == "0 Spaces");+ let open = view(+ &NotchState {+ open: true,+ ..pinned.clone()+ },+ &spaces,+ );+ assert_eq!(ids(&open.tiles), ["relay:wsl"]);+ assert_eq!(open.count_label, "0 Spaces");+ assert_eq!(open.label, "1 desktop");+ }+ // The desktop is on: the tab shows 1 whether or not it is pinned.+ let on = view(&pinned, std::slice::from_ref(&wsl));+ assert!(on.show_tab && on.tab.count == "1");+ assert_eq!(on.count_label, "1 Space");+ }++ #[test]+ fn pinned_tiles_come_first_in_pin_order_then_the_usual_order() {+ let mut a = space("local:a", "A", SpaceOs::Linux, SpaceStatus::Running);+ let mut b = space("local:b", "B", SpaceOs::Linux, SpaceStatus::Running);+ let mut c = space("local:c", "C", SpaceOs::Linux, SpaceStatus::Running);+ a.last_used_at = 30;+ b.last_used_at = 20;+ c.last_used_at = 10;+ let mut wsl = machine("wsl", "WSL", SHARES, true);+ wsl.last_used_at = 5;+ let spaces = vec![a, b, c, wsl];+ let order = |pinned: &[&str]| {+ let pinned: Vec<String> = pinned.iter().map(|p| p.to_string()).collect();+ ids(&tiles_pinned(&spaces, None, "", &pinned))+ };+ // MRU alone.+ assert_eq!(order(&[]), ["local:a", "local:b", "local:c", "relay:wsl"]);+ // The pinned first, in the order they were pinned.+ assert_eq!(+ order(&["relay:wsl", "local:c"]),+ ["relay:wsl", "local:c", "local:a", "local:b"]+ );+ let t = tiles_pinned(&spaces, None, "", &["local:c".into()]);+ assert!(t[0].pinned && !t[1].pinned);+ assert!(t[0].label.ends_with(", pinned"));+ // A pin of a Space that is gone draws nothing and breaks nothing.+ assert_eq!(order(&["local:gone", "local:b"])[0], "local:b");+ assert_eq!(order(&["local:gone"]).len(), 4);+ // The search still narrows the pinned ones.+ let pinned: Vec<String> = vec!["relay:wsl".into()];+ assert!(tiles_pinned(&spaces, None, "nothing like it", &pinned).is_empty());+ // Pinned tiles survive the cap: the seventh Space is the one cut.+ let many: Vec<Space> = (0..MAX_TILES + 2)+ .map(|i| {+ let mut s = space(+ &format!("local:{i}"),+ &format!("S{i}"),+ SpaceOs::Linux,+ SpaceStatus::Running,+ );+ s.last_used_at = 100 - i as i64;+ s+ })+ .collect();+ let last = many.last().unwrap().id.clone();+ let t = tiles_pinned(&many, None, "", std::slice::from_ref(&last));+ assert_eq!(t.len(), MAX_TILES);+ assert_eq!(t[0].id, last);+ }++ /// A pinned desktop that is off or no longer shared stays, dimmed, and+ /// says why; it takes no drop. Unpinned, it is gone again.+ #[test]+ fn a_pinned_desktop_that_is_offline_or_not_shared_says_so() {+ let pinned = vec!["relay:wsl".to_string(), "relay:mac".to_string()];+ let off = machine("wsl", "WSL", SHARES, false);+ let unshared = machine("mac", "Mac", SPACES_ONLY, true);+ let spaces = vec![off, unshared];+ assert!(tiles(&spaces, None).is_empty());+ let t = tiles_pinned(&spaces, None, "", &pinned);+ assert_eq!(ids(&t), ["relay:wsl", "relay:mac"]);+ assert_eq!(t[0].note.as_deref(), Some("Offline"));+ assert_eq!(t[1].note.as_deref(), Some("Not shared"));+ for tile in &t {+ assert!(tile.desktop && tile.pinned && tile.dim && !tile.drop_target);+ }+ assert_eq!(t[0].label, "WSL, Linux, desktop, Offline, pinned");+ // It comes back by itself when the machine does.+ let back = machine("wsl", "WSL", SHARES, true);+ let t = tiles_pinned(&[back], None, "", &pinned);+ assert!(t[0].note.is_none() && !t[0].dim);+ // Its owner stopped sharing it with you.+ let mut stopped = machine("wsl", "WSL", SHARES, true);+ stopped.sdk.as_mut().unwrap().error = Some("WSL stopped sharing".into());+ let t = tiles_pinned(&[stopped], None, "", &pinned);+ assert_eq!(t[0].note.as_deref(), Some("Not shared"));+ }++ /// Pinning shows a tile and grants nothing: This machine is never+ /// pinned in, and a pinned machine that has no desktop is not made one.+ #[test]+ fn pinning_does_not_bring_back_this_machine_or_a_machine_without_a_desktop() {+ let this_mac = crate::host::this_machine_space(None, 0, SpaceOs::Macos);+ let provider = machine("studio", "Studio", SPACES_ONLY, true);+ // Studio is pinned, but a machine that only provides Spaces is shown+ // as a pinned desktop that is not shared: the person sees why.+ let pinned = vec![THIS_MACHINE_ID.to_string(), "relay:studio".to_string()];+ let t = tiles_pinned(&[this_mac, provider], None, "", &pinned);+ assert_eq!(ids(&t), ["relay:studio"]);+ assert_eq!(t[0].note.as_deref(), Some("Not shared"));+ }++ #[test]+ fn pins_toggle_in_order_skip_this_machine_and_are_capped() {+ let none: Vec<String> = vec![];+ let one = toggle_pin(&none, "relay:wsl");+ assert_eq!(one, ["relay:wsl"]);+ let two = toggle_pin(&one, "local:a");+ assert_eq!(two, ["relay:wsl", "local:a"]);+ assert_eq!(toggle_pin(&two, "relay:wsl"), ["local:a"]);+ assert_eq!(toggle_pin(&none, THIS_MACHINE_ID), none);+ assert_eq!(toggle_pin(&none, ""), none);+ let mut many = none;+ for i in 0..MAX_PINNED + 3 {+ many = toggle_pin(&many, &format!("local:{i}"));+ }+ assert_eq!(many.len(), MAX_PINNED);+ assert_eq!(many[0], "local:3");+ }++ #[test]+ fn the_pinned_ids_travel_through_the_panel_state() {+ let st = reduce(+ &NotchState::default(),+ &NotchEvent::Pinned {+ ids: vec!["relay:wsl".into()],+ },+ )+ .state;+ assert_eq!(st.pinned, ["relay:wsl"]);+ // Saved with the state, absent when nothing is pinned.+ assert!(+ serde_json::to_value(NotchState::default())+ .unwrap()+ .get("pinned")+ .is_none()+ );+ let ev: NotchEvent =+ serde_json::from_value(serde_json::json!({"type": "pinned", "ids": ["a"]})).unwrap();+ assert_eq!(+ ev,+ NotchEvent::Pinned {+ ids: vec!["a".into()]+ }+ );+ // A hidden notch still learns its pins.+ let hidden = NotchState {+ hidden: true,+ ..Default::default()+ };+ let t = reduce(+ &hidden,+ &NotchEvent::Pinned {+ ids: vec!["x".into()],+ },+ );+ assert_eq!(t.state.pinned, ["x"]);+ }++ #[test]+ fn the_panel_label_names_spaces_and_desktops() {+ let wsl = machine("wsl", "WSL", SHARES, true);+ let a = space("local:a", "A", SpaceOs::Linux, SpaceStatus::Running);+ let open = NotchState {+ open: true,+ ..Default::default()+ };+ assert_eq!(view(&open, std::slice::from_ref(&a)).label, "1 Space");+ assert_eq!(view(&open, std::slice::from_ref(&wsl)).label, "1 desktop");+ assert_eq!(view(&open, &[a, wsl]).label, "1 Space and 1 desktop");+ assert_eq!(view(&open, &[]).label, "0 Spaces");+ }}diff --git a/libs/cua/crates/cua-spaces-app-core/src/settings.rs b/libs/cua/crates/cua-spaces-app-core/src/settings.rsindex 66d1681c49..8466e14a0e 100644--- a/libs/cua/crates/cua-spaces-app-core/src/settings.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/settings.rs@@ -77,6 +77,11 @@ pub struct AppSettings {/// longer shows them, nothing is revoked or wiped/// ([`crate::keyvault::view::prune_dismissed`] forgets the gone ones).pub dismissed_access: Vec<String>,+ /// The Spaces and the machines' desktops pinned to the notch ("Pin to+ /// notch" in a Space's "..." menu), in the order they were pinned: the+ /// notch lists them first ([`crate::notch::tiles_pinned`]). Ids only,+ /// nothing secret; an id whose Space is gone is kept and draws nothing.+ pub notch_pinned: Vec<String>,/// Keyvault rows may load a site's icon from Google's favicon service/// when the source browser had none (Settings, Keyvault; on by default)./// Off, only icons read locally are shown.@@ -112,6 +117,7 @@ impl Default for AppSettings {experiments: Experiments::default(),new_ui: None,dismissed_access: vec![],+ notch_pinned: vec![],keyvault_site_icons: true,teleport_choices: vec![],auto_connect: true,@@ -1268,6 +1274,26 @@ mod tests {// A settings file from before dismissals: none dismissed.let old: AppSettings = serde_json::from_str(r#"{"menuBar":true}"#).unwrap();assert!(old.dismissed_access.is_empty());+ assert!(old.notch_pinned.is_empty());+ }++ /// Pins to the notch are a per-user preference kept in the settings+ /// file: they survive a restart in the order they were made.+ #[test]+ fn notch_pins_survive_a_restart() {+ let dir = tempfile::tempdir().unwrap();+ let path = dir.path().join("settings.json");+ let s = AppSettings {+ notch_pinned: vec!["relay:wsl".into(), "local:dev".into()],+ ..AppSettings::default()+ };+ save(&path, &s).unwrap();+ assert!(+ std::fs::read_to_string(&path)+ .unwrap()+ .contains("\"notchPinned\"")+ );+ assert_eq!(load(&path).notch_pinned, ["relay:wsl", "local:dev"]);}#[test]diff --git a/libs/cua/crates/cua-spaces-app-core/src/space_menu.rs b/libs/cua/crates/cua-spaces-app-core/src/space_menu.rsindex cc028db31e..dd8c7c9ac7 100644--- a/libs/cua/crates/cua-spaces-app-core/src/space_menu.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/space_menu.rs@@ -19,6 +19,11 @@//! Teleport an app… stays in the menu while the Space is off, greyed: it//! needs a running desktop.//!+//! Pin to notch / Unpin from notch is in every menu that can pin (a Space,+//! and the desktop of one of your other machines), whatever your role: it+//! keeps a tile in the notch first in line and grants nothing. It comes+//! after the Space's own actions, above the set-apart Delete or Leave.+//!//! The input is its own plain record (the page builds it from the Space's//! sharing facts), so the rule does not depend on how a shell keeps them.@@ -90,6 +95,10 @@ pub struct SpaceMenuInput {pub can_delete: bool,/// You may leave it.pub can_leave: bool,+ /// It can be pinned to the notch (not This machine).+ pub can_pin: bool,+ /// It is pinned to the notch now (Unpin from notch).+ pub pinned: bool,}/// What an item does.@@ -112,6 +121,8 @@ pub enum SpaceMenuItemId {Delete,/// Leaves it (asks first: `spaces.bulkConfirm`).Leave,+ /// Pins it to the notch, or unpins it (the label says which).+ Pin,}/// One menu item.@@ -174,6 +185,16 @@ pub fn menu(input: &SpaceMenuInput) -> Vec<SpaceMenuItem> {if mine && input.can_rename && !viewer {items.push(item(Rename, "Rename"));}+ if input.can_pin {+ items.push(item(+ Pin,+ if input.pinned {+ "Unpin from notch"+ } else {+ "Pin to notch"+ },+ ));+ }let delete = match input.kind {SpaceMenuKind::Mine => input.can_delete,SpaceMenuKind::Team => input.maker && input.can_delete,@@ -376,6 +397,52 @@ mod tests {assert_eq!(lines(&m), ["Open", "--- Leave"]);}+ #[test]+ fn pin_to_notch_is_in_every_menu_that_can_pin_above_delete_and_leave() {+ let pin = |input: SpaceMenuInput| lines(&menu(&input));+ assert_eq!(+ pin(SpaceMenuInput {+ can_pin: true,+ ..mine()+ }),+ [+ "Open",+ "Turn off",+ "Share\u{2026}",+ "Teleport an app\u{2026}",+ "Rename",+ "Pin to notch",+ "--- Delete Space (red)"+ ]+ );+ assert_eq!(+ pin(SpaceMenuInput {+ can_pin: true,+ pinned: true,+ ..mine()+ })[5],+ "Unpin from notch"+ );+ // Someone else's Space, even a watch-only one: it grants nothing.+ let viewer = SpaceMenuInput {+ kind: SpaceMenuKind::WithMe,+ role: SpaceMenuRole::Viewer,+ can_leave: true,+ can_pin: true,+ ..Default::default()+ };+ assert_eq!(pin(viewer), ["Open", "Pin to notch", "--- Leave"]);+ // One of your other machines' desktops: not a Space to power, share+ // or delete, so just Open and the pin.+ let desktop = SpaceMenuInput {+ can_pin: true,+ ..Default::default()+ };+ assert_eq!(pin(desktop), ["Open", "Pin to notch"]);+ // Nothing offers it where it cannot pin (This machine).+ assert_eq!(pin(SpaceMenuInput::default()), ["Open"]);+ }+#[test]fn ids_and_words_on_the_wire() {let v = serde_json::to_value(menu(&SpaceMenuInput {diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rsindex 45d9121b13..fb76634c19 100644--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs@@ -400,15 +400,63 @@ pub fn is_machine_desktop(space: &Space) -> bool {.is_some_and(|own| !own.is_empty() && !own.contains('/') && !own.starts_with("space-"))}-/// The Spaces the user can open, in `spaces`' order: every Space but the-/// machines' own desktops ([`is_machine_desktop`]): not This machine, even-/// while it provides Spaces, and not one of your machines on the relay. A-/// Space a machine provides is listed. The notch's tiles list these; its-/// tab and the menu bar item count the ones that are on ([`on_count`]).+/// Whether `space` is the desktop of one of your other machines, reached+/// through the relay (`relay:<machine>`, no host above it): a machine's+/// own desktop that is not This machine's. A Space the machine provides is+/// a Space, not this.+pub fn is_remote_desktop(space: &Space) -> bool {+ is_machine_desktop(space) && space.id.starts_with("relay:")+}++/// Whether a machine's desktop can be opened right now.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub enum DesktopAvailability {+ /// The machine answers and says it shares its desktop.+ Available,+ /// The machine does not answer, or has not said what it shares.+ Offline,+ /// The machine answers but does not share its desktop (it only+ /// provides Spaces, or shares neither), or its owner stopped sharing+ /// it with you.+ NotShared,+}++/// Whether the other machine's desktop `space` can be opened: the machine+/// answers and its features say it streams its desktop+/// ([`feature::DESKTOP_STREAM`]). Without that evidence there is no+/// desktop to list, so a machine that has not said what it shares stays+/// out, as before (#5190).+pub fn desktop_availability(space: &Space) -> DesktopAvailability {+ if crate::machines::says_stopped_sharing(space) || sidebar::shares_desktop(space) == Some(false)+ {+ return DesktopAvailability::NotShared;+ }+ match &space.sdk {+ Some(sdk) if sdk.reachable && has_feature(space, feature::DESKTOP_STREAM) => {+ DesktopAvailability::Available+ }+ _ => DesktopAvailability::Offline,+ }+}++/// The Spaces the user can open, in `spaces`' order: every Space, and the+/// desktops of your other machines while they are there to open+/// ([`desktop_availability`] is `Available`): a shared desktop is a Space.+/// Not This machine, even while it provides Spaces, and not a machine that+/// has no desktop to open (it only provides Spaces, is off or has not+/// answered): the notch listed those as if they were Spaces (#5190). A Space a machine+/// provides is listed. The notch's tiles list these (and the desktops a+/// person pinned, [`crate::notch::tiles_matching`]); its tab and the menu+/// bar item count the ones that are on ([`on_count`]).pub fn openable_spaces(spaces: &[Space]) -> Vec<Space> {spaces.iter()- .filter(|s| !is_machine_desktop(s))+ .filter(|s| {+ !is_machine_desktop(s)+ || (is_remote_desktop(s)+ && desktop_availability(s) == DesktopAvailability::Available)+ }).cloned().collect()}@@ -860,6 +908,65 @@ mod tests {assert_eq!(openable_count(&[idle]), 0);}+ /// The desktop of one of your other machines is a Space while it is+ /// there to open: shown and counted when it runs. A machine with no+ /// desktop to open (it only provides Spaces, is off, or has not+ /// answered) and This machine are not.+ #[test]+ fn a_shared_desktop_is_a_space_and_a_machine_without_one_is_not() {+ use crate::host::this_machine_space;+ let machine = |id: &str, features: &[&str], reachable: bool| {+ let mut r = row();+ r.id = format!("relay:{id}");+ r.provider = "relay".into();+ r.features = features.iter().map(|f| f.to_string()).collect();+ r.reachable = reachable;+ row_to_space(&r, 0)+ };+ let shared = machine("wsl", &["desktop_stream", "host_spaces"], true);+ let spaces_only = machine("studio", &["host_spaces", "files"], true);+ let off = machine("old", &["desktop_stream"], false);+ // Answers, but has not said what it shares: no desktop to list.+ let silent = machine("mini", &[], true);+ for (space, want) in [+ (&shared, DesktopAvailability::Available),+ (&spaces_only, DesktopAvailability::NotShared),+ (&off, DesktopAvailability::Offline),+ (&silent, DesktopAvailability::Offline),+ ] {+ assert!(is_machine_desktop(space) && is_remote_desktop(space));+ assert_eq!(desktop_availability(space), want, "{}", space.id);+ }+ let this_mac = this_machine_space(None, 0, SpaceOs::Macos);+ assert!(is_machine_desktop(&this_mac) && !is_remote_desktop(&this_mac));+ let ids = |v: Vec<Space>| v.into_iter().map(|s| s.id).collect::<Vec<_>>();+ let all = vec![+ this_mac,+ shared.clone(),+ spaces_only.clone(),+ off.clone(),+ silent.clone(),+ ];+ assert_eq!(+ ids(openable_spaces(&all)),+ ["relay:wsl"],+ "only the desktops there to open"+ );+ // A running one counts like a Space; the off one, the one that+ // keeps its desktop to itself and the silent one do not.+ assert_eq!(openable_count(&all), 1);+ assert_eq!(on_count(&all), 1);+ assert_eq!(on_count(&[off, spaces_only]), 0);+ // A Space a machine provides is a Space either way.+ let mut provided = row();+ provided.id = "relay:wsl/dev".into();+ provided.provider = "relay".into();+ provided.host = Some("wsl".into());+ let provided = row_to_space(&provided, 0);+ assert!(!is_remote_desktop(&provided));+ assert_eq!(ids(openable_spaces(&[provided])), ["relay:wsl/dev"]);+ }+/// The notch and the menu bar count the Spaces on or starting, never a/// stopped one or This machine; the tiles still list the stopped ones.#[test]diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core.rsindex 109dc08c32..f44d1e1a33 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core.rs@@ -1522,6 +1522,13 @@ pub fn app_notch_view(state: AppNotchState, spaces: Vec<AppSpace>) -> AppNotchVicore::notch::view(&state, &spaces)}+/// `pinned` (the notch's pins, in pin order) with `id` pinned or, when it+/// already is, unpinned: Pin to notch and Unpin from notch.+#[uniffi::export]+pub fn app_notch_toggle_pin(pinned: Vec<String>, id: String) -> Vec<String> {+ core::notch::toggle_pin(&pinned, &id)+}+/// The springs and delays every shell animates with.#[uniffi::export]pub fn app_notch_motion() -> AppNotchMotion {diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rsindex 2814b33421..214bb3260f 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs@@ -1838,6 +1838,16 @@ pub struct AppNotchTile {pub progress_label: Option<String>,/// Signed in through the Keyvault (and not dismissed): the key badge.pub signed_in: bool,+ /// One of your other machines' desktops, not a Space it provides: the+ /// tile reads "Desktop" and opens the same desktop the machine's page+ /// does, creating nothing.+ pub desktop: bool,+ /// Pinned to the notch (Pin to notch in the Space's "..." menu): the+ /// tiles list pinned ones first.+ pub pinned: bool,+ /// Why a pinned desktop cannot be opened now ("Offline", "Not+ /// shared"); `None` while it can. The tile stays, dimmed, and says it.+ pub note: Option<String>,}/// What the panel shows.@@ -1880,6 +1890,9 @@ pub struct AppNotchState {/// dismissed ([`crate::keyvault::view::signed_in_spaces`]): their tiles/// carry the key.pub signed_in: Vec<String>,+ /// The Spaces and desktops pinned to the notch, in the order they were+ /// pinned (`AppSettings::notch_pinned`): their tiles come first.+ pub pinned: Vec<String>,/// "Spaces tab in the notch: Hide" (menu bar only): nothing shows in/// the notch, and hover, clicks and window drags do nothing.pub hidden: bool,@@ -1942,6 +1955,12 @@ pub enum AppNotchEvent {/// The Space ids signed in (their tiles carry the key).signed_in: Vec<String>,},+ /// The pinned Spaces and desktops changed (Pin to notch, Unpin from+ /// notch, or settings read at start): their ids in pin order.+ Pinned {+ /// The pinned ids.+ ids: Vec<String>,+ },}/// Something the shell must do.@@ -7037,6 +7056,11 @@ pub struct AppSettings {/// longer shows them, nothing is revoked or wiped/// ([`crate::keyvault::view::prune_dismissed`] forgets the gone ones).pub dismissed_access: Vec<String>,+ /// The Spaces and the machines' desktops pinned to the notch ("Pin to+ /// notch" in a Space's "..." menu), in the order they were pinned: the+ /// notch lists them first ([`crate::notch::tiles_pinned`]). Ids only,+ /// nothing secret; an id whose Space is gone is kept and draws nothing.+ pub notch_pinned: Vec<String>,/// Keyvault rows may load a site's icon from Google's favicon service/// when the source browser had none (Settings, Keyvault; on by default)./// Off, only icons read locally are shown.@@ -11070,6 +11094,10 @@ pub struct AppSpaceMenuInput {pub can_delete: bool,/// You may leave it.pub can_leave: bool,+ /// It can be pinned to the notch (not This machine).+ pub can_pin: bool,+ /// It is pinned to the notch now (Unpin from notch).+ pub pinned: bool,}/// What an item does.@@ -11092,6 +11120,8 @@ pub enum AppSpaceMenuItemId {Delete,/// Leaves it (asks first: `spaces.bulkConfirm`).Leave,+ /// Pins it to the notch, or unpins it (the label says which).+ Pin,}/// One menu item.diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex 0cb4bff49b..85872473a2 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -27125,6 +27125,11 @@ public struct AppNotchState: Equatable, Hashable {* carry the key.*/public var signedIn: [String]+ /**+ * The Spaces and desktops pinned to the notch, in the order they were+ * pinned (`AppSettings::notch_pinned`): their tiles come first.+ */+ public var pinned: [String]/*** "Spaces tab in the notch: Hide" (menu bar only): nothing shows in* the notch, and hover, clicks and window drags do nothing.@@ -27168,6 +27173,10 @@ public struct AppNotchState: Equatable, Hashable {* dismissed ([`crate::keyvault::view::signed_in_spaces`]): their tiles* carry the key.*/signedIn: [String],+ /**+ * The Spaces and desktops pinned to the notch, in the order they were+ * pinned (`AppSettings::notch_pinned`): their tiles come first.+ */pinned: [String],/*** "Spaces tab in the notch: Hide" (menu bar only): nothing shows in* the notch, and hover, clicks and window drags do nothing.@@ -27182,6 +27191,7 @@ public struct AppNotchState: Equatable, Hashable {self.transfer = transferself.keyvault = keyvaultself.signedIn = signedIn+ self.pinned = pinnedself.hidden = hidden}@@ -27211,6 +27221,7 @@ public struct FfiConverterTypeAppNotchState: FfiConverterRustBuffer {transfer: FfiConverterOptionTypeAppNotchTransfer.read(from: &buf),keyvault: FfiConverterOptionString.read(from: &buf),signedIn: FfiConverterSequenceString.read(from: &buf),+ pinned: FfiConverterSequenceString.read(from: &buf),hidden: FfiConverterBool.read(from: &buf))}@@ -27226,6 +27237,7 @@ public struct FfiConverterTypeAppNotchState: FfiConverterRustBuffer {FfiConverterOptionTypeAppNotchTransfer.write(value.transfer, into: &buf)FfiConverterOptionString.write(value.keyvault, into: &buf)FfiConverterSequenceString.write(value.signedIn, into: &buf)+ FfiConverterSequenceString.write(value.pinned, into: &buf)FfiConverterBool.write(value.hidden, into: &buf)}}@@ -27371,6 +27383,22 @@ public struct AppNotchTile: Equatable, Hashable {* Signed in through the Keyvault (and not dismissed): the key badge.*/public var signedIn: Bool+ /**+ * One of your other machines' desktops, not a Space it provides: the+ * tile reads "Desktop" and opens the same desktop the machine's page+ * does, creating nothing.+ */+ public var desktop: Bool+ /**+ * Pinned to the notch (Pin to notch in the Space's "..." menu): the+ * tiles list pinned ones first.+ */+ public var pinned: Bool+ /**+ * Why a pinned desktop cannot be opened now ("Offline", "Not+ * shared"); `None` while it can. The tile stays, dimmed, and says it.+ */+ public var note: String?// Default memberwise initializers are never public by default, so we// declare one manually.@@ -27419,7 +27447,20 @@ public struct AppNotchTile: Equatable, Hashable {*/progressLabel: String?,/*** Signed in through the Keyvault (and not dismissed): the key badge.- */signedIn: Bool) {+ */signedIn: Bool,+ /**+ * One of your other machines' desktops, not a Space it provides: the+ * tile reads "Desktop" and opens the same desktop the machine's page+ * does, creating nothing.+ */desktop: Bool,+ /**+ * Pinned to the notch (Pin to notch in the Space's "..." menu): the+ * tiles list pinned ones first.+ */pinned: Bool,+ /**+ * Why a pinned desktop cannot be opened now ("Offline", "Not+ * shared"); `None` while it can. The tile stays, dimmed, and says it.+ */note: String?) {self.id = idself.name = nameself.os = os@@ -27433,6 +27474,9 @@ public struct AppNotchTile: Equatable, Hashable {self.progress = progressself.progressLabel = progressLabelself.signedIn = signedIn+ self.desktop = desktop+ self.pinned = pinned+ self.note = note}@@ -27463,7 +27507,10 @@ public struct FfiConverterTypeAppNotchTile: FfiConverterRustBuffer {location: FfiConverterString.read(from: &buf),progress: FfiConverterOptionUInt32.read(from: &buf),progressLabel: FfiConverterOptionString.read(from: &buf),- signedIn: FfiConverterBool.read(from: &buf)+ signedIn: FfiConverterBool.read(from: &buf),+ desktop: FfiConverterBool.read(from: &buf),+ pinned: FfiConverterBool.read(from: &buf),+ note: FfiConverterOptionString.read(from: &buf))}@@ -27481,6 +27528,9 @@ public struct FfiConverterTypeAppNotchTile: FfiConverterRustBuffer {FfiConverterOptionUInt32.write(value.progress, into: &buf)FfiConverterOptionString.write(value.progressLabel, into: &buf)FfiConverterBool.write(value.signedIn, into: &buf)+ FfiConverterBool.write(value.desktop, into: &buf)+ FfiConverterBool.write(value.pinned, into: &buf)+ FfiConverterOptionString.write(value.note, into: &buf)}}@@ -35672,6 +35722,13 @@ public struct AppSettings: Equatable, Hashable {* ([`crate::keyvault::view::prune_dismissed`] forgets the gone ones).*/public var dismissedAccess: [String]+ /**+ * The Spaces and the machines' desktops pinned to the notch ("Pin to+ * notch" in a Space's "..." menu), in the order they were pinned: the+ * notch lists them first ([`crate::notch::tiles_pinned`]). Ids only,+ * nothing secret; an id whose Space is gone is kept and draws nothing.+ */+ public var notchPinned: [String]/*** Keyvault rows may load a site's icon from Google's favicon service* when the source browser had none (Settings, Keyvault; on by default).@@ -35753,6 +35810,12 @@ public struct AppSettings: Equatable, Hashable {* longer shows them, nothing is revoked or wiped* ([`crate::keyvault::view::prune_dismissed`] forgets the gone ones).*/dismissedAccess: [String],+ /**+ * The Spaces and the machines' desktops pinned to the notch ("Pin to+ * notch" in a Space's "..." menu), in the order they were pinned: the+ * notch lists them first ([`crate::notch::tiles_pinned`]). Ids only,+ * nothing secret; an id whose Space is gone is kept and draws nothing.+ */notchPinned: [String],/*** Keyvault rows may load a site's icon from Google's favicon service* when the source browser had none (Settings, Keyvault; on by default).@@ -35788,6 +35851,7 @@ public struct AppSettings: Equatable, Hashable {self.experiments = experimentsself.newUi = newUiself.dismissedAccess = dismissedAccess+ self.notchPinned = notchPinnedself.keyvaultSiteIcons = keyvaultSiteIconsself.teleportChoices = teleportChoicesself.autoConnect = autoConnect@@ -35823,6 +35887,7 @@ public struct FfiConverterTypeAppSettings: FfiConverterRustBuffer {experiments: FfiConverterTypeAppExperiments.read(from: &buf),newUi: FfiConverterOptionBool.read(from: &buf),dismissedAccess: FfiConverterSequenceString.read(from: &buf),+ notchPinned: FfiConverterSequenceString.read(from: &buf),keyvaultSiteIcons: FfiConverterBool.read(from: &buf),teleportChoices: FfiConverterSequenceTypeAppRememberedChoice.read(from: &buf),autoConnect: FfiConverterBool.read(from: &buf),@@ -35844,6 +35909,7 @@ public struct FfiConverterTypeAppSettings: FfiConverterRustBuffer {FfiConverterTypeAppExperiments.write(value.experiments, into: &buf)FfiConverterOptionBool.write(value.newUi, into: &buf)FfiConverterSequenceString.write(value.dismissedAccess, into: &buf)+ FfiConverterSequenceString.write(value.notchPinned, into: &buf)FfiConverterBool.write(value.keyvaultSiteIcons, into: &buf)FfiConverterSequenceTypeAppRememberedChoice.write(value.teleportChoices, into: &buf)FfiConverterBool.write(value.autoConnect, into: &buf)@@ -39161,6 +39227,14 @@ public struct AppSpaceMenuInput: Equatable, Hashable {* You may leave it.*/public var canLeave: Bool+ /**+ * It can be pinned to the notch (not This machine).+ */+ public var canPin: Bool+ /**+ * It is pinned to the notch now (Unpin from notch).+ */+ public var pinned: Bool// Default memberwise initializers are never public by default, so we// declare one manually.@@ -39197,7 +39271,13 @@ public struct AppSpaceMenuInput: Equatable, Hashable {*/canDelete: Bool,/*** You may leave it.- */canLeave: Bool) {+ */canLeave: Bool,+ /**+ * It can be pinned to the notch (not This machine).+ */canPin: Bool,+ /**+ * It is pinned to the notch now (Unpin from notch).+ */pinned: Bool) {self.kind = kindself.role = roleself.maker = maker@@ -39209,6 +39289,8 @@ public struct AppSpaceMenuInput: Equatable, Hashable {self.canRename = canRenameself.canDelete = canDeleteself.canLeave = canLeave+ self.canPin = canPin+ self.pinned = pinned}@@ -39237,7 +39319,9 @@ public struct FfiConverterTypeAppSpaceMenuInput: FfiConverterRustBuffer {canShare: FfiConverterBool.read(from: &buf),canRename: FfiConverterBool.read(from: &buf),canDelete: FfiConverterBool.read(from: &buf),- canLeave: FfiConverterBool.read(from: &buf)+ canLeave: FfiConverterBool.read(from: &buf),+ canPin: FfiConverterBool.read(from: &buf),+ pinned: FfiConverterBool.read(from: &buf))}@@ -39253,6 +39337,8 @@ public struct FfiConverterTypeAppSpaceMenuInput: FfiConverterRustBuffer {FfiConverterBool.write(value.canRename, into: &buf)FfiConverterBool.write(value.canDelete, into: &buf)FfiConverterBool.write(value.canLeave, into: &buf)+ FfiConverterBool.write(value.canPin, into: &buf)+ FfiConverterBool.write(value.pinned, into: &buf)}}@@ -58598,6 +58684,15 @@ public enum AppNotchEvent: Equatable, Hashable {* The Space ids signed in (their tiles carry the key).*/signedIn: [String])+ /**+ * The pinned Spaces and desktops changed (Pin to notch, Unpin from+ * notch, or settings read at start): their ids in pin order.+ */+ case pinned(+ /**+ * The pinned ids.+ */ids: [String]+ )@@ -58654,6 +58749,9 @@ public struct FfiConverterTypeAppNotchEvent: FfiConverterRustBuffer {case 14: return .keyvault(label: try FfiConverterOptionString.read(from: &buf), signedIn: try FfiConverterSequenceString.read(from: &buf))+ case 15: return .pinned(ids: try FfiConverterSequenceString.read(from: &buf)+ )+default: throw UniffiInternalError.unexpectedEnumCase}}@@ -58726,6 +58824,11 @@ public struct FfiConverterTypeAppNotchEvent: FfiConverterRustBuffer {FfiConverterOptionString.write(label, into: &buf)FfiConverterSequenceString.write(signedIn, into: &buf)++ case let .pinned(ids):+ writeInt(&buf, Int32(15))+ FfiConverterSequenceString.write(ids, into: &buf)+}}}@@ -62886,6 +62989,10 @@ public enum AppSpaceMenuItemId: Equatable, Hashable {* Leaves it (asks first: `spaces.bulkConfirm`).*/case leave+ /**+ * Pins it to the notch, or unpins it (the label says which).+ */+ case pin@@ -62923,6 +63030,8 @@ public struct FfiConverterTypeAppSpaceMenuItemId: FfiConverterRustBuffer {case 8: return .leave+ case 9: return .pin+default: throw UniffiInternalError.unexpectedEnumCase}}@@ -62962,6 +63071,10 @@ public struct FfiConverterTypeAppSpaceMenuItemId: FfiConverterRustBuffer {case .leave:writeInt(&buf, Int32(8))++ case .pin:+ writeInt(&buf, Int32(9))+}}}@@ -79420,6 +79533,18 @@ public func appNotchTileAt(layout: AppNotchLayout, tiles: [AppNotchTile], row: B)})}+/**+ * `pinned` (the notch's pins, in pin order) with `id` pinned or, when it+ * already is, unpinned: Pin to notch and Unpin from notch.+ */+public func appNotchTogglePin(pinned: [String], id: String) -> [String] {+ return try! FfiConverterSequenceString.lift(try! rustCall() {+ uniffi_cua_spaces_ffi_fn_func_app_notch_toggle_pin(+ FfiConverterSequenceString.lower(pinned),+ FfiConverterString.lower(id),$0+ )+})+}/*** The notch panel as drawn.*/@@ -82102,6 +82227,9 @@ private let initializationResult: InitializationResult = {if (uniffi_cua_spaces_ffi_checksum_func_app_notch_tile_at() != 23982) {return InitializationResult.apiChecksumMismatch}+ if (uniffi_cua_spaces_ffi_checksum_func_app_notch_toggle_pin() != 49031) {+ return InitializationResult.apiChecksumMismatch+ }if (uniffi_cua_spaces_ffi_checksum_func_app_notch_view() != 50142) {return InitializationResult.apiChecksumMismatch}diff --git a/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.h b/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.hindex 3bc25312ee..e23d69ee30 100644--- a/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.h+++ b/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.h@@ -1396,6 +1396,11 @@ RustBuffer uniffi_cua_spaces_ffi_fn_func_app_notch_reduce(RustBuffer state, RustRustBuffer uniffi_cua_spaces_ffi_fn_func_app_notch_tile_at(RustBuffer layout, RustBuffer tiles, int8_t row, double x, double y, RustCallStatus *_Nonnull out_status);#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_NOTCH_TOGGLE_PIN+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_NOTCH_TOGGLE_PIN+RustBuffer uniffi_cua_spaces_ffi_fn_func_app_notch_toggle_pin(RustBuffer pinned, RustBuffer id, RustCallStatus *_Nonnull out_status+);+#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_NOTCH_VIEW#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_NOTCH_VIEWRustBuffer uniffi_cua_spaces_ffi_fn_func_app_notch_view(RustBuffer state, RustBuffer spaces, RustCallStatus *_Nonnull out_status@@ -3518,6 +3523,12 @@ uint16_t uniffi_cua_spaces_ffi_checksum_func_app_notch_reduce(void#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_NOTCH_TILE_ATuint16_t uniffi_cua_spaces_ffi_checksum_func_app_notch_tile_at(void+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_NOTCH_TOGGLE_PIN+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_NOTCH_TOGGLE_PIN+uint16_t uniffi_cua_spaces_ffi_checksum_func_app_notch_toggle_pin(void+);#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_NOTCH_VIEWdiff --git a/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchContentView.swift b/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchContentView.swiftindex 2c2f7a81a6..75b67e8e09 100644--- a/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchContentView.swift+++ b/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchContentView.swift@@ -705,6 +705,20 @@ public struct TileView: View {.font(.system(size: 10, weight: .medium)).foregroundStyle(.white.opacity(0.6))}+ if let note = tile.note {+ // A pinned desktop that cannot be opened now ("Offline", "Not shared"): it stays, dimmed, and says why.+ Text(note)+ .font(.system(size: 10, weight: .medium))+ .foregroundStyle(.white.opacity(0.85))+ .padding(.horizontal, 6)+ .padding(.vertical, 2)+ .background(Capsule().fill(.black.opacity(0.6)))+ }+ if tile.pinned {+ PinnedMark()+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)+ .padding(5)+ }if tile.signedIn {SignedInKey().frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)@@ -734,6 +748,7 @@ public struct TileView: View {}private var dot: Color {+ if tile.note != nil { return .gray }switch tile.status {case .running, .local: return .greencase .approval: return .orange@@ -743,6 +758,20 @@ public struct TileView: View {}}+/// A Space or desktop pinned to the notch: a small pin on its thumbnail.+struct PinnedMark: View {+ var body: some View {+ Image(systemName: "pin.fill")+ .font(.system(size: 8, weight: .bold))+ .foregroundStyle(.white)+ .frame(width: 16, height: 16)+ .background(Circle().fill(.black.opacity(0.65)))+ .overlay(Circle().strokeBorder(.white.opacity(0.18), lineWidth: 0.5))+ .accessibilityLabel("Pinned")+ .help("Pinned to the notch")+ }+}+/// A Space signed in through the Keyvault: a small key on its thumbnail.struct SignedInKey: View {var body: some View {diff --git a/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchData.swift b/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchData.swiftindex 32824126a9..9e77ff4b23 100644--- a/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchData.swift+++ b/libs/spaces-notch-swift/Sources/CuaSpacesNotchUI/NotchData.swift@@ -149,10 +149,16 @@ public enum NotchData {public var progress: UInt32?public var progressLabel: String?public var signedIn: Bool+ /// One of your other machines' desktops (not a Space it provides).+ public var desktop: Bool+ /// Pinned to the notch.+ public var pinned: Bool+ /// Why a pinned desktop cannot be opened now ("Offline", "Not shared").+ public var note: String?public init(id: String, name: String, status: TileStatus, dim: Bool, dropTarget: Bool, targeted: Bool,symbol: String, label: String, location: String, progress: UInt32?, progressLabel: String?,- signedIn: Bool) {+ signedIn: Bool, desktop: Bool = false, pinned: Bool = false, note: String? = nil) {self.id = idself.name = nameself.status = status@@ -165,6 +171,29 @@ public enum NotchData {self.progress = progressself.progressLabel = progressLabelself.signedIn = signedIn+ self.desktop = desktop+ self.pinned = pinned+ self.note = note+ }++ // The Electron app's core sends these only when set.+ public init(from decoder: Decoder) throws {+ let c = try decoder.container(keyedBy: CodingKeys.self)+ id = try c.decode(String.self, forKey: .id)+ name = try c.decode(String.self, forKey: .name)+ status = try c.decode(TileStatus.self, forKey: .status)+ dim = try c.decode(Bool.self, forKey: .dim)+ dropTarget = try c.decode(Bool.self, forKey: .dropTarget)+ targeted = try c.decode(Bool.self, forKey: .targeted)+ symbol = try c.decode(String.self, forKey: .symbol)+ label = try c.decode(String.self, forKey: .label)+ location = try c.decode(String.self, forKey: .location)+ progress = try c.decodeIfPresent(UInt32.self, forKey: .progress)+ progressLabel = try c.decodeIfPresent(String.self, forKey: .progressLabel)+ signedIn = try c.decode(Bool.self, forKey: .signedIn)+ desktop = try c.decodeIfPresent(Bool.self, forKey: .desktop) ?? false+ pinned = try c.decodeIfPresent(Bool.self, forKey: .pinned) ?? false+ note = try c.decodeIfPresent(String.self, forKey: .note)}}