Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

refactor(desktop): share computer permission steps

leepokai1ba87b8108ca
diff --git a/apps/desktop/src/renderer/lib/access-onboarding.test.ts b/apps/desktop/src/renderer/lib/access-onboarding.test.ts
new file mode 100644
index 00000000..28de34ba
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/access-onboarding.test.ts
@@ -0,0 +1,26 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import type { ScreenState } from '../../shared/models'
+import { accessPages, accessPageReady } from './access-onboarding.ts'
+
+test('macOS setup combines three permissions and optional GitHub support', () => {
+ assert.deepEqual(accessPages('darwin').map((page) => page.id), ['helper', 'capture', 'input', 'star'])
+})
+
+test('other desktops only show supported permissions followed by optional support', () => {
+ assert.deepEqual(accessPages('linux').map((page) => page.id), ['helper', 'portal', 'star'])
+ assert.deepEqual(accessPages('win32').map((page) => page.id), ['control', 'star'])
+})
+
+test('a completed permission can continue before the whole computer is ready', () => {
+ const screen = { enabled: true, connected: true, capture: true, input: false } as ScreenState
+ assert.equal(accessPageReady('helper', 'input', screen), true)
+ assert.equal(accessPageReady('capture', 'input', screen), true)
+ assert.equal(accessPageReady('input', 'input', screen), false)
+ assert.equal(accessPageReady('portal', 'portal', screen), false)
+ assert.equal(accessPageReady('helper', 'background', screen), false)
+ assert.equal(accessPageReady('capture', 'host', screen), false)
+ assert.equal(accessPageReady('capture', 'unavailable', screen), false)
+ assert.equal(accessPageReady('helper', 'host', null), false)
+ assert.equal(accessPageReady('star', 'ready', screen), false)
+})
diff --git a/apps/desktop/src/renderer/lib/access-onboarding.ts b/apps/desktop/src/renderer/lib/access-onboarding.ts
new file mode 100644
index 00000000..57ec236b
--- /dev/null
+++ b/apps/desktop/src/renderer/lib/access-onboarding.ts
@@ -0,0 +1,28 @@
+import type { ComputerAccessStep } from '../../shared/computer-access'
+import type { ScreenState } from '../../shared/models'
+
+export type AccessPage = 'helper' | 'capture' | 'input' | 'portal' | 'control' | 'star'
+
+export function accessPageReady(page: AccessPage, step: ComputerAccessStep, screen: ScreenState | null): boolean {
+ if (!screen || step === 'host' || step === 'unavailable') return false
+ switch (page) {
+ case 'helper': return screen.enabled && screen.connected && !['enable', 'helper', 'background'].includes(step)
+ case 'capture': return screen.capture
+ case 'input': return screen.input
+ case 'portal': return screen.capture && screen.input
+ case 'control': return step === 'ready'
+ case 'star': return false
+ }
+}
+
+/** Only list permissions that can actually be granted on this desktop. */
+export function accessPages(platform: string): { id: AccessPage; label: string }[] {
+ if (platform === 'win32') return [{ id: 'control', label: 'Computer control' }, { id: 'star', label: 'GitHub Star' }]
+ return [
+ { id: 'helper', label: 'Codync Screen' },
+ ...(platform === 'darwin'
+ ? [{ id: 'capture' as const, label: 'Screen recording' }, { id: 'input' as const, label: 'Control apps' }]
+ : [{ id: 'portal' as const, label: 'Screen sharing & control' }]),
+ { id: 'star', label: 'GitHub Star' },
+ ]
+}
diff --git a/apps/desktop/src/renderer/views/computer-access/AccessSteps.tsx b/apps/desktop/src/renderer/views/computer-access/AccessSteps.tsx
new file mode 100644
index 00000000..077e01db
--- /dev/null
+++ b/apps/desktop/src/renderer/views/computer-access/AccessSteps.tsx
@@ -0,0 +1,74 @@
+import type { ReactNode } from 'react'
+import type { ComputerAccess } from '../../store/computer-access'
+import type { AccessPage } from '../../lib/access-onboarding'
+import { Button, Spinner } from '../../components/Controls'
+import { Icon } from '../../components/Icon'
+import { useTr } from '../../lib/use-language'
+
+export function AccessSteps({ access, selection }: { access: ComputerAccess; selection?: AccessPage }) {
+ const tr = useTr()
+ const { screen, step, busy } = access
+ const mac = window.codync.platform === 'darwin'
+ const windows = window.codync.platform === 'win32'
+ const ready = step === 'ready'
+ const canRequest = ['capture', 'input', 'portal', 'ready'].includes(step)
+ const helperReady = screen?.enabled === true && screen.connected && step !== 'background'
+ const request = (permission: 'capture' | 'input' | 'portal', title: string) => (
+ <Button kind={step === permission ? 'primary' : 'secondary'} disabled={!canRequest || busy !== null} onClick={() => void access.request(permission)}>
+ {busy === permission ? <><Spinner /> {tr('Waiting for permission…')}</> : title}
+ </Button>
+ )
+ return (
+ <>
+ {windows ? <AccessRow large={selection !== undefined} title="Computer control" icon="cursorarrow.motionlines" detail="Bots can use apps on this computer. Remote screen viewing from your phone isn’t available on Windows yet." done={ready} /> : <>
+ {(!selection || selection === 'helper') ? <AccessRow large={selection !== undefined} title="Codync Screen" icon="desktopcomputer" detail="Runs in the background to share your screen and connect your controls." done={helperReady} active={['enable', 'helper', 'background'].includes(step)} status={step === 'background' ? 'Needs approval' : undefined}>
+ {['enable', 'helper'].includes(step) ? <Button disabled={busy !== null} onClick={() => void access.enable()}>{busy === 'enable' ? <><Spinner /> {tr('Starting…')}</> : step === 'helper' ? 'Start again' : 'Enable Codync Screen'}</Button> : null}
+ {step === 'background' ? <><p className="computer-access-inline-note">{tr('Allow Codync to run in the background in Login Items.')}</p><Button onClick={() => access.openSettings('background')}>{tr('Open Login Items')} <Icon name="arrow.up.right.square" size={10} /></Button></> : null}
+ </AccessRow> : null}
+ {mac ? <>
+ {(!selection || selection === 'capture') ? <AccessRow large={selection !== undefined} title="Screen recording" icon="record.circle" detail="Lets Codync see your screen, including anything visible in your apps." done={screen?.capture === true} active={step === 'capture'}>
+ {step === 'capture' ? <SettingsHint app={access.helperName} /> : null}
+ {canRequest ? request('capture', 'Allow screen recording') : null}
+ {access.requested.has('capture') ? <SettingsLink action={() => access.openSettings('capture')} /> : null}
+ </AccessRow> : null}
+ {(!selection || selection === 'input') ? <AccessRow large={selection !== undefined} title="Control apps" icon="cursorarrow.motionlines" detail="Lets Codync click, type and interact with apps on your behalf." done={screen?.input === true} active={step === 'input'}>
+ {step === 'input' ? <SettingsHint app={access.helperName} control /> : null}
+ {canRequest ? request('input', 'Allow computer control') : null}
+ {access.requested.has('input') ? <SettingsLink action={() => access.openSettings('input')} /> : null}
+ </AccessRow> : null}
+ </> : (!selection || selection === 'portal') ? <AccessRow large={selection !== undefined} title="Screen sharing & control" icon="cursorarrow.motionlines" detail="Choose a screen and allow mouse and keyboard access. You can stop sharing at any time." done={screen?.capture === true && screen.input} active={step === 'portal'}>
+ {canRequest ? request('portal', 'Choose screen and allow control') : null}
+ </AccessRow> : null}
+ </>}
+ </>
+ )
+}
+
+function AccessRow({ title, icon, detail, done, active = false, status, children, large = false }: {
+ title: string; icon: string; detail: string; done: boolean; active?: boolean; status?: string; children?: ReactNode; large?: boolean
+}) {
+ const tr = useTr()
+ const label = tr(done ? 'Ready' : status ?? (active ? 'Needs access' : 'Waiting'))
+ return <div className={`computer-access-row ${done ? 'granted' : active ? 'current' : 'waiting'}`}>
+ <span className="computer-access-badge" role="img" aria-label={label} title={label}>
+ {done ? <Icon name="checkmark" size={large ? 26 : 12} weight="bold" /> : <Icon name={icon} size={large ? 26 : 15} />}
+ </span>
+ <div className="computer-access-row-body">
+ <h2>{tr(title)}</h2>
+ <p>{tr(detail)}</p>
+ {!done ? <div className="computer-access-actions">{children}</div> : null}
+ </div>
+ </div>
+}
+
+function SettingsHint({ app, control = false }: { app: string; control?: boolean }) {
+ const tr = useTr()
+ return <p className="computer-access-inline-note">
+ {tr('In System Settings, look for')} <strong>{app}</strong>.{control ? <> {tr('It may be listed under Device Control and Data Access or Accessibility.')}</> : null} {tr('Return here after granting access; if asked, allow the helper to restart.')}
+ </p>
+}
+
+function SettingsLink({ action }: { action: () => void }) {
+ const tr = useTr()
+ return <Button kind="secondary" onClick={action}>{tr('Open System Settings')} <Icon name="arrow.up.right.square" size={10} /></Button>
+}
diff --git a/apps/desktop/src/renderer/views/computer-access/ComputerAccessView.tsx b/apps/desktop/src/renderer/views/computer-access/ComputerAccessView.tsx
index f3e4b1eb..58e9a7da 100644
--- a/apps/desktop/src/renderer/views/computer-access/ComputerAccessView.tsx
+++ b/apps/desktop/src/renderer/views/computer-access/ComputerAccessView.tsx
@@ -1,9 +1,10 @@
import type { ReactNode } from 'react'
-import { Button, IconButton, Spinner } from '../../components/Controls'
+import { Button, IconButton } from '../../components/Controls'
import { Icon } from '../../components/Icon'
import { useTr } from '../../lib/use-language'
import { useScreenViewed } from '../../store/analytics'
import { useComputerAccess } from './use-computer-access'
+import { AccessSteps } from './AccessSteps'
import appIcon from '../../../../resources/icon.png'
import './computer-access.css'
@@ -12,20 +13,14 @@ export function ComputerAccessView({ onContinue }: { onContinue?: (ready: boolea
const access = useComputerAccess()
const tr = useTr()
useScreenViewed('computer_access')
- const { screen, step, busy } = access
+ const { screen, step } = access
const mac = window.codync.platform === 'darwin'
const windows = window.codync.platform === 'win32'
const ready = step === 'ready'
- const canRequest = ['capture', 'input', 'portal', 'ready'].includes(step)
const helperReady = screen?.enabled === true && screen.connected && step !== 'background'
const completed = windows ? Number(ready) : Number(helperReady) + (mac
? Number(screen?.capture === true) + Number(screen?.input === true)
: Number(screen?.capture === true && screen.input))
- const request = (permission: 'capture' | 'input' | 'portal', title: string) => (
- <Button kind={step === permission ? 'primary' : 'secondary'} disabled={!canRequest || busy !== null} onClick={() => void access.request(permission)}>
- {busy === permission ? <><Spinner /> {tr('Waiting for permission…')}</> : title}
- </Button>
- )
return (
<section className={`computer-access ${onContinue ? 'onboarding' : ''}`} aria-label={tr('Computer access setup')}>
<div className="computer-access-content">
@@ -48,28 +43,7 @@ export function ComputerAccessView({ onContinue }: { onContinue?: (ready: boolea
<span>{tr(windows ? 'Availability' : 'Permissions')}</span>
<span>{ready ? tr('All set') : tr('{done} of {total} ready').replace('{done}', String(completed)).replace('{total}', String(mac ? 3 : windows ? 1 : 2))}<IconButton title="Check again" icon="arrow.clockwise" size={22} onClick={() => void access.refresh()} /></span>
</div>
- <div className="computer-access-steps">
- {windows ? <AccessRow title="Computer control" icon="cursorarrow.motionlines" detail="Bots can use apps on this computer. Remote screen viewing from your phone isn’t available on Windows yet." done={ready} /> : <>
- <AccessRow title="Codync Screen" icon="desktopcomputer" detail="Runs in the background to share your screen and connect your controls." done={helperReady} active={['enable', 'helper', 'background'].includes(step)} status={step === 'background' ? 'Needs approval' : undefined}>
- {['enable', 'helper'].includes(step) ? <Button disabled={busy !== null} onClick={() => void access.enable()}>{busy === 'enable' ? <><Spinner /> {tr('Starting…')}</> : step === 'helper' ? 'Start again' : 'Enable Codync Screen'}</Button> : null}
- {step === 'background' ? <><p className="computer-access-inline-note">{tr('Allow Codync to run in the background in Login Items.')}</p><Button onClick={() => access.openSettings('background')}>{tr('Open Login Items')} <Icon name="arrow.up.right.square" size={10} /></Button></> : null}
- </AccessRow>
- {mac ? <>
- <AccessRow title="Screen recording" icon="record.circle" detail="Lets Codync see your screen, including anything visible in your apps." done={screen?.capture === true} active={step === 'capture'}>
- {step === 'capture' ? <SettingsHint app={access.helperName} /> : null}
- {canRequest ? request('capture', 'Allow screen recording') : null}
- {access.requested.has('capture') ? <SettingsLink action={() => access.openSettings('capture')} /> : null}
- </AccessRow>
- <AccessRow title="Control apps" icon="cursorarrow.motionlines" detail="Lets Codync click, type and interact with apps on your behalf." done={screen?.input === true} active={step === 'input'}>
- {step === 'input' ? <SettingsHint app={access.helperName} control /> : null}
- {canRequest ? request('input', 'Allow computer control') : null}
- {access.requested.has('input') ? <SettingsLink action={() => access.openSettings('input')} /> : null}
- </AccessRow>
- </> : <AccessRow title="Screen sharing & control" icon="cursorarrow.motionlines" detail="Choose a screen and allow mouse and keyboard access. You can stop sharing at any time." done={screen?.capture === true && screen.input} active={step === 'portal'}>
- {canRequest ? request('portal', 'Choose screen and allow control') : null}
- </AccessRow>}
- </>}
- </div>
+ <div className="computer-access-steps"><AccessSteps access={access} /></div>
<ul className="computer-access-notes">
<li><Icon name="lock.shield" size={13} /><p>{tr(onContinue ? 'Permissions stay on this computer. You can change them later in Settings → Computer access.' : 'Permissions stay on this computer. Your other computers keep their own permissions.')}</p></li>
<li><Icon name="iphone" size={13} /><p>{tr('On iPhone, connect with a QR code or Ask Access. No SSH setup needed.')}</p></li>
@@ -82,38 +56,9 @@ export function ComputerAccessView({ onContinue }: { onContinue?: (ready: boolea
)
}
-function AccessRow({ title, icon, detail, done, active = false, status, children }: {
- title: string; icon: string; detail: string; done: boolean; active?: boolean; status?: string; children?: ReactNode
-}) {
- const tr = useTr()
- const label = tr(done ? 'Ready' : status ?? (active ? 'Needs access' : 'Waiting'))
- return <div className={`computer-access-row ${done ? 'granted' : active ? 'current' : 'waiting'}`}>
- <span className="computer-access-badge" role="img" aria-label={label} title={label}>
- {done ? <Icon name="checkmark" size={12} weight="bold" /> : <Icon name={icon} size={15} />}
- </span>
- <div className="computer-access-row-body">
- <h2>{tr(title)}</h2>
- <p>{tr(detail)}</p>
- {!done ? <div className="computer-access-actions">{children}</div> : null}
- </div>
- </div>
-}
-
-function AccessNotice({ title, icon, error = false, children }: { title: string; icon: string; error?: boolean; children: ReactNode }) {
+export function AccessNotice({ title, icon, error = false, children }: { title: string; icon: string; error?: boolean; children: ReactNode }) {
const tr = useTr()
return <div className={`computer-access-notice ${error ? 'error' : ''}`} role={error ? 'alert' : 'status'}>
<Icon name={icon} size={16} /><div><strong>{tr(title)}</strong><p>{typeof children === 'string' ? tr(children) : children}</p></div>
</div>
}
-
-function SettingsHint({ app, control = false }: { app: string; control?: boolean }) {
- const tr = useTr()
- return <p className="computer-access-inline-note">
- {tr('In System Settings, look for')} <strong>{app}</strong>.{control ? <> {tr('It may be listed under Device Control and Data Access or Accessibility.')}</> : null} {tr('Return here after granting access; if asked, allow the helper to restart.')}
- </p>
-}
-
-function SettingsLink({ action }: { action: () => void }) {
- const tr = useTr()
- return <Button kind="secondary" onClick={action}>{tr('Open System Settings')} <Icon name="arrow.up.right.square" size={10} /></Button>
-}