mirror of
https://github.com/stablyai/orca.git
synced 2026-11-06 03:57:35 +00:00
* fix(mobile): phone server rows follow the desktop's other-client and sleeping filters A phone created through a desktop now records whom it acted for, so the desktop's Hide other-client workspaces filter keeps the user's own phone workspaces (locally and on servers) and hides only other people's. The desktop relay marks each server row its sidebar would hide, and the rows its own browser or chat tabs keep awake; the phone applies both. * test(e2e): dedupe sidebar row ids in the visibility spec * fix(mobile): address review: owner naming, old-server relayed phones, scope trim * refactor(mobile): record a phone's owner as creator and fold desktop tab activity into the host flag A phone now records its owner as the creator (this host for a directly paired phone, the relaying desktop for a delegated one), so the shared rule is unchanged and onBehalfOf is gone. The relay ORs the desktop's saved browser/chat tabs into hasHostSidebarActivity, so the phone's status dot follows too, and local worktree.ps counts the same signals. The old-server fallback is removed. * test(e2e): poll the phone and the sidebar together in the visibility spec
94 lines
3.1 KiB
TypeScript
94 lines
3.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { FolderWorkspace } from './folder-workspace-types'
|
|
import {
|
|
filterFolderWorkspacesFromOtherDevices,
|
|
isWorkspaceOwnedBySomeoneElse
|
|
} from './workspace-creator-visibility'
|
|
|
|
function makeFolderWorkspace(
|
|
id: string,
|
|
creatorProvenance: FolderWorkspace['creatorProvenance']
|
|
): FolderWorkspace {
|
|
return {
|
|
id,
|
|
projectGroupId: 'project',
|
|
name: id,
|
|
folderPath: `/tmp/${id}`,
|
|
executionHostId: 'runtime:env-1',
|
|
creatorProvenance,
|
|
linkedTask: null,
|
|
comment: '',
|
|
isArchived: false,
|
|
isUnread: false,
|
|
isPinned: false,
|
|
sortOrder: 0,
|
|
lastActivityAt: 0,
|
|
createdAt: 0,
|
|
updatedAt: 0
|
|
}
|
|
}
|
|
|
|
describe('filterFolderWorkspacesFromOtherDevices', () => {
|
|
it('uses the same client ownership rules as git workspaces', () => {
|
|
const own = makeFolderWorkspace('own', {
|
|
kind: 'paired-device',
|
|
deviceId: 'device-a'
|
|
})
|
|
const other = makeFolderWorkspace('other', {
|
|
kind: 'paired-device',
|
|
deviceId: 'device-b'
|
|
})
|
|
const host = makeFolderWorkspace('host', { kind: 'host' })
|
|
const legacy = makeFolderWorkspace('legacy', undefined)
|
|
|
|
const result = filterFolderWorkspacesFromOtherDevices(
|
|
[own, other, host, legacy],
|
|
new Map([['env-1', 'device-a']])
|
|
)
|
|
|
|
expect(result.map((workspace) => workspace.id)).toEqual(['own', 'legacy'])
|
|
})
|
|
})
|
|
|
|
describe('isWorkspaceOwnedBySomeoneElse', () => {
|
|
const desktopOnServer = new Map([['server', 'desktop']])
|
|
// What resolveRpcWorkspaceCreatorProvenance records for each creator.
|
|
const created = {
|
|
byThisHostOrItsPhone: { kind: 'host' },
|
|
byPairedDesktopOrItsRelayedPhone: { kind: 'paired-device', deviceId: 'desktop' },
|
|
byAnotherClientOrItsPhone: { kind: 'paired-device', deviceId: 'laptop' },
|
|
byLegacyPhone: { kind: 'paired-device', deviceId: 'phone' }
|
|
} as const
|
|
|
|
function hidden(creatorProvenance: unknown, runtimeOwnerEnvironmentId?: string): boolean {
|
|
return isWorkspaceOwnedBySomeoneElse(
|
|
{ creatorProvenance, runtimeOwnerEnvironmentId },
|
|
desktopOnServer
|
|
)
|
|
}
|
|
|
|
it("keeps a local row this desktop or its phone created, and hides other clients'", () => {
|
|
expect(hidden(created.byThisHostOrItsPhone)).toBe(false)
|
|
expect(hidden(created.byAnotherClientOrItsPhone)).toBe(true)
|
|
})
|
|
|
|
it('keeps a legacy local phone row hidden: an older host recorded the phone, not its owner', () => {
|
|
expect(hidden(created.byLegacyPhone)).toBe(true)
|
|
})
|
|
|
|
it('keeps a server row this desktop or its relayed phone created', () => {
|
|
expect(hidden(created.byPairedDesktopOrItsRelayedPhone, 'server')).toBe(false)
|
|
})
|
|
|
|
it('hides a server row another client, its phone, or the server itself created', () => {
|
|
expect(hidden(created.byAnotherClientOrItsPhone, 'server')).toBe(true)
|
|
expect(hidden(created.byThisHostOrItsPhone, 'server')).toBe(true)
|
|
})
|
|
|
|
it('keeps rows with no creator, or on a server whose pairing is unknown', () => {
|
|
expect(hidden(undefined)).toBe(false)
|
|
expect(hidden(undefined, 'server')).toBe(false)
|
|
expect(hidden(created.byAnotherClientOrItsPhone, 'unpaired')).toBe(false)
|
|
})
|
|
})
|