mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* feat(mobile): start a workspace from a branch, issue/PR, or Linear ticket Unify mobile workspace creation with desktop. The "+" Create Workspace modal now has a primary "Start from" field that opens a tabbed search drawer (Branch · GitHub · GitLab · Linear), letting a user start a workspace from an existing/new git branch, a GitHub issue/PR, a GitLab issue/MR, or a Linear ticket — in addition to the default blank workspace. No new backend is required: the search RPCs (github.listWorkItems, gitlab.listWorkItems, linear.searchIssues/listIssues, repo.searchRefs) and the worktree.create linked-item params were already used by the mobile Tasks screen. This surfaces them in the create flow, reusing the existing pure modules (buildTaskWorkspaceCreateParams, shouldResolveHostedReviewStartPoint, filterAvailableTaskProviders). Details: - New pure modules: workspace-source-selection, use-workspace-source-search, source-workspace-create, worktree-create-retry, blank-workspace-create (the blank/retry path extracted from the modal for reuse + line budget). - New UI: WorkspaceSourcePickerDrawer (+ row) and SetupHookTrustDrawer (extracted from the modal). - Older paired desktops (missing the mobile.tasks.v1 capability) degrade to Branch + Blank only; GitLab/Linear tabs appear only when available. - GitHub/GitLab sources pin their repo; switching repos resets the source. PR/MR sources resolve their base branch at create time; SSH repos gate search until connected (Linear search is repo/SSH-independent). * fix(mobile): hydrate settings/trust before availability probes settle Review fixes for #7985: setTrustedOrcaHooks/setRuntimeSettings no longer wait on status.get/preflight.check/linear.status (a first-open preflight.check can take seconds, widening the spurious setup-trust re-prompt window). Also adds param-parity tests for createBlankWorkspace and a GitLab MR base-resolve test. * feat(mobile): match desktop's Smart source picker exactly Rework the mobile create-workspace source picker to be a faithful port of desktop's Smart picker instead of the earlier divergent "Start from" drawer. The mobile field is now the workspace-name input AND the source search, with the exact desktop tabs — Smart · GitHub · Linear · GitLab · Branch · Name. "Smart" fans out across GitHub + GitLab + Linear + branches, prepends a "Use '<name>'" row, and resolves pasted URLs / #123 / STA-42 to exact items (with a cross-repo switch prompt). Selecting a source shows a pill and moves the editable name into Advanced. The invented "Blank workspace" concept is removed — the neutral state is just a typed/empty name (blank submit still yields a creature name). DRY: the pure desktop logic (smart-workspace-source-results, -command-value, github-links, gitlab-links, work-item-link-query-bounds, github-work-item-identity) moves to src/shared/new-workspace/ with re-export shims at the old renderer paths, so both renderer and mobile share one implementation. composer-branch-selection and workspace-name were already shared and are reused directly. Two read-only lookup RPCs are allowlisted for mobile so pasted GitLab URLs and cross-repo GitHub URLs resolve to exact items (github.workItemByOwnerRepo, gitlab.workItemByPath). New mobile modules are split for max-lines: use-mobile-composer-source (selection state + desktop-parity handlers, PR/MR base resolve), use-smart-workspace-source + smart-source-fan-out/-search-requests/-paste-intent (RPC orchestration), composer-linked-work-item / work-item-lookup-text / mobile-smart-source-modes (pure logic), and SmartWorkspaceSourceField/Drawer/Row + SmartWorkspaceAdvancedFields. Replaces WorkspaceSourcePickerDrawer/Row, workspace-source-selection, use-workspace-source-search, and MobileWorkspaceNameInput. Reviewed by three adversarial agents + re-reviewed after fixes: GitHub search now returns issues AND PRs (not issues-only), Linear defaults to assigned, create-branch preserves slashy names, cross-repo PR base resolves against the item's own repo, displayName is suppressed for user-edited names, and the smart-mode GitHub fan-out respects availability. tsc/oxlint/max-lines-ratchet clean; 1328 mobile tests pass. * fix(mobile): keep smart source drawer fully visible * refactor: share workspace creation behavior across clients * fix: address workspace creation review findings --------- Co-authored-by: Brennan Benson <brennanbenson@Brennans-MacBook-Pro.local>
228 lines
7.4 KiB
TypeScript
228 lines
7.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
describeRuntimeCompatBlock,
|
|
evaluateCompat,
|
|
evaluateRuntimeCompat
|
|
} from './protocol-compat'
|
|
import {
|
|
DESKTOP_PROTOCOL_VERSION,
|
|
MIN_COMPATIBLE_MOBILE_VERSION,
|
|
MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION,
|
|
MIN_COMPATIBLE_RUNTIME_SERVER_VERSION,
|
|
RUNTIME_PROTOCOL_VERSION
|
|
} from './protocol-version'
|
|
|
|
const MOBILE_V = 1
|
|
|
|
describe('evaluateCompat', () => {
|
|
it('returns ok when both desktop fields are undefined and constants are wide-open', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 0,
|
|
desktopProtocolVersion: undefined,
|
|
desktopMinCompatibleMobileVersion: undefined
|
|
})
|
|
expect(verdict).toEqual({ kind: 'ok' })
|
|
})
|
|
|
|
it('returns ok when desktop reports version equal to mobile', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 0,
|
|
desktopProtocolVersion: MOBILE_V,
|
|
desktopMinCompatibleMobileVersion: 0
|
|
})
|
|
expect(verdict).toEqual({ kind: 'ok' })
|
|
})
|
|
|
|
it('returns ok when desktop reports a newer version (additive changes assumed safe)', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 0,
|
|
desktopProtocolVersion: MOBILE_V + 5,
|
|
desktopMinCompatibleMobileVersion: 0
|
|
})
|
|
expect(verdict).toEqual({ kind: 'ok' })
|
|
})
|
|
|
|
it('allows desktop protocol 3 to roll out before mobile protocol 2 updates', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: 2,
|
|
minCompatibleDesktopVersion: 2,
|
|
desktopProtocolVersion: 3,
|
|
desktopMinCompatibleMobileVersion: 2
|
|
})
|
|
|
|
expect(verdict).toEqual({ kind: 'ok' })
|
|
})
|
|
|
|
it('allows mobile protocol 3 to roll out before desktop protocol 2 updates', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: 3,
|
|
minCompatibleDesktopVersion: 2,
|
|
desktopProtocolVersion: 2,
|
|
desktopMinCompatibleMobileVersion: 2
|
|
})
|
|
|
|
expect(verdict).toEqual({ kind: 'ok' })
|
|
})
|
|
|
|
it('blocks with mobile-too-old when desktop requires a newer mobile', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 0,
|
|
desktopProtocolVersion: 5,
|
|
desktopMinCompatibleMobileVersion: MOBILE_V + 1
|
|
})
|
|
expect(verdict).toEqual({
|
|
kind: 'blocked',
|
|
reason: 'mobile-too-old',
|
|
desktopVersion: 5,
|
|
requiredMobileVersion: MOBILE_V + 1
|
|
})
|
|
})
|
|
|
|
it('coerces undefined desktopVersion to 0 in the verdict payload', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 0,
|
|
desktopProtocolVersion: undefined,
|
|
desktopMinCompatibleMobileVersion: MOBILE_V + 1
|
|
})
|
|
expect(verdict).toMatchObject({
|
|
kind: 'blocked',
|
|
reason: 'mobile-too-old',
|
|
desktopVersion: 0
|
|
})
|
|
})
|
|
|
|
it('blocks with desktop-too-old when desktop reports below the local minimum', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 5,
|
|
desktopProtocolVersion: 3,
|
|
desktopMinCompatibleMobileVersion: 0
|
|
})
|
|
expect(verdict).toEqual({
|
|
kind: 'blocked',
|
|
reason: 'desktop-too-old',
|
|
desktopVersion: 3,
|
|
requiredDesktopVersion: 5
|
|
})
|
|
})
|
|
|
|
it('mobile-too-old wins precedence when both constraints would fire', () => {
|
|
// Why: documents the intended kill-switch precedence — desktop's
|
|
// refusal of a too-old mobile takes priority over mobile's local
|
|
// refusal of a too-old desktop.
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 99,
|
|
desktopProtocolVersion: -1,
|
|
desktopMinCompatibleMobileVersion: MOBILE_V + 1
|
|
})
|
|
expect(verdict.kind).toBe('blocked')
|
|
expect((verdict as { reason: string }).reason).toBe('mobile-too-old')
|
|
})
|
|
|
|
it('with minCompatibleDesktopVersion = 0 every reported desktop passes', () => {
|
|
for (const v of [0, 1, 2, 99]) {
|
|
expect(
|
|
evaluateCompat({
|
|
mobileProtocolVersion: MOBILE_V,
|
|
minCompatibleDesktopVersion: 0,
|
|
desktopProtocolVersion: v,
|
|
desktopMinCompatibleMobileVersion: 0
|
|
})
|
|
).toEqual({ kind: 'ok' })
|
|
}
|
|
})
|
|
|
|
it('hard-blocks protocol-1 mobile for the binary terminal stream cutover', () => {
|
|
const verdict = evaluateCompat({
|
|
mobileProtocolVersion: 1,
|
|
minCompatibleDesktopVersion: DESKTOP_PROTOCOL_VERSION,
|
|
desktopProtocolVersion: DESKTOP_PROTOCOL_VERSION,
|
|
desktopMinCompatibleMobileVersion: MIN_COMPATIBLE_MOBILE_VERSION
|
|
})
|
|
|
|
expect(verdict).toEqual({
|
|
kind: 'blocked',
|
|
reason: 'mobile-too-old',
|
|
desktopVersion: DESKTOP_PROTOCOL_VERSION,
|
|
requiredMobileVersion: MIN_COMPATIBLE_MOBILE_VERSION
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('evaluateRuntimeCompat', () => {
|
|
it('keeps the current client and current server self-compatible', () => {
|
|
const verdict = evaluateRuntimeCompat({
|
|
clientProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
minCompatibleServerProtocolVersion: MIN_COMPATIBLE_RUNTIME_SERVER_VERSION,
|
|
serverProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
serverMinCompatibleClientProtocolVersion: MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION
|
|
})
|
|
|
|
expect(verdict).toMatchObject({ kind: 'ok' })
|
|
})
|
|
|
|
it('allows client and server app versions to skew when protocol ranges overlap', () => {
|
|
const verdict = evaluateRuntimeCompat({
|
|
clientProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
minCompatibleServerProtocolVersion: MIN_COMPATIBLE_RUNTIME_SERVER_VERSION,
|
|
serverProtocolVersion: RUNTIME_PROTOCOL_VERSION + 3,
|
|
serverMinCompatibleClientProtocolVersion: RUNTIME_PROTOCOL_VERSION - 1
|
|
})
|
|
|
|
expect(verdict).toMatchObject({ kind: 'ok' })
|
|
})
|
|
|
|
it('blocks when the server requires a newer client protocol', () => {
|
|
const verdict = evaluateRuntimeCompat({
|
|
clientProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
minCompatibleServerProtocolVersion: MIN_COMPATIBLE_RUNTIME_SERVER_VERSION,
|
|
serverProtocolVersion: RUNTIME_PROTOCOL_VERSION + 1,
|
|
serverMinCompatibleClientProtocolVersion: RUNTIME_PROTOCOL_VERSION + 1
|
|
})
|
|
|
|
expect(verdict).toMatchObject({
|
|
kind: 'blocked',
|
|
reason: 'client-too-old',
|
|
requiredClientProtocolVersion: RUNTIME_PROTOCOL_VERSION + 1
|
|
})
|
|
expect(describeRuntimeCompatBlock(verdict)).toContain('client is too old')
|
|
})
|
|
|
|
it('blocks when the server protocol is below the client minimum', () => {
|
|
const verdict = evaluateRuntimeCompat({
|
|
clientProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
minCompatibleServerProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
serverProtocolVersion: RUNTIME_PROTOCOL_VERSION - 1,
|
|
serverMinCompatibleClientProtocolVersion: 0
|
|
})
|
|
|
|
expect(verdict).toMatchObject({
|
|
kind: 'blocked',
|
|
reason: 'server-too-old',
|
|
requiredServerProtocolVersion: RUNTIME_PROTOCOL_VERSION
|
|
})
|
|
expect(describeRuntimeCompatBlock(verdict)).toContain('server is too old')
|
|
})
|
|
|
|
it('treats missing server fields as protocol 0', () => {
|
|
const verdict = evaluateRuntimeCompat({
|
|
clientProtocolVersion: RUNTIME_PROTOCOL_VERSION,
|
|
minCompatibleServerProtocolVersion: 1,
|
|
serverProtocolVersion: undefined,
|
|
serverMinCompatibleClientProtocolVersion: undefined
|
|
})
|
|
|
|
expect(verdict).toMatchObject({
|
|
kind: 'blocked',
|
|
reason: 'server-too-old',
|
|
serverProtocolVersion: 0
|
|
})
|
|
})
|
|
})
|