Skip to content

Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.

Put the computer's network address in the iPhone QR code, not its .local name (#196)

Eduardo Machado39165e323b09
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ea9cf7..c0900d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@ What changed in each version of Tucano. The format follows [Keep a Changelog](ht
> **Em português:**
> - **Entrar na IA pelo navegador ou pelo iPhone, num Tucano em servidor.** O botão Entrar roda o login da própria IA no servidor e mostra a tela dele numa janela: a página pra abrir, o código pra digitar e um campo pra colar o código de volta. Sem SSH.
>
-> **Correções:** um agente com o GitHub em **Ler e escrever** volta a subir a branch e abrir a PR em vez de dizer que "a sessão é só leitura" (e, se algo pede aprovação ou está desligado, diz exatamente o quê); e o cartão **Computador** mostra o que vale pra cada escolha, sem misturar a confirmação de **Este computador** com o painel do Linux.
+> **Correções:** um agente com o GitHub em **Ler e escrever** volta a subir a branch e abrir a PR em vez de dizer que "a sessão é só leitura" (e, se algo pede aprovação ou está desligado, diz exatamente o quê); e o cartão **Computador** mostra o que vale pra cada escolha, sem misturar a confirmação de **Este computador** com o painel do Linux; e o QR code de Configurações › Celular › Seu iPhone traz o endereço do computador na rede de casa, que o iPhone alcança (antes, o nome .local fazia a conexão falhar).
### Added
@@ -15,6 +15,7 @@ What changed in each version of Tucano. The format follows [Keep a Changelog](ht
### Fixed
+- **The iPhone connects to the computer's Tucano on a real home network.** The QR code in Settings › Phone › Your iPhone named the Mac by its Bonjour name (`name.local`), which the iPhone app couldn't reach on a real Wi-Fi: it waited and gave up with "Couldn't reach your Tucano", while the same QR code with the address connected. It now carries the computer's address on the home network, read each time a QR code is made, as on Windows and Linux.
- **An agent with GitHub on "Ler e escrever" pushes and opens the PR instead of saying the session is read-only.** On Codex, the CLI's own text about its sandbox ("`sandbox_mode` is `read-only`... Network access is restricted", "Approval policy is never") reached the model, and it answered "Estou bloqueado porque esta sessão permite apenas leitura" for a push or a PR it had every grant for. That text is left out now (in `codex exec` and the app-server), and the note an agent with the app's tools gets says Codex's sandbox doesn't limit them, that git and other commands on its computer run with `bash`, and to say exactly what was refused or waits for approval, never "read-only". On every harness, an agent with a GitHub connector gets a **GitHub** section in its instructions, made from what it really has: the tools it publishes with (`create_branch`, `push_files`, `create_or_update_file`, `create_pull_request`, by the names it sees); on **Este computador**, that `git push` also runs with your own git credentials; on **Linux isolado**, that there are none there; what your autonomy level or rules make ask first or turn off; and, with read-only access, to ask for read and write with `pedir_acesso`. Before, an agent on this computer was told only "git push only when asked", with no word about the connector.
- **The agent page's Computador card shows what each choice means, from the first look.** Clicking **Este computador** after **Linux isolado** showed the confirmation on top of the Linux panel (the Docker state, **Pastas do seu computador**, **Apagar computador**), with Linux still picked and already saved, and that mix read as this computer's full card, while the real one looked cut short. Now the confirmation shows alone, with **Este computador** picked, and **Cancelar** (or clicking the saved choice) goes back to it; once allowed, the card says the commands run on your computer as you, starting in its folder, and that it reaches your folders without lending them and needs no Docker.
diff --git a/src/main/home-link.ts b/src/main/home-link.ts
index a132fd0..f023bb3 100644
--- a/src/main/home-link.ts
+++ b/src/main/home-link.ts
@@ -123,6 +123,11 @@ export class HomeLink {
if (server) await new Promise<void>((done) => server.close(() => done()).closeAllConnections())
}
+ // Where the phone reaches this computer, for the next QR code (the address can change while the app runs).
+ setHost(host: string): void {
+ if (this.server) this.origin = `https://${host.includes(':') ? `[${host}]` : host}:${this.port}`
+ }
+
// A one-time code for the owner's phone, as the link the QR code holds.
makeCode(): { link: string; expiresAt: number } {
const { code, expiresAt } = this.codes.make(null)
diff --git a/src/main/home-phone-net.ts b/src/main/home-phone-net.ts
index acd48cc..45227b3 100644
--- a/src/main/home-phone-net.ts
+++ b/src/main/home-phone-net.ts
@@ -3,16 +3,21 @@
import { execFileSync } from 'node:child_process'
import { hostname, networkInterfaces } from 'node:os'
-// How the phone finds this computer on the Wi-Fi: its Bonjour name (eduardos-macbook.local), which
-// stays when the router hands out another address; elsewhere, its address on the home network.
-export function homeHost(): string {
+// How the phone finds this computer on the Wi-Fi: its address on the home network (192.168.0.12).
+// Not the Mac's Bonjour name (eduardos-macbook.local): the iPhone app couldn't reach it by that name
+// on a real network, while the address worked. The QR code is made
+// when it's shown, so a new address from the router means only a new QR code.
+// No home network address (a cable-less, Wi-Fi-less machine): the Bonjour name, then the hostname.
+export function homeHost(nets: Parameters<typeof lanAddress>[0] = networkInterfaces()): string {
+ const lan = lanAddress(nets)
+ if (lan) return lan
if (process.platform === 'darwin') {
try {
const name = execFileSync('/usr/sbin/scutil', ['--get', 'LocalHostName'], { encoding: 'utf8', timeout: 2000 }).trim()
if (/^[A-Za-z0-9-]{1,63}$/.test(name)) return `${name}.local`.toLowerCase()
} catch {}
}
- return lanAddress(networkInterfaces()) ?? hostname()
+ return hostname()
}
// The address of the Wi-Fi or the cable, not of a virtual network the computer also has (Docker,
diff --git a/src/main/home-phone.ts b/src/main/home-phone.ts
index 69a2686..a813d8d 100644
--- a/src/main/home-phone.ts
+++ b/src/main/home-phone.ts
@@ -125,6 +125,7 @@ export function homePhone(deps: {
async code(): Promise<{ link: string; expiresAt: number }> {
if (!link?.running) await this.set(true)
if (!link?.running) throw new Error(error ?? 'not running')
+ link.setHost(homeHost())
return link.makeCode()
},
// The core's answers to the questions above; true when the message was one.
diff --git a/test/home-link.test.ts b/test/home-link.test.ts
index b2d56c5..76d1ef6 100644
--- a/test/home-link.test.ts
+++ b/test/home-link.test.ts
@@ -242,3 +242,24 @@ describe('lanAddress', () => {
expect(lanAddress({ eth0: [{ family: 'IPv4', address: '8.8.8.8', internal: false }] })).toBeUndefined()
})
})
+
+describe('homeHost', () => {
+ it('puts the home network address in the QR code, not the .local name', async () => {
+ const { homeHost } = await import('../src/main/home-phone-net')
+ expect(homeHost({ en0: [{ family: 'IPv4', address: '192.168.3.112', internal: false }], utun4: [{ family: 'IPv4', address: '100.101.1.2', internal: false }] })).toBe('192.168.3.112')
+ })
+
+ it('makes each QR code with the address it has now', async () => {
+ const dir = mkdtempSync(join(tmpdir(), 'home-host-'))
+ const link = new HomeLink({ tls: makeCertificate('Tucano', []), codesFile: join(dir, 'codes.json'), core: () => undefined })
+ try {
+ const port = await link.start(47390, '192.168.0.10')
+ expect(new URL(link.makeCode().link).searchParams.get('url')).toBe(`https://192.168.0.10:${port}`)
+ link.setHost('192.168.0.77')
+ expect(new URL(link.makeCode().link).searchParams.get('url')).toBe(`https://192.168.0.77:${port}`)
+ } finally {
+ await link.stop()
+ rmSync(dir, { recursive: true, force: true })
+ }
+ })
+})