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.

feat(desktop): install the host on an SSH computer in one click

leepokai074c61561ef7
diff --git a/apps/desktop/src/main/ssh-command.ts b/apps/desktop/src/main/ssh-command.ts
index c4692727..d480c697 100644
--- a/apps/desktop/src/main/ssh-command.ts
+++ b/apps/desktop/src/main/ssh-command.ts
@@ -15,6 +15,37 @@ export const remoteInfoCommand = (port: number, folder = '.codync') => {
return `sh -lc 'PATH="${REMOTE_PATH}" codync-host info --json --port ${port}'`
}
+const INSTALL_SCRIPT = 'https://raw.githubusercontent.com/leepokai/Codync/main/packaging/install.sh'
+/** The service step prints this when linger is off and turning it on needs sudo (`SSH_LINGER_COMMAND`). */
+export const LINGER_NEEDED = 'codync-linger-needed'
+
+/** Install's two remote steps, in order: each its own SSH command, so the card can say which one runs. */
+export const installSteps = [
+ { kind: 'download', title: 'Installing codync-host…', timeout: 300_000 },
+ { kind: 'service', title: 'Starting codync-host…', timeout: 120_000 },
+] as const
+export type InstallStep = typeof installSteps[number]['kind']
+
+/**
+ * The released host into `~/.local/bin` (where `remoteInfoCommand` looks), then its service on the profile's
+ * validated port. Linux keeps a user's services running after logout only with linger, which usually needs
+ * sudo: the service step tries without it and prints `LINGER_NEEDED` when that fails.
+ */
+export const remoteInstallCommand = (step: InstallStep, port: number) => step === 'download'
+ // Read whole first: piped straight in, a failed download would be an empty script that "succeeds".
+ ? `sh -lc 'script=$(curl -fsSL ${INSTALL_SCRIPT}) && printf "%s\\n" "$script" | CODYNC_BIN_DIR="$HOME/.local/bin" sh -s -- --host-only'`
+ : `sh -lc 'PATH="$HOME/.local/bin:$PATH"; codync-host install --port ${port} && { [ "$(uname -s)" != Linux ] || [ "$(loginctl show-user "$(id -un)" -p Linger --value 2>/dev/null)" = yes ] || loginctl --no-ask-password enable-linger 2>/dev/null || echo ${LINGER_NEEDED}; }'`
+
+/** Whether the service step said linger needs the user (`LINGER_NEEDED`). */
+export const needsLinger = (stdout: string) => stdout.split(/\r?\n/).some((line) => line.trim() === LINGER_NEEDED)
+
+/** The last lines an install printed, for the card: its errors (stderr) if any, without colors or progress redraws. */
+export function installOutput(stdout: string, stderr: string, count = 6) {
+ const lines = (text: string) => text.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '').split(/\r\n|\r|\n/).map((l) => l.trimEnd()).filter(Boolean)
+ const err = lines(stderr)
+ return (err.length > 0 ? err : lines(stdout)).slice(-count).join('\n')
+}
+
/** Codync's own known_hosts file in `dir`, this app's host data folder (`~/.codync`, or a development sandbox's). */
export const codyncKnownHosts = (dir: string) => `${dir.replaceAll('\\', '/')}/ssh_known_hosts`
@@ -76,13 +107,19 @@ export function resolveArguments(p: SSHProfile) {
return [...args, '--', p.host]
}
-/** The remote command is fixed; only the validated port number goes into it. */
-export const infoArguments = (p: SSHProfile, h: string, folder = '.codync', dir = `${h}/${folder}`) => [
+/** One fixed remote command; only the validated port number goes into it. */
+const commandArguments = (p: SSHProfile, h: string, dir: string | undefined, command: string) => [
'-T', '-o', 'BatchMode=yes', '-o', 'ConnectTimeout=10', '-o', 'ForwardAgent=no', '-o', 'ForwardX11=no',
...hostKeyOptions(h, dir), ...targetOptions(p),
- '--', p.host, remoteInfoCommand(p.remotePort, folder),
+ '--', p.host, command,
]
+export const infoArguments = (p: SSHProfile, h: string, folder = '.codync', dir = `${h}/${folder}`) =>
+ commandArguments(p, h, dir, remoteInfoCommand(p.remotePort, folder))
+
+export const installArguments = (p: SSHProfile, step: InstallStep, h: string, dir?: string) =>
+ commandArguments(p, h, dir, remoteInstallCommand(step, p.remotePort))
+
export const tunnelArguments = (p: SSHProfile, localPort: number, h: string, dir?: string) => [
'-N', '-T', '-o', 'ExitOnForwardFailure=yes', '-o', 'ServerAliveInterval=15', '-o', 'ServerAliveCountMax=3',
// A shared master owns the listener and lets this child exit. The app must own
diff --git a/apps/desktop/src/main/ssh-process.ts b/apps/desktop/src/main/ssh-process.ts
index f52c25cb..0ea8f88d 100644
--- a/apps/desktop/src/main/ssh-process.ts
+++ b/apps/desktop/src/main/ssh-process.ts
@@ -31,14 +31,14 @@ export const lastLine = (text: string) => text.split(/\r?\n/).filter(Boolean).po
interface Result { status: number; stdout: string; stderr: string }
-/** Runs a tool with hidden Windows consoles while draining both output pipes; one that hangs is killed after 30 s. */
-export function run(bin: string, args: string[], input?: string): Promise<Result> {
+/** Runs a tool with hidden Windows consoles while draining both output pipes; one that hangs is killed after `timeout` ms. */
+export function run(bin: string, args: string[], input?: string, timeout = 30_000): Promise<Result> {
return new Promise((resolve) => {
let stdout = ''
let stderr = ''
let child: ChildProcess
try {
- child = spawn(bin, args, { stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'], windowsHide: true, timeout: 30_000 })
+ child = spawn(bin, args, { stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'], windowsHide: true, timeout })
} catch (error) {
return resolve({ status: -1, stdout, stderr: String(error) })
}
diff --git a/apps/desktop/src/main/ssh.ts b/apps/desktop/src/main/ssh.ts
index ca9e6055..fb589923 100644
--- a/apps/desktop/src/main/ssh.ts
+++ b/apps/desktop/src/main/ssh.ts
@@ -7,7 +7,7 @@ import { join } from 'node:path'
import { app, dialog, ipcMain, type BrowserWindow } from 'electron'
import { dataDir } from './host-controller'
import type { SSHAttachment, SSHProfile, SSHState, SSHStatus } from '../shared/ssh'
-import { codyncKnownHosts, infoArguments, keyscanArguments, knownHostsFiles, resolveArguments, tunnelArguments } from './ssh-command'
+import { codyncKnownHosts, infoArguments, installArguments, installOutput, installSteps, keyscanArguments, knownHostsFiles, needsLinger, resolveArguments, tunnelArguments } from './ssh-command'
import { authRefused, consistent, hostKeys, knownHostsLines, knownHostsName, parseConfig, parseInfo, usesProxy } from './ssh-parse'
import { KEYGEN, KEYSCAN, SSH, killOrphanTunnels, lastLine, missingTools, run, scanHostKeys, sshListens } from './ssh-process'
import { validate } from './ssh-profile'
@@ -62,6 +62,8 @@ class SSHComputers {
private connectedAt = new Map<string, number>()
/** Host key lines waiting for the user's "Trust and connect". */
private pendingKeys = new Map<string, string[]>()
+ /** Installed here, but the host stops at logout until the user enables linger with sudo. */
+ private needsLinger = new Set<string>()
constructor(private file: string, private emit: (s: SSHState) => void) {
try {
@@ -70,7 +72,7 @@ class SSHComputers {
}
get state(): SSHState {
- return { profiles: this.profiles, status: Object.fromEntries(this.status), attachments: [...this.attachments.values()] }
+ return { profiles: this.profiles, status: Object.fromEntries(this.status), attachments: [...this.attachments.values()], needsLinger: [...this.needsLinger] }
}
private changed() {
@@ -110,6 +112,7 @@ class SSHComputers {
this.profiles = this.profiles.filter((p) => p.id !== id)
this.status.delete(id)
this.backoff.delete(id)
+ this.needsLinger.delete(id)
this.persist()
this.changed()
}
@@ -149,6 +152,30 @@ class SSHComputers {
this.connect(id)
}
+ /**
+ * Install on a `notInstalled` card: the released host and its service over SSH, then a connection. Only
+ * the production app: there's no released development host.
+ */
+ async install(id: string) {
+ const profile = this.profiles.find((p) => p.id === id)
+ if (!profile || this.status.get(id)?.kind !== 'notInstalled' || identity.environment !== 'main') return
+ const token: Token = { cancelled: false }
+ this.tasks.set(id, token)
+ this.needsLinger.delete(id)
+ for (const step of installSteps) {
+ this.setStatus(id, { kind: 'installing', step: step.title })
+ const result = await run(SSH, installArguments(profile, step.kind, home, dataDir), undefined, step.timeout)
+ // Disconnected meanwhile; the remote step finishes on its own.
+ if (token.cancelled) return
+ if (result.status !== 0) {
+ this.tasks.delete(id)
+ return this.setStatus(id, { kind: 'notInstalled', failure: { output: installOutput(result.stdout, result.stderr) } })
+ }
+ if (needsLinger(result.stdout)) this.needsLinger.add(id)
+ }
+ this.connect(id)
+ }
+
// MARK: connecting
private async run(id: string, token: Token) {
@@ -375,6 +402,7 @@ export function registerSSH(getWindows: () => BrowserWindow[]) {
ipcMain.on('ssh:connect', (_e, id: string) => ssh.connect(id))
ipcMain.on('ssh:disconnect', (_e, id: string) => ssh.disconnect(id))
ipcMain.on('ssh:trustHostKey', (_e, id: string) => void ssh.trustHostKey(id))
+ ipcMain.on('ssh:install', (_e, id: string) => void ssh.install(id))
ipcMain.handle('ssh:chooseKey', async () => {
const result = await dialog.showOpenDialog({ defaultPath: join(home, '.ssh'), properties: ['openFile', 'showHiddenFiles'] })
return result.canceled ? null : (result.filePaths[0] ?? null)
diff --git a/apps/desktop/src/preload/ssh.ts b/apps/desktop/src/preload/ssh.ts
index 0d11db58..dbc76203 100644
--- a/apps/desktop/src/preload/ssh.ts
+++ b/apps/desktop/src/preload/ssh.ts
@@ -14,6 +14,7 @@ export const sshBridge: SSHBridge = {
connect: (id) => ipcRenderer.send('ssh:connect', id),
disconnect: (id) => ipcRenderer.send('ssh:disconnect', id),
trustHostKey: (id) => ipcRenderer.send('ssh:trustHostKey', id),
+ install: (id) => ipcRenderer.send('ssh:install', id),
chooseKey: () => ipcRenderer.invoke('ssh:chooseKey') as Promise<string | null>,
configHosts: () => ipcRenderer.invoke('ssh:configHosts') as Promise<SSHConfigHosts>,
setConfigAccess: (access) => ipcRenderer.invoke('ssh:setConfigAccess', access) as Promise<SSHConfigHosts>,
diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.ts
index 2f2a6460..c9c115ca 100644
--- a/apps/desktop/src/renderer/demo/bridge.ts
+++ b/apps/desktop/src/renderer/demo/bridge.ts
@@ -59,13 +59,14 @@ const bridge: CodyncBridge = {
},
speech: { available: false, locales: () => [], start() {}, stop() {}, onEvent: none, shortcut: async () => 'off', setShortcut: async () => 'off', setCalling() {} },
ssh: {
- state: async () => ({ profiles: [], status: {}, attachments: [] }),
+ state: async () => ({ profiles: [], status: {}, attachments: [], needsLinger: [] }),
onChange: none,
save: async () => DEMO_UNAVAILABLE,
remove() {},
connect() {},
disconnect() {},
trustHostKey() {},
+ install() {},
chooseKey: async () => null,
configHosts: async () => ({ access: 'denied', hosts: [] }),
setConfigAccess: async () => ({ access: 'denied', hosts: [] }),
diff --git a/apps/desktop/src/renderer/lib/auto-claim.test.ts b/apps/desktop/src/renderer/lib/auto-claim.test.ts
index cfd6eda7..31c06ddd 100644
--- a/apps/desktop/src/renderer/lib/auto-claim.test.ts
+++ b/apps/desktop/src/renderer/lib/auto-claim.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { mayAutoClaim, mayOfferMove } from './auto-claim.ts'
+import { mayAutoClaim, mayJoinAfterInstall, mayOfferMove } from './auto-claim.ts'
const host = { id: 'new', online: true, cloud: { enabled: true, owner: null } }
@@ -34,3 +34,11 @@ test('a computer in another account offers to move into the signed-in one', () =
assert.equal(mayOfferMove({ ...owned('a'), online: false }, 'b', []), false)
assert.equal(mayOfferMove({ ...host, cloud: { enabled: true, owner: { userId: 'a' }, relay: 'private' } }, 'b', []), false)
})
+
+test('an SSH computer installed from here joins unless it is in an account or on a private relay', () => {
+ // Its cloud may still be off: Add to account turns it on, as installing shows the intent.
+ assert.equal(mayJoinAfterInstall({ owner: null }), true)
+ assert.equal(mayJoinAfterInstall({ owner: null, relay: 'codync' }), true)
+ assert.equal(mayJoinAfterInstall({ owner: { userId: 'a' } }), false)
+ assert.equal(mayJoinAfterInstall({ owner: null, relay: 'private' }), false)
+})
diff --git a/apps/desktop/src/renderer/lib/auto-claim.ts b/apps/desktop/src/renderer/lib/auto-claim.ts
index d6674713..b5d8bfda 100644
--- a/apps/desktop/src/renderer/lib/auto-claim.ts
+++ b/apps/desktop/src/renderer/lib/auto-claim.ts
@@ -25,6 +25,9 @@ export function mayAutoClaim(host: ClaimCandidate, keptOut: readonly string[], s
return joinable(host, keptOut) && !host.cloud?.owner && !seen.includes(host.id)
}
+/** Whether an SSH computer just installed from here joins the account: not one in an account already, nor on a private relay (no accounts). */
+export const mayJoinAfterInstall = (cloud: Pick<CloudStatus, 'owner' | 'relay'>) => !cloud.owner && cloud.relay !== 'private'
+
/**
* Whether to ask to move this computer into the signed-in account: it's in another one, and signing in
* here with a different account means it goes with that one now. Saying no keeps it out (`keptOut`).
diff --git a/apps/desktop/src/renderer/store/cloud.ts b/apps/desktop/src/renderer/store/cloud.ts
index 44e1c537..cfec6806 100644
--- a/apps/desktop/src/renderer/store/cloud.ts
+++ b/apps/desktop/src/renderer/store/cloud.ts
@@ -1,5 +1,5 @@
import type { CloudStatus, ClaimSignature } from '@shared/models'
-import { mayAutoClaim, mayOfferMove, type ClaimCandidate } from '../lib/auto-claim'
+import { mayAutoClaim, mayJoinAfterInstall, mayOfferMove, type ClaimCandidate } from '../lib/auto-claim'
import { Observable } from '../lib/observable'
import { isOlderCopy } from '../lib/older-copy'
import { relayAddressToSave } from '../lib/relay-address'
@@ -253,6 +253,16 @@ export class CloudModel extends Observable {
}
}
+ /** Add to account for an SSH computer just installed from here (installing shows the intent), once its host is up. */
+ async joinAfterInstall(store: BotStore) {
+ if (!this.userId) return
+ try {
+ if (mayJoinAfterInstall(await (await store.ready()).call<CloudStatus>('cloudStatus'))) await this.claim(store)
+ } catch (error) {
+ this.fail(error)
+ }
+ }
+
/** §4.2 A: makes a computer this app manages part of the account; its cloud is turned on first. */
async claim(store: BotStore, quiet = false): Promise<boolean> {
const user = this.userId
diff --git a/apps/desktop/src/renderer/views/settings/SSHRow.tsx b/apps/desktop/src/renderer/views/settings/SSHRow.tsx
index 81cf3a9b..1afe90f9 100644
--- a/apps/desktop/src/renderer/views/settings/SSHRow.tsx
+++ b/apps/desktop/src/renderer/views/settings/SSHRow.tsx
@@ -1,14 +1,20 @@
-import { SSH_INSTALL_COMMAND, type SSHProfile, type SSHStatus } from '@shared/ssh'
-import { Button, IconButton, Reveal } from '../../components/Controls'
+import { SSH_LINGER_COMMAND, type SSHProfile, type SSHStatus } from '@shared/ssh'
+import { Button, IconButton, Reveal, Spinner } from '../../components/Controls'
import { Icon } from '../../components/Icon'
-import { HStack, IconSlot, VStack } from '../../components/Stack'
+import { HStack, IconSlot, Spacer, VStack } from '../../components/Stack'
import { Text } from '../../components/Text'
import { analytics } from '../../store/analytics'
import { sshStatusDetail } from '@shared/ssh-startup'
+import { useTr } from '../../lib/use-language'
+import { useSSH } from './ssh-model'
export function SSHRow({ profile, status, edit, attached = true }: { profile: SSHProfile; status: SSHStatus; attached?: boolean; edit: () => void }) {
+ const tr = useTr()
+ const ssh = useSSH()
const bridge = window.codync.ssh
+ // There's no released development host to install.
const dev = window.codync.appScheme === 'codync-dev'
+ const named = (text: string) => tr(text).replaceAll('{name}', profile.host)
const target = `${profile.user ? `${profile.user}@` : ''}${profile.host}${profile.port !== null ? `:${profile.port}` : ''}`
const line = (() => {
switch (status.kind) {
@@ -16,6 +22,8 @@ export function SSHRow({ profile, status, edit, attached = true }: { profile: SS
return `${target} · Not connected`
case 'connecting':
return status.step
+ case 'installing':
+ return tr(status.step)
case 'confirmHostKey':
return `${target} · Confirm the host key`
case 'connected':
@@ -25,11 +33,12 @@ export function SSHRow({ profile, status, edit, attached = true }: { profile: SS
case 'failed':
return status.message
case 'notInstalled':
- return dev ? `Install Codync Dev on ${profile.host} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.` : `codync-host isn't installed on ${profile.host}. Install it there:`
+ if (dev) return named('Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.')
+ return named(status.failure ? "Couldn't install codync-host on {name}." : "codync-host isn't installed on {name}.")
}
})()
const problem = status.kind === 'retrying' || status.kind === 'failed' || status.kind === 'notInstalled'
- const active = status.kind === 'connected' || status.kind === 'connecting' || status.kind === 'retrying'
+ const active = status.kind === 'connected' || status.kind === 'connecting' || status.kind === 'retrying' || status.kind === 'installing'
return (
<div className="settings-card settings-appear">
<div className="settings-row">
@@ -40,6 +49,7 @@ export function SSHRow({ profile, status, edit, attached = true }: { profile: SS
<Text size="callout" weight="medium">{profile.name || profile.host}</Text>
<Text size="caption" tone={problem ? 'attention' : 'secondary'}>{line}</Text>
</VStack>
+ {status.kind === 'installing' ? <Spinner /> : null}
{active ? (
<IconButton title="Disconnect" icon="stop.circle" onClick={() => bridge.disconnect(profile.id)} />
) : (
@@ -66,11 +76,22 @@ export function SSHRow({ profile, status, edit, attached = true }: { profile: SS
) : null}
</Reveal>
<Reveal show={status.kind === 'notInstalled' && !dev}>
- <HStack gap={6} className="settings-row">
- <span className="settings-code selectable">{SSH_INSTALL_COMMAND}</span>
- <IconButton title="Copy install command" icon="doc.on.doc" onClick={() => { analytics.track({ event: 'link_opened', link: 'install_command' }); window.codync.app.copy(SSH_INSTALL_COMMAND) }} />
+ <HStack gap={8} className="settings-row">
+ {status.kind === 'notInstalled' && status.failure?.output ? (
+ <span className="settings-code settings-output selectable">{status.failure.output}</span>
+ ) : <Spacer />}
+ <Button onClick={() => ssh.install(profile.id)}>Install</Button>
</HStack>
</Reveal>
+ <Reveal show={ssh.state.needsLinger.includes(profile.id)}>
+ <VStack gap={6}>
+ <Text size="caption" tone="secondary">{named('To keep codync-host running on {name} after you log out, run this there:')}</Text>
+ <HStack gap={6}>
+ <span className="settings-code selectable">{SSH_LINGER_COMMAND}</span>
+ <IconButton title="Copy command" icon="doc.on.doc" onClick={() => { analytics.track({ event: 'link_opened', link: 'install_command' }); window.codync.app.copy(SSH_LINGER_COMMAND) }} />
+ </HStack>
+ </VStack>
+ </Reveal>
</div>
)
}
diff --git a/apps/desktop/src/renderer/views/settings/settings.css b/apps/desktop/src/renderer/views/settings/settings.css
index d8c993d0..d896a36a 100644
--- a/apps/desktop/src/renderer/views/settings/settings.css
+++ b/apps/desktop/src/renderer/views/settings/settings.css
@@ -105,6 +105,11 @@
background: var(--code-background);
border-radius: var(--radius-xs);
}
+/* Several lines a command printed, kept as it wrapped them. */
+.settings-output {
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+}
.settings-mono {
font-family: var(--mono);
}
diff --git a/apps/desktop/src/renderer/views/settings/ssh-model.ts b/apps/desktop/src/renderer/views/settings/ssh-model.ts
index 3a1c1d5c..5f4bf829 100644
--- a/apps/desktop/src/renderer/views/settings/ssh-model.ts
+++ b/apps/desktop/src/renderer/views/settings/ssh-model.ts
@@ -8,10 +8,12 @@ import { BotStore } from '../../store/bot-store'
/** The main process's SSH computers, mirrored for views. */
class SSHModel extends Observable {
- state: SSHState = { profiles: [], status: {}, attachments: [] }
+ state: SSHState = { profiles: [], status: {}, attachments: [], needsLinger: [] }
/** `~/.ssh/config`'s hosts and whether the user allowed reading it; null until known. */
config: SSHConfigHosts | null = null
private started = false
+ /** Profiles installed from here: their computer joins the account once it's up (installing shows the intent). */
+ private joining = new Set<string>()
start() {
if (this.started) return
@@ -45,6 +47,16 @@ class SSHModel extends Observable {
return (this.config?.hosts ?? []).filter((h) => !added.has(h.alias))
}
+ install(id: string) {
+ this.joining.add(id)
+ window.codync.ssh.install(id)
+ }
+
+ /** Whether the computer attached through `profileId` was installed from here; true once. */
+ takeInstalled(profileId: string) {
+ return this.joining.delete(profileId)
+ }
+
status(id: string) {
return this.state.status[id] ?? { kind: 'idle' as const }
}
@@ -77,8 +89,10 @@ export function useSSHAttachments(app: AppModel) {
if (attached.get(id) === key) continue
const cached = app.computers.find((c) => c.id === id)
const computer: Computer = { ...a.computer, urls: [], color: cached?.color ?? null, device: cached?.device ?? null }
- app.attach(computer, new BotStore(computer, true, () => new LoopbackTransport(a.baseURL, a.token)))
+ const store = new BotStore(computer, true, () => new LoopbackTransport(a.baseURL, a.token))
+ app.attach(computer, store)
attached.set(id, key)
+ if (ssh.takeInstalled(a.profileId)) void app.cloud.joinAfterInstall(store)
}
for (const id of [...attached.keys()]) {
if (live.has(id)) continue
diff --git a/apps/desktop/src/shared/ssh-install.test.ts b/apps/desktop/src/shared/ssh-install.test.ts
new file mode 100644
index 00000000..dcd94bff
--- /dev/null
+++ b/apps/desktop/src/shared/ssh-install.test.ts
@@ -0,0 +1,93 @@
+import assert from 'node:assert/strict'
+import { spawnSync } from 'node:child_process'
+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { test } from 'node:test'
+import { LINGER_NEEDED, installArguments, installOutput, installSteps, needsLinger, remoteInstallCommand, type InstallStep } from '../main/ssh-command.ts'
+import type { SSHProfile } from './ssh.ts'
+
+const skip = process.platform === 'win32'
+
+function tool(dir: string, name: string, body: string) {
+ mkdirSync(dir, { recursive: true })
+ writeFileSync(join(dir, name), `#!/bin/sh\n${body}\n`)
+ chmodSync(join(dir, name), 0o755)
+}
+
+/**
+ * Runs an install step's remote command under `sh -c` in a fixture home, with fake `curl`, `uname`, `loginctl`
+ * and `codync-host` first on PATH: `env` picks how they answer.
+ */
+function remote(step: InstallStep, env: Record<string, string>) {
+ const root = mkdtempSync(join(tmpdir(), 'codync-install-'))
+ try {
+ const home = join(root, 'home')
+ const bin = join(root, 'bin')
+ // The fake install.sh records where it was told to install and its options.
+ tool(bin, 'curl', '[ "$CURL_FAILS" = 1 ] && exit 22\nprintf \'%s\\n\' \'printf "%s\\n" "$CODYNC_BIN_DIR" "$@" > "$HOME/script-args"\'')
+ tool(bin, 'uname', 'echo "$OS"')
+ tool(bin, 'loginctl', 'case $1 in show-user) echo "$LINGER" ;; --no-ask-password) [ "$2" = enable-linger ] && exit "$ENABLE_EXIT" ;; esac\nexit 1')
+ tool(join(home, '.local/bin'), 'codync-host', 'echo "$@" > "$HOME/host-args"\nexit "$HOST_EXIT"')
+ const command = remoteInstallCommand(step, 19333).replace(/^sh -lc '/, '').replace(/'$/, '')
+ const result = spawnSync('/bin/sh', ['-c', command], {
+ encoding: 'utf8',
+ env: { HOME: home, PATH: `${bin}:/usr/bin:/bin`, OS: 'Linux', LINGER: 'no', ENABLE_EXIT: '1', HOST_EXIT: '0', ...env },
+ })
+ const read = (name: string) => { try { return readFileSync(join(home, name), 'utf8') } catch { return null } }
+ return { status: result.status, stdout: result.stdout, scriptArgs: read('script-args'), hostArgs: read('host-args'), home }
+ } finally {
+ rmSync(root, { recursive: true, force: true })
+ }
+}
+
+test('the download step runs install.sh for the host only, into ~/.local/bin', { skip }, () => {
+ const r = remote('download', {})
+ assert.equal(r.status, 0)
+ assert.equal(r.scriptArgs, `${join(r.home, '.local/bin')}\n--host-only\n`)
+})
+
+test('a failed download fails the step instead of running an empty script', { skip }, () => {
+ const r = remote('download', { CURL_FAILS: '1' })
+ assert.notEqual(r.status, 0)
+ assert.equal(r.scriptArgs, null)
+})
+
+test('the service step installs the service on the profile port', { skip }, () => {
+ const r = remote('service', { LINGER: 'yes' })
+ assert.equal(r.status, 0)
+ assert.equal(r.hostArgs, 'install --port 19333\n')
+ assert.equal(needsLinger(r.stdout), false)
+})
+
+test('Linux without linger asks for the sudo command only when enabling it is refused', { skip }, () => {
+ assert.equal(needsLinger(remote('service', { LINGER: 'no', ENABLE_EXIT: '1' }).stdout), true)
+ assert.equal(needsLinger(remote('service', { LINGER: 'no', ENABLE_EXIT: '0' }).stdout), false)
+ // No linger on macOS: launchd keeps the agent.
+ assert.equal(needsLinger(remote('service', { OS: 'Darwin', LINGER: 'no' }).stdout), false)
+})
+
+test('a failed service install fails the step without a linger hint', { skip }, () => {
+ const r = remote('service', { HOST_EXIT: '1' })
+ assert.notEqual(r.status, 0)
+ assert.equal(needsLinger(r.stdout), false)
+})
+
+test('install steps run in order over the same hardened ssh options as the info command', () => {
+ assert.deepEqual(installSteps.map((s) => s.kind), ['download', 'service'])
+ const profile: SSHProfile = { id: 'p', host: 'vps', user: 'me', port: 2222, identityFile: null, remotePort: 19333, computerId: null, name: '' }
+ const args = installArguments(profile, 'service', '/home/me', '/home/me/.codync')
+ assert.deepEqual(args.slice(-3), ['--', 'vps', remoteInstallCommand('service', 19333)])
+ for (const option of ['BatchMode=yes', 'ForwardAgent=no', 'StrictHostKeyChecking=yes']) assert.ok(args.includes(option), option)
+ assert.deepEqual(args.slice(args.indexOf('-p'), args.indexOf('-p') + 2), ['-p', '2222'])
+})
+
+test('the card shows the last lines of errors, without colors or progress redraws', () => {
+ const stderr = '###### 12.0%\r########## 100.0%\n\x1b[31merror:\x1b[0m checksum mismatch for codync-host-linux-arm64.tar.gz\n'
+ assert.equal(installOutput('\x1b[1m==>\x1b[0m Downloading', stderr, 2), '########## 100.0%\nerror: checksum mismatch for codync-host-linux-arm64.tar.gz')
+ // Nothing on stderr: what it printed instead.
+ assert.equal(installOutput('a\nb\nc\n', '', 2), 'b\nc')
+ assert.equal(installOutput('', ''), '')
+ assert.equal(needsLinger(`Tip: \`loginctl enable-linger $USER\` keeps the host running\n${LINGER_NEEDED}\n`), true)
+ assert.equal(needsLinger('Tip: `loginctl enable-linger $USER` keeps the host running\n'), false)
+})
diff --git a/apps/desktop/src/shared/ssh-startup.test.ts b/apps/desktop/src/shared/ssh-startup.test.ts
index 92585638..53d6fd5a 100644
--- a/apps/desktop/src/shared/ssh-startup.test.ts
+++ b/apps/desktop/src/shared/ssh-startup.test.ts
@@ -5,7 +5,7 @@ import { isSSHConnecting, showsChat, sshSummary, sshStatusDetail } from './ssh-s
import type { SSHProfile, SSHState, SSHStatus } from './ssh.ts'
const profile: SSHProfile = { id: 'remote', host: 'remote', name: 'Remote', port: null, user: null, identityFile: null, remotePort: 19222, computerId: null }
-const state = (status?: SSHStatus): SSHState => ({ profiles: [profile], status: status ? { remote: status } : {}, attachments: [] })
+const state = (status?: SSHStatus): SSHState => ({ profiles: [profile], status: status ? { remote: status } : {}, attachments: [], needsLinger: [] })
test('saved profiles keep connection status and management visible in every state', () => {
const statuses: SSHStatus[] = [
@@ -15,7 +15,7 @@ test('saved profiles keep connection status and management visible in every stat
for (const host of ['notInstalled', 'failed', 'missingBinary'] satisfies HostState['kind'][]) {
for (const status of statuses) assert.equal(showsChat(host, 0, state(status)), true, `${host}/${status.kind}`)
assert.equal(showsChat(host, 0, state()), true, `${host}/missing SSH status`)
- assert.equal(showsChat(host, 0, { profiles: [], status: {}, attachments: [] }), false)
+ assert.equal(showsChat(host, 0, { profiles: [], status: {}, attachments: [], needsLinger: [] }), false)
}
})
@@ -50,3 +50,13 @@ test('summary separates active connection attempts from profiles needing attenti
assert.equal(sshSummary([{ kind: 'notInstalled' }]), '1 needs attention')
assert.equal(sshSummary([]), '')
})
+
+test('an install in progress counts as connecting and shows its step', () => {
+ const installing: SSHStatus = { kind: 'installing', step: 'Starting codync-host…' }
+ assert.equal(isSSHConnecting(installing), true)
+ assert.equal(sshStatusDetail(installing), 'Starting codync-host…')
+ assert.equal(sshSummary([installing]), '1 connecting…')
+ assert.equal(showsChat('notInstalled', 0, state(installing)), true)
+ // A failed install leaves the computer not installed, so Install is offered again.
+ assert.equal(sshSummary([{ kind: 'notInstalled', failure: { output: 'error: download failed' } }]), '1 needs attention')
+})
diff --git a/apps/desktop/src/shared/ssh-startup.ts b/apps/desktop/src/shared/ssh-startup.ts
index 30d5f1c5..17521e9a 100644
--- a/apps/desktop/src/shared/ssh-startup.ts
+++ b/apps/desktop/src/shared/ssh-startup.ts
@@ -2,7 +2,7 @@ import type { HostState } from './ipc.ts'
import type { SSHState, SSHStatus } from './ssh.ts'
export function isSSHConnecting(status: SSHStatus): boolean {
- return status.kind === 'connecting' || status.kind === 'retrying'
+ return status.kind === 'connecting' || status.kind === 'retrying' || status.kind === 'installing'
}
/** Saved remote computers keep their status and recovery controls reachable. */
@@ -22,7 +22,8 @@ export function sshSummary(statuses: SSHStatus[]): string {
export function sshStatusDetail(status: SSHStatus, attached = true): string {
switch (status.kind) {
case 'idle': return 'Not connected'
- case 'connecting': return status.step
+ case 'connecting':
+ case 'installing': return status.step
case 'retrying': return `${status.message} Retrying…`
case 'confirmHostKey': return 'Confirm host key…'
case 'connected': return attached ? 'Connected' : 'Connected · opening…'
diff --git a/apps/desktop/src/shared/ssh.ts b/apps/desktop/src/shared/ssh.ts
index f18102d7..fc5d7df7 100644
--- a/apps/desktop/src/shared/ssh.ts
+++ b/apps/desktop/src/shared/ssh.ts
@@ -25,7 +25,10 @@ export type SSHStatus =
| { kind: 'retrying'; message: string }
/** Needs the user (settings, the remote side, or a security problem); nothing retries. */
| { kind: 'failed'; message: string }
- | { kind: 'notInstalled' }
+ /** No codync-host there; `failure` is the last Install that didn't finish, with the last lines it printed. */
+ | { kind: 'notInstalled'; failure?: { output: string } }
+ /** Install runs `install.sh` and `codync-host install` over SSH, then connects. */
+ | { kind: 'installing'; step: string }
/** A connected tunnel: the computer behind it, as a loopback host. */
export interface SSHAttachment {
@@ -39,6 +42,8 @@ export interface SSHState {
profiles: SSHProfile[]
status: Record<string, SSHStatus>
attachments: SSHAttachment[]
+ /** Profiles whose install couldn't keep the host running after logout (`SSH_LINGER_COMMAND`). */
+ needsLinger: string[]
}
/** A name ssh takes as a destination without it reading as an option: an alias or a hostname. */
@@ -60,7 +65,8 @@ export interface SSHConfigHosts {
hosts: SSHConfigHost[]
}
-export const SSH_INSTALL_COMMAND = 'brew install leepokai/codync/codync-host && codync-host install'
+/** Needs sudo, so Install can't run it: keeps a Linux host running while no one is logged in. */
+export const SSH_LINGER_COMMAND = 'sudo loginctl enable-linger "$USER"'
export const newSSHProfile = (remotePort = 19222): SSHProfile => ({
id: crypto.randomUUID(),
@@ -82,6 +88,8 @@ export interface SSHBridge {
connect(id: string): void
disconnect(id: string): void
trustHostKey(id: string): void
+ /** Installs codync-host on a `notInstalled` computer, then connects. */
+ install(id: string): void
/** The system file dialog; the chosen path, or null. */
chooseKey(): Promise<string | null>
/** The hosts in `~/.ssh/config`, read only once the user allowed it. */
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
index 8706cbdc..223c2e4d 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/de.json
@@ -1070,7 +1070,6 @@
"q quits": "q beendet",
"· now": "· jetzt",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "Installiere Codync Dev auf {name} und öffne es einmal. Installiere unter Linux den Entwicklungs-Host als ~/.local/bin/codync-dev-host.",
- "codync-host isn't installed on {name}. Install it there:": "codync-host ist auf {name} nicht installiert. Installiere es dort:",
"Version {version} is available: run codync-host update": "Version {version} ist verfügbar: führe codync-host update aus",
"Download failed: {error}": "Download fehlgeschlagen: {error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} Entwurf behalten; Enter versucht es erneut, Ctrl+C löscht den Text.",
@@ -1481,5 +1480,11 @@
"Keep it there": "Dort lassen",
"Move here": "Hierher verschieben",
"If the computer asks, check it shows {code}.": "Wenn der Computer fragt, prüfe, dass er {code} anzeigt.",
- "Connect to the internet to pair, so Codync can confirm your account.": "Verbinde dich mit dem Internet, damit Codync beim Koppeln dein Konto bestätigen kann."
+ "Connect to the internet to pair, so Codync can confirm your account.": "Verbinde dich mit dem Internet, damit Codync beim Koppeln dein Konto bestätigen kann.",
+ "Installing codync-host…": "codync-host wird installiert…",
+ "Starting codync-host…": "codync-host wird gestartet…",
+ "Couldn't install codync-host on {name}.": "codync-host konnte nicht auf {name} installiert werden.",
+ "codync-host isn't installed on {name}.": "codync-host ist auf {name} nicht installiert.",
+ "To keep codync-host running on {name} after you log out, run this there:": "Damit codync-host auf {name} weiterläuft, wenn du dich abmeldest, führe dort Folgendes aus:",
+ "Copy command": "Befehl kopieren"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
index f237e22c..b23c4934 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/es.json
@@ -1070,7 +1070,6 @@
"q quits": "q sale",
"· now": "· ahora",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "Instala Codync Dev en {name} y ábrelo una vez. En Linux, instala el host de desarrollo como ~/.local/bin/codync-dev-host.",
- "codync-host isn't installed on {name}. Install it there:": "codync-host no está instalado en {name}. Instálalo allí:",
"Version {version} is available: run codync-host update": "La versión {version} está disponible: ejecuta codync-host update",
"Download failed: {error}": "Error de descarga: {error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} Borrador conservado; Enter reintenta, Ctrl+C borra el texto.",
@@ -1481,5 +1480,11 @@
"Keep it there": "Dejarla ahí",
"Move here": "Mover aquí",
"If the computer asks, check it shows {code}.": "Si el ordenador lo pregunta, comprueba que muestra {code}.",
- "Connect to the internet to pair, so Codync can confirm your account.": "Conéctate a internet para vincular, así Codync puede confirmar tu cuenta."
+ "Connect to the internet to pair, so Codync can confirm your account.": "Conéctate a internet para vincular, así Codync puede confirmar tu cuenta.",
+ "Installing codync-host…": "Instalando codync-host…",
+ "Starting codync-host…": "Iniciando codync-host…",
+ "Couldn't install codync-host on {name}.": "No se pudo instalar codync-host en {name}.",
+ "codync-host isn't installed on {name}.": "codync-host no está instalado en {name}.",
+ "To keep codync-host running on {name} after you log out, run this there:": "Para que codync-host siga funcionando en {name} cuando cierres la sesión, ejecuta esto allí:",
+ "Copy command": "Copiar comando"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
index da6d86c8..b5ea501a 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/fr.json
@@ -1070,7 +1070,6 @@
"q quits": "q pour quitter",
"· now": "· maintenant",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "Installez Codync Dev sur {name} et ouvrez-le une fois. Sur Linux, installez l’hôte de développement sous ~/.local/bin/codync-dev-host.",
- "codync-host isn't installed on {name}. Install it there:": "codync-host n’est pas installé sur {name}. Installez-le là-bas :",
"Version {version} is available: run codync-host update": "La version {version} est disponible : exécutez codync-host update",
"Download failed: {error}": "Échec du téléchargement : {error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} Brouillon conservé ; Entrée pour réessayer, Ctrl+C pour effacer le texte.",
@@ -1481,5 +1480,11 @@
"Keep it there": "Le laisser là",
"Move here": "Déplacer ici",
"If the computer asks, check it shows {code}.": "Si l'ordinateur le demande, vérifiez qu'il affiche {code}.",
- "Connect to the internet to pair, so Codync can confirm your account.": "Connectez-vous à Internet pour appairer, afin que Codync confirme votre compte."
+ "Connect to the internet to pair, so Codync can confirm your account.": "Connectez-vous à Internet pour appairer, afin que Codync confirme votre compte.",
+ "Installing codync-host…": "Installation de codync-host…",
+ "Starting codync-host…": "Démarrage de codync-host…",
+ "Couldn't install codync-host on {name}.": "Impossible d’installer codync-host sur {name}.",
+ "codync-host isn't installed on {name}.": "codync-host n’est pas installé sur {name}.",
+ "To keep codync-host running on {name} after you log out, run this there:": "Pour que codync-host continue de tourner sur {name} après votre déconnexion, exécutez ceci là-bas :",
+ "Copy command": "Copier la commande"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
index f6a7732b..703b5076 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ja.json
@@ -1070,7 +1070,6 @@
"q quits": "qで終了",
"· now": "・ 今",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "{name} に Codync Dev をインストールし、一度開きます。 Linux で、開発ホストを ~/.local/bin/codync-dev-host としてインストールします。",
- "codync-host isn't installed on {name}. Install it there:": "codync-host は {name} にインストールされていません。そこにインストールします。",
"Version {version} is available: run codync-host update": "バージョン {version} が利用可能です: codync-host update を実行します",
"Download failed: {error}": "ダウンロードに失敗しました: {error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} ドラフトは保存されました。再試行を入力し、Ctrl+C でテキストをクリアします。",
@@ -1481,5 +1480,11 @@
"Keep it there": "そのままにする",
"Move here": "ここに移動",
"If the computer asks, check it shows {code}.": "コンピュータに確認を求められたら、{code} と表示されているか確かめてください。",
- "Connect to the internet to pair, so Codync can confirm your account.": "ペアリングするにはインターネットに接続してください。Codync がアカウントを確認します。"
+ "Connect to the internet to pair, so Codync can confirm your account.": "ペアリングするにはインターネットに接続してください。Codync がアカウントを確認します。",
+ "Installing codync-host…": "codync-host をインストール中…",
+ "Starting codync-host…": "codync-host を起動中…",
+ "Couldn't install codync-host on {name}.": "{name} に codync-host をインストールできませんでした。",
+ "codync-host isn't installed on {name}.": "codync-host は {name} にインストールされていません。",
+ "To keep codync-host running on {name} after you log out, run this there:": "ログアウト後も {name} で codync-host を動かし続けるには、そこで次を実行してください:",
+ "Copy command": "コマンドをコピー"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
index 603dfcb3..667f43eb 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/ko.json
@@ -1070,7 +1070,6 @@
"q quits": "q로 종료",
"· now": "· 지금",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "{name}에 Codync Dev를 설치하고 한 번 여세요. Linux에서는 개발용 호스트를 ~/.local/bin/codync-dev-host에 설치하세요.",
- "codync-host isn't installed on {name}. Install it there:": "{name}에 codync-host가 설치되지 않았습니다. 해당 컴퓨터에 설치하세요:",
"Version {version} is available: run codync-host update": "{version} 버전 사용 가능: codync-host update를 실행하세요",
"Download failed: {error}": "다운로드 실패: {error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} 초안 유지됨; Enter로 다시 시도, Ctrl+C로 글 지우기.",
@@ -1481,5 +1480,11 @@
"Keep it there": "그대로 두기",
"Move here": "여기로 옮기기",
"If the computer asks, check it shows {code}.": "컴퓨터가 물으면 {code}가 표시되는지 확인하세요.",
- "Connect to the internet to pair, so Codync can confirm your account.": "페어링하려면 인터넷에 연결하세요. Codync가 계정을 확인해야 합니다."
+ "Connect to the internet to pair, so Codync can confirm your account.": "페어링하려면 인터넷에 연결하세요. Codync가 계정을 확인해야 합니다.",
+ "Installing codync-host…": "codync-host 설치 중…",
+ "Starting codync-host…": "codync-host 시작 중…",
+ "Couldn't install codync-host on {name}.": "{name}에 codync-host를 설치하지 못했습니다.",
+ "codync-host isn't installed on {name}.": "{name}에 codync-host가 설치되지 않았습니다.",
+ "To keep codync-host running on {name} after you log out, run this there:": "로그아웃한 뒤에도 {name}에서 codync-host가 계속 실행되게 하려면 해당 컴퓨터에서 다음을 실행하세요:",
+ "Copy command": "명령 복사"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
index af0dbf92..685c4a6a 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hans.json
@@ -1070,7 +1070,6 @@
"q quits": "q 退出",
"· now": "· 现在",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "在 {name} 上安装 Codync Dev 并打开一次。Linux 上请把开发用的 host 装成 ~/.local/bin/codync-dev-host。",
- "codync-host isn't installed on {name}. Install it there:": "{name} 上还没有安装 codync-host。请在那里安装:",
"Version {version} is available: run codync-host update": "已有 {version}:请运行 codync-host update",
"Download failed: {error}": "下载失败:{error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} 草稿还在;Enter 重试,Ctrl+C 清空文字。",
@@ -1481,5 +1480,11 @@
"Keep it there": "留在原处",
"Move here": "移到这里",
"If the computer asks, check it shows {code}.": "如果电脑问你,确认它显示 {code}。",
- "Connect to the internet to pair, so Codync can confirm your account.": "请连上网络再配对,Codync 才能确认你的账户。"
+ "Connect to the internet to pair, so Codync can confirm your account.": "请连上网络再配对,Codync 才能确认你的账户。",
+ "Installing codync-host…": "正在安装 codync-host…",
+ "Starting codync-host…": "正在启动 codync-host…",
+ "Couldn't install codync-host on {name}.": "无法在 {name} 上安装 codync-host。",
+ "codync-host isn't installed on {name}.": "{name} 上还没有安装 codync-host。",
+ "To keep codync-host running on {name} after you log out, run this there:": "要让 codync-host 在你退出登录后继续在 {name} 上运行,请在那里运行:",
+ "Copy command": "复制命令"
}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
index 2e77a686..69cfc586 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
+++ b/apps/ios/Kit/Sources/CodyncKit/Resources/Languages/zh-Hant.json
@@ -1070,7 +1070,6 @@
"q quits": "q 退出",
"· now": "· 現在",
"Install Codync Dev on {name} and open it once. On Linux, install the development host as ~/.local/bin/codync-dev-host.": "在 {name} 上安裝 Codync Dev 並開啟一次。Linux 上請把開發用的 host 裝成 ~/.local/bin/codync-dev-host。",
- "codync-host isn't installed on {name}. Install it there:": "{name} 上還沒有安裝 codync-host。請在那裡安裝:",
"Version {version} is available: run codync-host update": "已有 {version}:請執行 codync-host update",
"Download failed: {error}": "下載失敗:{error}",
"{error} Draft kept; Enter retries, Ctrl+C clears text.": "{error} 草稿還在;Enter 重試,Ctrl+C 清空文字。",
@@ -1481,5 +1480,11 @@
"Keep it there": "留在原處",
"Move here": "移到這裡",
"If the computer asks, check it shows {code}.": "如果電腦問你,確認它顯示 {code}。",
- "Connect to the internet to pair, so Codync can confirm your account.": "請連上網路再配對,Codync 才能確認你的賬戶。"
+ "Connect to the internet to pair, so Codync can confirm your account.": "請連上網路再配對,Codync 才能確認你的賬戶。",
+ "Installing codync-host…": "正在安裝 codync-host…",
+ "Starting codync-host…": "正在啟動 codync-host…",
+ "Couldn't install codync-host on {name}.": "無法在 {name} 上安裝 codync-host。",
+ "codync-host isn't installed on {name}.": "{name} 上還沒有安裝 codync-host。",
+ "To keep codync-host running on {name} after you log out, run this there:": "要讓 codync-host 在你登出後繼續在 {name} 上執行,請在那裡執行:",
+ "Copy command": "複製命令"
}
diff --git a/host/src/cloud_cli.rs b/host/src/cloud_cli.rs
index e8b0f145..d1f9b537 100644
--- a/host/src/cloud_cli.rs
+++ b/host/src/cloud_cli.rs
@@ -95,7 +95,7 @@ fn account_hint(status: &serde_json::Value) -> Option<&'static str> {
Some(if status["enabled"] != true || status["relay"] == "private" {
"Not in an account. Phones pair with `codync-host pair` and a QR code; joining an account needs the Codync cloud (`codync-host cloud --enable`)."
} else {
- "Not in an account. Add it from a signed-in phone: run `codync-host pair` and scan the code, or type its short code. Or, from a desktop app that reaches this computer over SSH, choose Add to account."
+ "Not in an account. Add it from a signed-in phone: run `codync-host pair` and scan the code, or type the short code it prints. Or, from a desktop app that reaches this computer over SSH, choose Add to account."
})
}
diff --git a/host/src/main.rs b/host/src/main.rs
index 294ec5c8..3a29fe0f 100644
--- a/host/src/main.rs
+++ b/host/src/main.rs
@@ -599,7 +599,7 @@ async fn pair(port: u16, as_json: bool) -> Result<()> {
println!("{}", code.render::<qrcode::render::unicode::Dense1x2>().quiet_zone(true).build());
println!("Scan with the Codync iOS app within 10 minutes, or open this link on the phone:\n{url}\n");
if let Some(code) = p["shortCode"].as_str() {
- println!("Or type this code in the app (Pair a computer → Type a code): {code}\n");
+ println!("Or type this code where the app's pairing screen asks for a link: {code}\n");
}
if hello["cloud"].is_null()
&& p["urls"].as_array().is_none_or(|u| {