Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e0490b6b1 | ||
|
|
80475e854c | ||
|
|
aeaf31ff6d | ||
|
|
8b9cf23ec7 | ||
|
|
68ff6d8578 | ||
|
|
8f5078c6d5 | ||
|
|
f1793ad2eb | ||
|
|
805c68dd0e | ||
|
|
e835adeb16 |
No files matched your search
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "T3 Code Dev",
|
||||
"image": "debian:bookworm",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers-extra/features/bun:1": {},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "24",
|
||||
"nodeGypDependencies": true
|
||||
},
|
||||
"ghcr.io/devcontainers/features/python:1": {
|
||||
"version": "3.12"
|
||||
}
|
||||
},
|
||||
"postCreateCommand": {
|
||||
"bun-install": "bun install --backend=copyfile --frozen-lockfile"
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": ["oxc.oxc-vscode"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,302 +0,0 @@
|
||||
# Remote Architecture
|
||||
|
||||
This document describes the target architecture for first-class remote environments in T3 Code.
|
||||
|
||||
It is intentionally architecture-first. It does not define a complete implementation plan or user-facing rollout checklist. The goal is to establish the core model so remote support can be added without another broad rewrite.
|
||||
|
||||
## Goals
|
||||
|
||||
- Treat remote environments as first-class product primitives, not special cases.
|
||||
- Support multiple ways to reach the same environment.
|
||||
- Keep the T3 server as the execution boundary.
|
||||
- Let desktop, mobile, and web all share the same conceptual model.
|
||||
- Avoid introducing a local control plane unless product pressure proves it is necessary.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Replacing the existing WebSocket server boundary with a custom transport protocol.
|
||||
- Making SSH the only remote story.
|
||||
- Syncing provider auth across machines.
|
||||
- Shipping every access method in the first iteration.
|
||||
|
||||
## High-level architecture
|
||||
|
||||
T3 already has a clean runtime boundary: the client talks to a T3 server over HTTP/WebSocket, and the server owns orchestration, providers, terminals, git, and filesystem operations.
|
||||
|
||||
Remote support should preserve that boundary.
|
||||
|
||||
```text
|
||||
┌──────────────────────────────────────────────┐
|
||||
│ Client (desktop / mobile / web) │
|
||||
│ │
|
||||
│ - known environments │
|
||||
│ - connection manager │
|
||||
│ - environment-aware routing │
|
||||
└───────────────┬──────────────────────────────┘
|
||||
│
|
||||
│ resolves one access endpoint
|
||||
│
|
||||
┌───────────────▼──────────────────────────────┐
|
||||
│ Access method │
|
||||
│ │
|
||||
│ - direct ws / wss │
|
||||
│ - tunneled ws / wss │
|
||||
│ - desktop-managed ssh bootstrap + forward │
|
||||
└───────────────┬──────────────────────────────┘
|
||||
│
|
||||
│ connects to one T3 server
|
||||
│
|
||||
┌───────────────▼──────────────────────────────┐
|
||||
│ Execution environment = one T3 server │
|
||||
│ │
|
||||
│ - environment identity │
|
||||
│ - provider state │
|
||||
│ - projects / threads / terminals │
|
||||
│ - git / filesystem / process runtime │
|
||||
└──────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
The important decision is that remoteness is expressed at the environment connection layer, not by splitting the T3 runtime itself.
|
||||
|
||||
## Domain model
|
||||
|
||||
### ExecutionEnvironment
|
||||
|
||||
An `ExecutionEnvironment` is one running T3 server instance.
|
||||
|
||||
It is the unit that owns:
|
||||
|
||||
- provider availability and auth state
|
||||
- model availability
|
||||
- projects and threads
|
||||
- terminal processes
|
||||
- filesystem access
|
||||
- git operations
|
||||
- server settings
|
||||
|
||||
It is identified by a stable `environmentId`.
|
||||
|
||||
This is the shared cross-client primitive. Desktop, mobile, and web should all reason about the same concept here.
|
||||
|
||||
### KnownEnvironment
|
||||
|
||||
A `KnownEnvironment` is a client-side saved entry for an environment the client knows how to reach.
|
||||
|
||||
It is not server-authored. It is local to a device or client profile.
|
||||
|
||||
Examples:
|
||||
|
||||
- a saved LAN URL
|
||||
- a saved public `wss://` endpoint
|
||||
- a desktop-managed SSH host entry
|
||||
- a saved tunneled environment
|
||||
|
||||
A known environment may or may not know the target `environmentId` before first successful connect.
|
||||
|
||||
### AccessEndpoint
|
||||
|
||||
An `AccessEndpoint` is one concrete way to reach a known environment.
|
||||
|
||||
This is the key abstraction that keeps SSH from taking over the model.
|
||||
|
||||
A single environment may have many endpoints:
|
||||
|
||||
- `wss://t3.example.com`
|
||||
- `ws://10.0.0.25:3773`
|
||||
- a tunneled relay URL
|
||||
- a desktop-managed SSH tunnel that resolves to a local forwarded WebSocket URL
|
||||
|
||||
The environment stays the same. Only the access path changes.
|
||||
|
||||
### RepositoryIdentity
|
||||
|
||||
`RepositoryIdentity` remains a best-effort logical repo grouping mechanism across environments.
|
||||
|
||||
It is not used for routing. It is only used for UI grouping and correlation between local and remote clones of the same repository.
|
||||
|
||||
### Workspace / Project
|
||||
|
||||
The current `Project` model remains environment-local.
|
||||
|
||||
That means:
|
||||
|
||||
- a local clone and a remote clone are different projects
|
||||
- they may share a `RepositoryIdentity`
|
||||
- threads still bind to one project in one environment
|
||||
|
||||
## Access methods
|
||||
|
||||
Access methods answer one question:
|
||||
|
||||
How does the client speak WebSocket to a T3 server?
|
||||
|
||||
They do not answer:
|
||||
|
||||
- how the server got started
|
||||
- who manages the server process
|
||||
- whether the environment is local or remote
|
||||
|
||||
### 1. Direct WebSocket access
|
||||
|
||||
Examples:
|
||||
|
||||
- `ws://10.0.0.15:3773`
|
||||
- `wss://t3.example.com`
|
||||
|
||||
This is the base model and should be the first-class default.
|
||||
|
||||
Benefits:
|
||||
|
||||
- works for desktop, mobile, and web
|
||||
- no client-specific process management required
|
||||
- best fit for hosted or self-managed remote T3 deployments
|
||||
|
||||
### 2. Tunneled WebSocket access
|
||||
|
||||
Examples:
|
||||
|
||||
- public relay URLs
|
||||
- private network relay URLs
|
||||
- local tunnel products such as pipenet
|
||||
|
||||
This is still direct WebSocket access from the client's perspective. The difference is that the route is mediated by a tunnel or relay.
|
||||
|
||||
For T3, tunnels are best modeled as another `AccessEndpoint`, not as a different kind of environment.
|
||||
|
||||
This is especially useful when:
|
||||
|
||||
- the host is behind NAT
|
||||
- inbound ports are unavailable
|
||||
- mobile must reach a desktop-hosted environment
|
||||
- a machine should be reachable without exposing raw LAN or public ports
|
||||
|
||||
### 3. Desktop-managed SSH access
|
||||
|
||||
SSH is an access and launch helper, not a separate environment type.
|
||||
|
||||
The desktop main process can use SSH to:
|
||||
|
||||
- reach a machine
|
||||
- probe it
|
||||
- launch or reuse a remote T3 server
|
||||
- establish a local port forward
|
||||
|
||||
After that, the renderer should still connect using an ordinary WebSocket URL against the forwarded local port.
|
||||
|
||||
This keeps the renderer transport model consistent with every other access method.
|
||||
|
||||
## Launch methods
|
||||
|
||||
Launch methods answer a different question:
|
||||
|
||||
How does a T3 server come to exist on the target machine?
|
||||
|
||||
Launch and access should stay separate in the design.
|
||||
|
||||
### 1. Pre-existing server
|
||||
|
||||
The simplest launch method is no launch at all.
|
||||
|
||||
The user or operator already runs T3 on the target machine, and the client connects through a direct or tunneled WebSocket endpoint.
|
||||
|
||||
This should be the first remote mode shipped because it validates the environment model with minimal extra machinery.
|
||||
|
||||
### 2. Desktop-managed remote launch over SSH
|
||||
|
||||
This is the main place where Zed is a useful reference.
|
||||
|
||||
Useful ideas to borrow from Zed:
|
||||
|
||||
- remote probing
|
||||
- platform detection
|
||||
- session directories with pid/log metadata
|
||||
- reconnect-friendly launcher behavior
|
||||
- desktop-owned connection UX
|
||||
|
||||
What should be different in T3:
|
||||
|
||||
- no custom stdio/socket proxy protocol between renderer and remote runtime
|
||||
- no attempt to make the remote runtime look like an editor transport
|
||||
- keep the final client-to-server connection as WebSocket
|
||||
|
||||
The recommended T3 flow is:
|
||||
|
||||
1. Desktop connects over SSH.
|
||||
2. Desktop probes the remote machine and verifies T3 availability.
|
||||
3. Desktop launches or reuses a remote T3 server.
|
||||
4. Desktop establishes local port forwarding.
|
||||
5. Renderer connects to the forwarded WebSocket endpoint as a normal environment.
|
||||
|
||||
### 3. Client-managed local publish
|
||||
|
||||
This is the inverse of remote launch: a local T3 server is already running, and the client publishes it through a tunnel.
|
||||
|
||||
This is useful for:
|
||||
|
||||
- exposing a desktop-hosted environment to mobile
|
||||
- temporary remote access without changing router or firewall settings
|
||||
|
||||
This is still a launch concern, not a new environment kind.
|
||||
|
||||
## Why access and launch must stay separate
|
||||
|
||||
These concerns are easy to conflate, but separating them prevents architectural drift.
|
||||
|
||||
Examples:
|
||||
|
||||
- A manually hosted T3 server might be reached through direct `wss`.
|
||||
- The same server might also be reachable through a tunnel.
|
||||
- An SSH-managed server might be launched over SSH but then reached through forwarded WebSocket.
|
||||
- A local desktop server might be published through a tunnel for mobile.
|
||||
|
||||
In all of those cases, the `ExecutionEnvironment` is the same kind of thing.
|
||||
|
||||
Only the launch and access paths differ.
|
||||
|
||||
## Security model
|
||||
|
||||
Remote support must assume that some environments will be reachable over untrusted networks.
|
||||
|
||||
That means:
|
||||
|
||||
- remote-capable environments should require explicit authentication
|
||||
- tunnel exposure should not rely on obscurity
|
||||
- client-saved endpoints should carry enough auth metadata to reconnect safely
|
||||
|
||||
T3 already supports a WebSocket auth token on the server. That should become a first-class part of environment access rather than remaining an incidental query parameter convention.
|
||||
|
||||
For publicly reachable environments, authenticated access should be treated as required.
|
||||
|
||||
## Relationship to Zed
|
||||
|
||||
Zed is a useful reference implementation for managed remote launch and reconnect behavior.
|
||||
|
||||
The relevant lessons are:
|
||||
|
||||
- remote bootstrap should be explicit
|
||||
- reconnect should be first-class
|
||||
- connection UX belongs in the client shell
|
||||
- runtime ownership should stay clearly on the remote host
|
||||
|
||||
The important mismatch is transport shape.
|
||||
|
||||
Zed needs a custom proxy/server protocol because its remote boundary sits below the editor and project runtime.
|
||||
|
||||
T3 should not copy that part.
|
||||
|
||||
T3 already has the right runtime boundary:
|
||||
|
||||
- one T3 server per environment
|
||||
- ordinary HTTP/WebSocket between client and environment
|
||||
|
||||
So T3 should borrow Zed's launch discipline, not its transport protocol.
|
||||
|
||||
## Recommended rollout
|
||||
|
||||
1. First-class known environments and access endpoints.
|
||||
2. Direct `ws` / `wss` remote environments.
|
||||
3. Authenticated tunnel-backed environments.
|
||||
4. Desktop-managed SSH launch and forwarding.
|
||||
5. Multi-environment UI improvements after the base runtime path is proven.
|
||||
|
||||
This ordering keeps the architecture network-first and transport-agnostic while still leaving room for richer managed remote flows.
|
||||
@@ -10,7 +10,6 @@ jobs:
|
||||
quality:
|
||||
name: Format, Lint, Typecheck, Test, Browser Test, Build
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
@@ -72,12 +71,11 @@ jobs:
|
||||
- name: Verify preload bundle output
|
||||
run: |
|
||||
test -f apps/desktop/dist-electron/preload.js
|
||||
grep -nE "desktopBridge|getLocalEnvironmentBootstrap|PICK_FOLDER_CHANNEL|wsUrl" apps/desktop/dist-electron/preload.js
|
||||
grep -nE "desktopBridge|getWsUrl|PICK_FOLDER_CHANNEL|wsUrl" apps/desktop/dist-electron/preload.js
|
||||
|
||||
release_smoke:
|
||||
name: Release Smoke
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
@@ -19,7 +19,6 @@ jobs:
|
||||
preflight:
|
||||
name: Preflight
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
version: ${{ steps.release_meta.outputs.version }}
|
||||
tag: ${{ steps.release_meta.outputs.tag }}
|
||||
@@ -82,7 +81,6 @@ jobs:
|
||||
name: Build ${{ matrix.label }}
|
||||
needs: preflight
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -128,7 +126,7 @@ jobs:
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Align package versions to release version
|
||||
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
run: bun scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
|
||||
- name: Build desktop artifact
|
||||
shell: bash
|
||||
@@ -229,7 +227,6 @@ jobs:
|
||||
name: Publish CLI to npm
|
||||
needs: [preflight, build]
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
@@ -251,7 +248,7 @@ jobs:
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Align package versions to release version
|
||||
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
run: bun scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
|
||||
- name: Build CLI package
|
||||
run: bun run build --filter=@t3tools/web --filter=t3
|
||||
@@ -263,7 +260,6 @@ jobs:
|
||||
name: Publish GitHub Release
|
||||
needs: [preflight, build, publish_cli]
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
@@ -311,7 +307,6 @@ jobs:
|
||||
name: Finalize release
|
||||
needs: [preflight, release]
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- id: app_token
|
||||
name: Mint release app token
|
||||
@@ -353,7 +348,7 @@ jobs:
|
||||
name: Update version strings
|
||||
env:
|
||||
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
|
||||
run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
|
||||
run: bun scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
|
||||
|
||||
- name: Format package.json files
|
||||
if: steps.update_versions.outputs.changed == 'true'
|
||||
@@ -369,7 +364,7 @@ jobs:
|
||||
env:
|
||||
RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
|
||||
run: |
|
||||
if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock; then
|
||||
if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json apps/marketing/public/schemas bun.lock; then
|
||||
echo "No version changes to commit."
|
||||
exit 0
|
||||
fi
|
||||
@@ -377,6 +372,6 @@ jobs:
|
||||
git config user.name "${{ steps.app_bot.outputs.name }}"
|
||||
git config user.email "${{ steps.app_bot.outputs.email }}"
|
||||
|
||||
git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
|
||||
git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json apps/marketing/public/schemas bun.lock
|
||||
git commit -m "chore(release): prepare $RELEASE_TAG"
|
||||
git push origin HEAD:main
|
||||
@@ -21,4 +21,3 @@ apps/web/src/components/__screenshots__
|
||||
.vitest-*
|
||||
__screenshots__/
|
||||
.tanstack
|
||||
squashfs-root/
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"ignorePatterns": [
|
||||
".reference",
|
||||
".plans",
|
||||
"dist",
|
||||
"dist-electron",
|
||||
@@ -9,9 +8,7 @@
|
||||
"bun.lock",
|
||||
"*.tsbuildinfo",
|
||||
"**/routeTree.gen.ts",
|
||||
"apps/web/public/mockServiceWorker.js",
|
||||
"apps/web/src/lib/vendor/qrcodegen.ts",
|
||||
"apps/mobile/uniwind-types.d.ts"
|
||||
"apps/web/public/mockServiceWorker.js"
|
||||
],
|
||||
"sortPackageJson": {}
|
||||
}
|
||||
@@ -6,8 +6,7 @@
|
||||
"node_modules",
|
||||
"bun.lock",
|
||||
"*.tsbuildinfo",
|
||||
"**/routeTree.gen.ts",
|
||||
"apps/mobile/uniwind-types.d.ts"
|
||||
"**/routeTree.gen.ts"
|
||||
],
|
||||
"plugins": ["eslint", "oxc", "react", "unicorn", "typescript"],
|
||||
"categories": {
|
||||
@@ -16,7 +15,6 @@
|
||||
"perf": "warn"
|
||||
},
|
||||
"rules": {
|
||||
"unicorn/no-array-sort": "off",
|
||||
"react-in-jsx-scope": "off",
|
||||
"eslint/no-shadow": "off",
|
||||
"eslint/no-await-in-loop": "off"
|
||||
|
||||
@@ -1,823 +0,0 @@
|
||||
# Server Auth Model Plan
|
||||
|
||||
## Purpose
|
||||
|
||||
Define the long-term server auth architecture for T3 Code before first-class remote environments ship.
|
||||
|
||||
This plan is deliberately broader than the current WebSocket token check and narrower than a complete remote collaboration system. The goal is to make the server secure by default, keep local desktop UX frictionless, and leave clean integration points for future remote access methods.
|
||||
|
||||
This document is written in terms of Effect-native services and layers because auth needs to be a core runtime concern, not route-local glue code.
|
||||
|
||||
## Primary goals
|
||||
|
||||
- Make auth server-wide, not WebSocket-only.
|
||||
- Make insecure exposure hard to do accidentally.
|
||||
- Preserve zero-login local desktop UX for desktop-managed environments.
|
||||
- Support browser-native pairing and session auth.
|
||||
- Leave room for native/mobile credentials later without rewriting the server boundary.
|
||||
- Keep auth separate from transport and launch method.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Full multi-user authorization and RBAC.
|
||||
- OAuth / SSO / enterprise identity.
|
||||
- Passkeys or biometric UX in v1.
|
||||
- Syncing auth state across environments.
|
||||
- Designing the full remote environment product in this document.
|
||||
|
||||
## Core decisions
|
||||
|
||||
### 1. Auth is a server concern
|
||||
|
||||
Every privileged surface of the T3 server must go through the same auth policy engine:
|
||||
|
||||
- HTTP routes
|
||||
- WebSocket upgrades
|
||||
- RPC methods reached through WebSocket
|
||||
|
||||
The current split where [`/ws`](../apps/server/src/ws.ts) checks `authToken` but routes in [`http.ts`](../apps/server/src/http.ts) do not is not sufficient for a remote-capable product.
|
||||
|
||||
### 2. Pairing and session are different things
|
||||
|
||||
The system should distinguish:
|
||||
|
||||
- bootstrap credentials
|
||||
- session credentials
|
||||
|
||||
Bootstrap credentials are short-lived and high-trust. They allow a client to become authenticated.
|
||||
|
||||
Session credentials are the durable credentials used after pairing.
|
||||
|
||||
Bootstrap should never become the long-lived request credential.
|
||||
|
||||
### 3. Auth and transport are separate
|
||||
|
||||
Auth must not be defined by how the client reached the server.
|
||||
|
||||
Examples:
|
||||
|
||||
- local desktop-managed server
|
||||
- LAN `ws://`
|
||||
- public `wss://`
|
||||
- tunneled `wss://`
|
||||
- SSH-forwarded `ws://127.0.0.1:<port>`
|
||||
|
||||
All of these should feed into the same auth model.
|
||||
|
||||
### 4. Exposure level changes defaults
|
||||
|
||||
The more exposed an environment is, the narrower the safe default should be.
|
||||
|
||||
Safe default expectations:
|
||||
|
||||
- local desktop-managed: auto-pair allowed
|
||||
- loopback browser access: explicit bootstrap allowed
|
||||
- non-loopback bind: auth required
|
||||
- tunnel/public endpoint: auth required, explicit enablement required
|
||||
|
||||
### 5. Browser and native clients may use different session credentials
|
||||
|
||||
The auth model should support more than one session credential type even if only one ships first.
|
||||
|
||||
Examples:
|
||||
|
||||
- browser session cookie
|
||||
- native bearer/device token
|
||||
|
||||
This should be represented in the model now, even if browser cookies are the first implementation.
|
||||
|
||||
## Target auth domain
|
||||
|
||||
### Route classes
|
||||
|
||||
Every route or transport entrypoint should be classified as one of:
|
||||
|
||||
1. `public`
|
||||
2. `bootstrap`
|
||||
3. `authenticated`
|
||||
|
||||
#### `public`
|
||||
|
||||
Unauthenticated by definition.
|
||||
|
||||
Should be extremely small. Examples:
|
||||
|
||||
- static shell needed to render the pairing/login UI
|
||||
- favicon/assets required for the pairing screen
|
||||
- a minimal server health/version endpoint if needed
|
||||
|
||||
#### `bootstrap`
|
||||
|
||||
Used only to exchange a bootstrap credential for a session.
|
||||
|
||||
Examples:
|
||||
|
||||
- Initial bootstrap envelope over file descriptor at startup
|
||||
- `POST /api/auth/bootstrap`
|
||||
- `GET /api/auth/session` if unauthenticated checks are part of bootstrap UX
|
||||
|
||||
#### `authenticated`
|
||||
|
||||
Everything that reveals machine state or mutates it.
|
||||
|
||||
Examples:
|
||||
|
||||
- WebSocket upgrade
|
||||
- orchestration snapshot and events
|
||||
- terminal open/write/close
|
||||
- project search and file writes
|
||||
- git routes
|
||||
- attachments
|
||||
- project favicon lookup
|
||||
- server settings
|
||||
|
||||
The default stance should be: if it touches the machine, it is authenticated.
|
||||
|
||||
## Credential model
|
||||
|
||||
### Bootstrap credentials
|
||||
|
||||
Initial credential types to model:
|
||||
|
||||
- `desktop-bootstrap`
|
||||
- `one-time-token`
|
||||
|
||||
Possible future credential types:
|
||||
|
||||
- `device-code`
|
||||
- `passkey-assertion`
|
||||
- `external-identity`
|
||||
|
||||
#### `desktop-bootstrap`
|
||||
|
||||
Used when the desktop shell manages the server and should be the only default pairing method for desktop-local environments.
|
||||
|
||||
Properties:
|
||||
|
||||
- launcher-provided
|
||||
- short-lived
|
||||
- one-time or bounded-use
|
||||
- never shown to the user as a reusable password
|
||||
|
||||
#### `one-time-token`
|
||||
|
||||
Used for explicit browser/mobile pairing flows.
|
||||
|
||||
Properties:
|
||||
|
||||
- short TTL
|
||||
- one-time use
|
||||
- safe to embed in a pairing URL fragment
|
||||
- exchanged for a session credential
|
||||
|
||||
### Session credentials
|
||||
|
||||
Initial credential types to model:
|
||||
|
||||
- `browser-session-cookie`
|
||||
- `bearer-session-token`
|
||||
|
||||
#### `browser-session-cookie`
|
||||
|
||||
Primary browser credential.
|
||||
|
||||
Properties:
|
||||
|
||||
- signed
|
||||
- `HttpOnly`
|
||||
- bounded lifetime
|
||||
- revocable by server key rotation or session invalidation
|
||||
|
||||
#### `bearer-session-token`
|
||||
|
||||
Reserved for native/mobile or non-browser clients.
|
||||
|
||||
Properties:
|
||||
|
||||
- opaque token, not a bootstrap secret
|
||||
- long enough lifetime to survive reconnects
|
||||
- stored in secure client storage when available
|
||||
|
||||
## Auth policy model
|
||||
|
||||
Auth behavior should be driven by an explicit environment auth policy, not route-local heuristics.
|
||||
|
||||
### Policy examples
|
||||
|
||||
#### `DesktopManagedLocalPolicy`
|
||||
|
||||
Default for desktop-managed local server.
|
||||
|
||||
Allowed bootstrap methods:
|
||||
|
||||
- `desktop-bootstrap`
|
||||
|
||||
Allowed session methods:
|
||||
|
||||
- `browser-session-cookie`
|
||||
|
||||
Disabled by default:
|
||||
|
||||
- `one-time-token`
|
||||
- `bearer-session-token`
|
||||
- password login
|
||||
- public pairing
|
||||
|
||||
#### `LoopbackBrowserPolicy`
|
||||
|
||||
Used for browser access on localhost without desktop-managed bootstrap.
|
||||
|
||||
Allowed bootstrap methods:
|
||||
|
||||
- `one-time-token`
|
||||
|
||||
Allowed session methods:
|
||||
|
||||
- `browser-session-cookie`
|
||||
|
||||
#### `RemoteReachablePolicy`
|
||||
|
||||
Used when binding non-loopback or using an explicit remote/tunnel workflow.
|
||||
|
||||
Allowed bootstrap methods:
|
||||
|
||||
- `one-time-token`
|
||||
- possibly `desktop-bootstrap` when a desktop shell is brokering access
|
||||
|
||||
Allowed session methods:
|
||||
|
||||
- `browser-session-cookie`
|
||||
- `bearer-session-token`
|
||||
|
||||
#### `UnsafeNoAuthPolicy`
|
||||
|
||||
Should exist only as an explicit escape hatch.
|
||||
|
||||
Requirements:
|
||||
|
||||
- explicit opt-in flag
|
||||
- loud startup warnings
|
||||
- never defaulted automatically
|
||||
|
||||
## Effect-native service model
|
||||
|
||||
### `ServerAuth`
|
||||
|
||||
The main auth facade used by HTTP routes and WebSocket upgrade handling.
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- classify requests
|
||||
- authenticate requests
|
||||
- authorize bootstrap attempts
|
||||
- create sessions from bootstrap credentials
|
||||
- enforce policy by environment mode
|
||||
|
||||
Sketch:
|
||||
|
||||
```ts
|
||||
export interface ServerAuthShape {
|
||||
readonly getCapabilities: Effect.Effect<AuthCapabilities>;
|
||||
readonly authenticateHttpRequest: (
|
||||
request: HttpServerRequest.HttpServerRequest,
|
||||
routeClass: RouteAuthClass,
|
||||
) => Effect.Effect<AuthContext, AuthError>;
|
||||
readonly authenticateWebSocketUpgrade: (
|
||||
request: HttpServerRequest.HttpServerRequest,
|
||||
) => Effect.Effect<AuthContext, AuthError>;
|
||||
readonly exchangeBootstrapCredential: (
|
||||
input: BootstrapExchangeInput,
|
||||
) => Effect.Effect<SessionGrant, AuthError>;
|
||||
}
|
||||
|
||||
export class ServerAuth extends ServiceMap.Service<ServerAuth, ServerAuthShape>()(
|
||||
"t3/ServerAuth",
|
||||
) {}
|
||||
```
|
||||
|
||||
### `BootstrapCredentialService`
|
||||
|
||||
Owns issuance, storage, validation, and consumption of bootstrap credentials.
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- issue desktop bootstrap grants
|
||||
- issue one-time pairing tokens
|
||||
- validate TTL and single-use semantics
|
||||
- consume bootstrap grants atomically
|
||||
|
||||
Sketch:
|
||||
|
||||
```ts
|
||||
export interface BootstrapCredentialServiceShape {
|
||||
readonly issueDesktopBootstrap: (
|
||||
input: IssueDesktopBootstrapInput,
|
||||
) => Effect.Effect<BootstrapCredential>;
|
||||
readonly issueOneTimeToken: (
|
||||
input: IssueOneTimeTokenInput,
|
||||
) => Effect.Effect<BootstrapCredential>;
|
||||
readonly consume: (
|
||||
presented: PresentedBootstrapCredential,
|
||||
) => Effect.Effect<ConsumedBootstrapCredential, BootstrapCredentialError>;
|
||||
}
|
||||
```
|
||||
|
||||
### `SessionCredentialService`
|
||||
|
||||
Owns creation and validation of authenticated sessions.
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- mint cookie sessions
|
||||
- mint bearer sessions
|
||||
- validate active session credentials
|
||||
- revoke sessions if needed later
|
||||
|
||||
Sketch:
|
||||
|
||||
```ts
|
||||
export interface SessionCredentialServiceShape {
|
||||
readonly createBrowserSession: (
|
||||
input: CreateSessionFromBootstrapInput,
|
||||
) => Effect.Effect<BrowserSessionGrant, SessionCredentialError>;
|
||||
readonly createBearerSession: (
|
||||
input: CreateSessionFromBootstrapInput,
|
||||
) => Effect.Effect<BearerSessionGrant, SessionCredentialError>;
|
||||
readonly authenticateCookie: (
|
||||
request: HttpServerRequest.HttpServerRequest,
|
||||
) => Effect.Effect<AuthContext, SessionCredentialError>;
|
||||
readonly authenticateBearer: (
|
||||
request: HttpServerRequest.HttpServerRequest,
|
||||
) => Effect.Effect<AuthContext, SessionCredentialError>;
|
||||
}
|
||||
```
|
||||
|
||||
### `ServerAuthPolicy`
|
||||
|
||||
Pure policy/config service that decides which credential types are allowed.
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- map runtime mode and bind/exposure settings to allowed auth methods
|
||||
- answer whether a route can be public
|
||||
- answer whether remote exposure requires auth
|
||||
|
||||
This should stay mostly pure and cheap to test.
|
||||
|
||||
### `ServerSecretStore`
|
||||
|
||||
Owns long-lived server signing keys and secrets.
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- get or create signing key
|
||||
- rotate signing key
|
||||
- abstract secure OS-backed storage vs filesystem fallback
|
||||
|
||||
Important:
|
||||
|
||||
- prefer platform secure storage when available
|
||||
- support hardened filesystem fallback for headless/server-only environments
|
||||
|
||||
### `BrowserSessionCookieCodec`
|
||||
|
||||
Focused utility service for cookie encode/decode/signing behavior.
|
||||
|
||||
This should not own policy. It should only own the cookie format.
|
||||
|
||||
### `AuthRouteGuards`
|
||||
|
||||
Thin helper layer used by routes to enforce auth consistently.
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- require auth for HTTP route handlers
|
||||
- classify route auth mode
|
||||
- convert auth failures into `401` / `403`
|
||||
|
||||
This prevents every route from re-implementing the same pattern.
|
||||
|
||||
Integrates with `HttpRouter.middleware` to enforce auth consistently.
|
||||
|
||||
## Suggested layer graph
|
||||
|
||||
```text
|
||||
ServerSecretStore
|
||||
├─> BootstrapCredentialService
|
||||
├─> BrowserSessionCookieCodec
|
||||
└─> SessionCredentialService
|
||||
|
||||
ServerAuthPolicy
|
||||
├─> BootstrapCredentialService
|
||||
├─> SessionCredentialService
|
||||
└─> ServerAuth
|
||||
|
||||
ServerAuth
|
||||
└─> AuthRouteGuards
|
||||
```
|
||||
|
||||
Layer naming should follow existing repo style:
|
||||
|
||||
- `ServerSecretStoreLive`
|
||||
- `BootstrapCredentialServiceLive`
|
||||
- `SessionCredentialServiceLive`
|
||||
- `ServerAuthPolicyLive`
|
||||
- `ServerAuthLive`
|
||||
- `AuthRouteGuardsLive`
|
||||
|
||||
## High-level implementation examples
|
||||
|
||||
### Example: WebSocket upgrade auth
|
||||
|
||||
Current state:
|
||||
|
||||
- `authToken` query param is checked in [`ws.ts`](../apps/server/src/ws.ts)
|
||||
|
||||
Target shape:
|
||||
|
||||
```ts
|
||||
const websocketUpgradeAuth = HttpMiddleware.make((httpApp) =>
|
||||
Effect.gen(function* () {
|
||||
const request = yield* HttpServerRequest.HttpServerRequest;
|
||||
const serverAuth = yield* ServerAuth;
|
||||
yield* serverAuth.authenticateWebSocketUpgrade(request);
|
||||
return yield* httpApp;
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
Then the `/ws` route becomes:
|
||||
|
||||
```ts
|
||||
export const websocketRpcRouteLayer = HttpRouter.add(
|
||||
"GET",
|
||||
"/ws",
|
||||
rpcWebSocketHttpEffect.pipe(
|
||||
websocketUpgradeAuth,
|
||||
Effect.catchTag("AuthError", (error) => toUnauthorizedResponse(error)),
|
||||
),
|
||||
);
|
||||
```
|
||||
|
||||
This keeps the route itself declarative and makes auth compose like normal HTTP middleware.
|
||||
|
||||
### Example: authenticated HTTP route
|
||||
|
||||
For routes like attachments or project favicon:
|
||||
|
||||
```ts
|
||||
const authenticatedRoute = (routeClass: RouteAuthClass) =>
|
||||
HttpMiddleware.make((httpApp) =>
|
||||
Effect.gen(function* () {
|
||||
const request = yield* HttpServerRequest.HttpServerRequest;
|
||||
const serverAuth = yield* ServerAuth;
|
||||
yield* serverAuth.authenticateHttpRequest(request, routeClass);
|
||||
return yield* httpApp;
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```ts
|
||||
export const attachmentsRouteLayer = HttpRouter.add(
|
||||
"GET",
|
||||
`${ATTACHMENTS_ROUTE_PREFIX}/*`,
|
||||
serveAttachment.pipe(
|
||||
authenticatedRoute(RouteAuthClass.Authenticated),
|
||||
Effect.catchTag("AuthError", (error) => toUnauthorizedResponse(error)),
|
||||
),
|
||||
);
|
||||
```
|
||||
|
||||
### Example: desktop bootstrap exchange
|
||||
|
||||
The desktop shell launches the local server and gets a short-lived bootstrap grant through a trusted side channel.
|
||||
|
||||
That grant is then exchanged for a browser cookie session when the renderer loads.
|
||||
|
||||
Sketch:
|
||||
|
||||
```ts
|
||||
const pairDesktopRenderer = Effect.gen(function* () {
|
||||
const bootstrapService = yield* BootstrapCredentialService;
|
||||
const credential = yield* bootstrapService.issueDesktopBootstrap({
|
||||
audience: "desktop-renderer",
|
||||
ttlMs: 30_000,
|
||||
});
|
||||
return credential;
|
||||
});
|
||||
```
|
||||
|
||||
The renderer then calls a bootstrap endpoint and receives a cookie session. The bootstrap credential is consumed and becomes invalid.
|
||||
|
||||
### Example: one-time pairing URL
|
||||
|
||||
For browser-driven pairing:
|
||||
|
||||
```ts
|
||||
const createPairingToken = Effect.gen(function* () {
|
||||
const bootstrapService = yield* BootstrapCredentialService;
|
||||
return yield* bootstrapService.issueOneTimeToken({
|
||||
ttlMs: 5 * 60_000,
|
||||
audience: "browser",
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
The server can emit a pairing URL where the token lives in the URL fragment so it is not automatically sent to the server before the client explicitly exchanges it.
|
||||
|
||||
## Sequence diagrams
|
||||
|
||||
These flows are meant to anchor the auth model in concrete user journeys.
|
||||
|
||||
The important invariant across all of them is:
|
||||
|
||||
- access method is not the auth method
|
||||
- launch method is not the auth method
|
||||
- bootstrap credential is not the session credential
|
||||
|
||||
### Normal desktop user
|
||||
|
||||
This is the default desktop-managed local flow.
|
||||
|
||||
The desktop shell is trusted to bootstrap the local renderer, but the renderer should still exchange that one-time bootstrap grant for a normal browser session cookie.
|
||||
|
||||
```text
|
||||
Participants:
|
||||
DesktopMain = Electron main
|
||||
SecretStore = secure local secret backend
|
||||
T3Server = local backend child process
|
||||
Frontend = desktop renderer
|
||||
|
||||
DesktopMain -> SecretStore : getOrCreate("server-signing-key")
|
||||
SecretStore --> DesktopMain : signing key available
|
||||
|
||||
DesktopMain -> T3Server : spawn server (--bootstrap-fd ...)
|
||||
DesktopMain -> T3Server : send desktop bootstrap envelope
|
||||
note over T3Server : policy = DesktopManagedLocalPolicy
|
||||
note over T3Server : allowed pairing = desktop-bootstrap only
|
||||
|
||||
Frontend -> DesktopMain : request local bootstrap grant
|
||||
DesktopMain --> Frontend : short-lived desktop bootstrap grant
|
||||
|
||||
Frontend -> T3Server : POST /api/auth/bootstrap
|
||||
T3Server -> T3Server : validate desktop bootstrap grant
|
||||
T3Server -> T3Server : create browser session
|
||||
T3Server --> Frontend : Set-Cookie: session=...
|
||||
|
||||
Frontend -> T3Server : GET /ws + authenticated cookie
|
||||
T3Server -> T3Server : validate cookie session
|
||||
T3Server --> Frontend : websocket accepted
|
||||
```
|
||||
|
||||
### `npx t3` user
|
||||
|
||||
This is the standalone local server flow.
|
||||
|
||||
There is no trusted desktop shell here, so pairing should be explicit.
|
||||
|
||||
```text
|
||||
Participants:
|
||||
UserShell = npx t3 launcher
|
||||
T3Server = standalone local server
|
||||
Browser = browser tab
|
||||
|
||||
UserShell -> T3Server : start server
|
||||
T3Server -> T3Server : getOrCreate("server-signing-key")
|
||||
note over T3Server : policy = LoopbackBrowserPolicy
|
||||
|
||||
UserShell -> T3Server : issue one-time pairing token
|
||||
T3Server --> UserShell : pairing URL or pairing token
|
||||
|
||||
UserShell --> Browser : open /pair?token=...
|
||||
|
||||
Browser -> T3Server : GET /pair?token=...
|
||||
T3Server -> T3Server : validate one-time token
|
||||
T3Server -> T3Server : create browser session
|
||||
T3Server --> Browser : Set-Cookie: session=...
|
||||
T3Server --> Browser : redirect to app
|
||||
|
||||
Browser -> T3Server : GET /ws + authenticated cookie
|
||||
T3Server --> Browser : websocket accepted
|
||||
```
|
||||
|
||||
### Phone user with tunneled host
|
||||
|
||||
This is the explicit remote access flow for a browser on another device.
|
||||
|
||||
The tunnel only provides reachability. It must not imply trust.
|
||||
|
||||
Recommended UX:
|
||||
|
||||
- desktop shows a QR code
|
||||
- desktop also shows a copyable pairing URL
|
||||
- if the phone opens the host URL without a valid token, the server should render a login or pairing screen rather than granting access
|
||||
|
||||
```text
|
||||
Participants:
|
||||
DesktopUser = user at the host machine
|
||||
DesktopMain = desktop app
|
||||
Tunnel = tunnel provider
|
||||
T3Server = T3 server
|
||||
PhoneBrowser = mobile browser
|
||||
|
||||
DesktopUser -> DesktopMain : enable remote access via tunnel
|
||||
DesktopMain -> T3Server : switch policy to RemoteReachablePolicy
|
||||
DesktopMain -> Tunnel : publish local T3 endpoint
|
||||
Tunnel --> DesktopMain : public https/wss URL
|
||||
|
||||
DesktopMain -> T3Server : issue one-time pairing token
|
||||
T3Server --> DesktopMain : pairing token
|
||||
DesktopMain -> DesktopUser : show QR code / shareable URL
|
||||
|
||||
DesktopUser -> PhoneBrowser : scan QR / open URL
|
||||
PhoneBrowser -> Tunnel : GET https://public-host/pair?token=...
|
||||
Tunnel -> T3Server : forward request
|
||||
T3Server -> T3Server : validate one-time token
|
||||
T3Server -> T3Server : create mobile browser session
|
||||
T3Server --> PhoneBrowser : Set-Cookie: session=...
|
||||
T3Server --> PhoneBrowser : redirect to app
|
||||
|
||||
PhoneBrowser -> Tunnel : GET /ws + authenticated cookie
|
||||
Tunnel -> T3Server : forward websocket upgrade
|
||||
T3Server --> PhoneBrowser : websocket accepted
|
||||
```
|
||||
|
||||
### Phone user with private network
|
||||
|
||||
This is operationally similar to the tunnel flow, but the access endpoint is on a private network such as Tailscale.
|
||||
|
||||
The auth flow should stay the same.
|
||||
|
||||
```text
|
||||
Participants:
|
||||
DesktopUser = user at the host machine
|
||||
T3Server = T3 server
|
||||
PrivateNet = tailscale / private LAN
|
||||
PhoneBrowser = mobile browser
|
||||
|
||||
DesktopUser -> T3Server : enable private-network access
|
||||
T3Server -> T3Server : switch policy to RemoteReachablePolicy
|
||||
DesktopUser -> T3Server : issue one-time pairing token
|
||||
T3Server --> DesktopUser : pairing URL / QR
|
||||
|
||||
DesktopUser -> PhoneBrowser : open private-network URL
|
||||
PhoneBrowser -> PrivateNet : GET http(s)://private-host/pair?token=...
|
||||
PrivateNet -> T3Server : route request
|
||||
T3Server -> T3Server : validate one-time token
|
||||
T3Server -> T3Server : create mobile browser session
|
||||
T3Server --> PhoneBrowser : Set-Cookie: session=...
|
||||
T3Server --> PhoneBrowser : redirect to app
|
||||
|
||||
PhoneBrowser -> PrivateNet : GET /ws + authenticated cookie
|
||||
PrivateNet -> T3Server : websocket upgrade
|
||||
T3Server --> PhoneBrowser : websocket accepted
|
||||
```
|
||||
|
||||
### Desktop user adding new SSH hosts
|
||||
|
||||
SSH should be treated as launch and reachability plumbing, not as the long-term auth model.
|
||||
|
||||
The desktop app uses SSH to start or reach the remote server, then the renderer pairs against that server using the same bootstrap/session split as every other environment.
|
||||
|
||||
```text
|
||||
Participants:
|
||||
DesktopUser = local desktop user
|
||||
DesktopMain = desktop app
|
||||
SSH = ssh transport/session
|
||||
RemoteHost = remote machine
|
||||
RemoteT3 = remote T3 server
|
||||
Frontend = desktop renderer
|
||||
|
||||
DesktopUser -> DesktopMain : add SSH host
|
||||
DesktopMain -> SSH : connect to remote host
|
||||
SSH -> RemoteHost : probe environment / verify t3 availability
|
||||
DesktopMain -> SSH : run remote launch command
|
||||
SSH -> RemoteHost : t3 remote launch --json
|
||||
RemoteHost -> RemoteT3 : start or reuse server
|
||||
RemoteT3 --> RemoteHost : port + environment metadata
|
||||
RemoteHost --> SSH : launch result JSON
|
||||
SSH --> DesktopMain : remote server details
|
||||
|
||||
DesktopMain -> SSH : establish local port forward
|
||||
SSH --> DesktopMain : localhost:FORWARDED_PORT ready
|
||||
|
||||
note over RemoteT3 : policy = RemoteReachablePolicy
|
||||
note over DesktopMain,RemoteT3 : desktop may use a trusted bootstrap flow here
|
||||
|
||||
Frontend -> DesktopMain : request bootstrap for selected environment
|
||||
DesktopMain --> Frontend : short-lived bootstrap grant
|
||||
|
||||
Frontend -> RemoteT3 : POST /api/auth/bootstrap via forwarded port
|
||||
RemoteT3 -> RemoteT3 : validate bootstrap grant
|
||||
RemoteT3 -> RemoteT3 : create browser session
|
||||
RemoteT3 --> Frontend : Set-Cookie: session=...
|
||||
|
||||
Frontend -> RemoteT3 : GET /ws + authenticated cookie
|
||||
RemoteT3 --> Frontend : websocket accepted
|
||||
```
|
||||
|
||||
## Storage decisions
|
||||
|
||||
### Server secrets
|
||||
|
||||
Use a `ServerSecretStore` abstraction.
|
||||
|
||||
Preferred order (use a layer for each, resolve on startup):
|
||||
|
||||
1. OS secure storage if available
|
||||
2. hardened filesystem fallback if not
|
||||
|
||||
The filesystem fallback should store only opaque signing material with strict file permissions. It should not store user passwords or reusable third-party credentials.
|
||||
|
||||
### Client credentials
|
||||
|
||||
Client-side credential persistence should prefer secure storage when available:
|
||||
|
||||
- desktop: OS keychain / secure store
|
||||
- mobile: platform secure storage
|
||||
- browser: cookie session for browser auth
|
||||
|
||||
This concern should stay in the client shell/runtime layer, not the server auth layer.
|
||||
|
||||
## What to build now
|
||||
|
||||
These are the parts worth building before remote environments ship:
|
||||
|
||||
1. `ServerAuth` service boundary.
|
||||
2. route classification and route guards.
|
||||
3. `ServerSecretStore` abstraction.
|
||||
4. bootstrap vs session credential split.
|
||||
5. browser session cookie codec as one session method.
|
||||
6. explicit auth capabilities/config surfaced in contracts.
|
||||
|
||||
Even if only one pairing flow is used initially, these seams will keep future remote and mobile work contained.
|
||||
|
||||
## What to add as part of first remote-capable auth
|
||||
|
||||
1. Browser pairing flow using one-time bootstrap token and cookie session.
|
||||
2. Desktop-managed auto-bootstrap for the local desktop-managed environment.
|
||||
3. Auth-required defaults for any non-loopback or explicitly published server.
|
||||
4. Explicit environment auth policy selection instead of scattered `if (host !== localhost)` checks.
|
||||
|
||||
## What to defer
|
||||
|
||||
- passkeys / WebAuthn
|
||||
- iCloud Keychain / Face ID-specific UX
|
||||
- multi-user permissions
|
||||
- collaboration roles
|
||||
- OAuth / SSO
|
||||
- polished session management UI
|
||||
- complex device approval flows
|
||||
|
||||
These can all sit on top of the same bootstrap/session/service split.
|
||||
|
||||
## Relationship to future remote environments
|
||||
|
||||
Remote access is one reason this auth model matters, but the auth model should not be remote-shaped.
|
||||
|
||||
Keep the design focused on:
|
||||
|
||||
- one T3 server
|
||||
- one auth policy
|
||||
- multiple credential types
|
||||
- multiple future access methods
|
||||
|
||||
That keeps the server auth model stable even as access methods expand later.
|
||||
|
||||
## Recommended implementation order
|
||||
|
||||
### Phase 1
|
||||
|
||||
- Introduce route auth classes.
|
||||
- Add `ServerAuth` and `AuthRouteGuards`.
|
||||
- Move existing `authToken` check behind `ServerAuth`.
|
||||
- Require auth for all privileged HTTP routes as well as WebSocket.
|
||||
|
||||
### Phase 2
|
||||
|
||||
- Add `ServerSecretStore` service with platform-specific layer implementations.
|
||||
- `layerOSXKeychain`, `layer
|
||||
- Add bootstrap/session split.
|
||||
- Add browser session cookie support.
|
||||
- Add one-time bootstrap exchange endpoint.
|
||||
|
||||
### Phase 3
|
||||
|
||||
- Add desktop bootstrap flow on top of the same services.
|
||||
- Make desktop-managed local environments default to bootstrap-only pairing.
|
||||
- Surface auth capabilities in shared contracts and renderer bootstrap.
|
||||
|
||||
### Phase 4
|
||||
|
||||
- Add non-browser bearer session support if mobile/native needs it.
|
||||
- Add richer policy modes for remote-reachable environments.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- No privileged HTTP or WebSocket path bypasses auth policy.
|
||||
- Local desktop-managed flows still avoid a visible login screen.
|
||||
- Non-loopback or published environments require explicit authenticated pairing by default.
|
||||
- Bootstrap and session credentials are distinct in code and in behavior.
|
||||
- Auth logic is centralized in Effect services/layers rather than route-local branching.
|
||||
@@ -1,89 +0,0 @@
|
||||
# Replace React Query With AtomRpc + Atom State
|
||||
|
||||
## Summary
|
||||
- Use `effect/unstable/reactivity/AtomRpc` over the existing `WsRpcGroup`; stop wrapping RPC in promises via [wsRpcClient.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsRpcClient.ts) and [wsNativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.ts).
|
||||
- Keep Zustand for orchestration read model and UI state.
|
||||
- Keep a narrow `desktopBridge` adapter for dialogs, menus, external links, theme, and updater APIs.
|
||||
- Do not introduce Suspense in this migration. Atom-backed hooks should keep returning `data`, `error`, `isLoading|isPending`, `refresh`, and `mutateAsync`-style surfaces so component churn stays low.
|
||||
|
||||
## Target Architecture
|
||||
- Extract the websocket `RpcClient.Protocol` layer from [wsTransport.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsTransport.ts) into `rpc/protocol.ts`.
|
||||
- Define one `AtomRpc.Service` for `WsRpcGroup` in `rpc/client.ts`.
|
||||
- Add `rpc/invalidation.ts` with explicit scoped invalidation keys: `git:${cwd}`, `project:${cwd}`, `checkpoint:${threadId}`, `server-config`.
|
||||
- Add `platform/desktopBridge.ts` as the only browser/desktop facade.
|
||||
- Remove from web by the end: [wsNativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.ts), [nativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/nativeApi.ts), [wsNativeApiState.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiState.ts), [wsNativeApiAtoms.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiAtoms.tsx), [wsRpcClient.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsRpcClient.ts), and all `*ReactQuery.ts` modules.
|
||||
|
||||
## Phase 1: Infrastructure First
|
||||
1. Extract the shared websocket RPC protocol layer from [wsTransport.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsTransport.ts) without changing behavior.
|
||||
2. Build the AtomRpc client on top of that layer.
|
||||
3. Add one temporary `runRpc` helper for imperative handlers that still want `Promise` ergonomics; it must call the AtomRpc service directly and must not reintroduce a facade object.
|
||||
4. Replace manual registry wiring with one app-level registry provider based on `@effect/atom-react`.
|
||||
5. Land this as a no-behavior-change PR.
|
||||
|
||||
## Phase 2: Replace `wsNativeApi`-Owned Push State
|
||||
1. Migrate welcome/config/provider/settings state first, because it is already atom-shaped and is the lowest-risk way to delete `wsNativeApi` responsibilities.
|
||||
2. Replace [wsNativeApiState.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiState.ts) with `rpc/serverState.ts`, updated directly from `subscribeServerLifecycle` and `subscribeServerConfig`.
|
||||
3. Keep the current hook names for one PR: `useServerConfig`, `useServerSettings`, `useServerProviders`, `useServerKeybindings`, `useServerWelcomeSubscription`, `useServerConfigUpdatedSubscription`.
|
||||
4. Move bootstrap side effects out of [wsNativeApiAtoms.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiAtoms.tsx) into a new root bootstrap component mounted from [__root.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/routes/__root.tsx).
|
||||
5. Delete the `server.getConfig()` fallback logic from [wsNativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.ts); snapshot fetch now lives beside the stream atoms.
|
||||
|
||||
## Phase 3: Replace React Query Domain By Domain
|
||||
1. Replace [gitReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/gitReactQuery.ts) first.
|
||||
2. Add `rpc/gitAtoms.ts` and `rpc/useGit.ts` with `useGitStatus`, `useGitBranches`, `useResolvePullRequest`, and `useGitMutation`.
|
||||
3. Mutation settlement must invalidate scoped keys, not a global cache. `checkout`, `pull`, `init`, `createWorktree`, `removeWorktree`, `preparePullRequestThread`, and stacked actions invalidate `git:${cwd}`. Worktree create/remove also invalidates `project:${cwd}`.
|
||||
4. Replace [projectReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/projectReactQuery.ts) second. `useProjectSearchEntries` must preserve current “keep previous results while loading” behavior.
|
||||
5. Replace [providerReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/providerReactQuery.ts) third. Preserve current checkpoint error normalization and retry/backoff semantics inside the atom effect. Invalidate by `checkpoint:${threadId}`.
|
||||
6. Defer the desktop updater until the last phase.
|
||||
|
||||
## Phase 4: Move Root Invalidation Off `queryClient`
|
||||
1. In [__root.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/routes/__root.tsx), remove `QueryClient` usage and replace the throttled `invalidateQueries` block with throttled invalidation helpers.
|
||||
2. Keep Zustand orchestration/event application unchanged.
|
||||
3. Map current effects exactly:
|
||||
- git or checkpoint-affecting orchestration events touch `checkpoint:${threadId}`
|
||||
- file creation/deletion/restoration touches `project:${cwd}`
|
||||
- config-affecting server events touch `server-config`
|
||||
|
||||
## Phase 5: Remove Imperative `NativeApi` Usage
|
||||
1. Create narrow modules instead of a replacement mega-facade:
|
||||
- `rpc/orchestrationActions.ts`
|
||||
- `rpc/terminalActions.ts`
|
||||
- `rpc/gitActions.ts`
|
||||
- `rpc/projectActions.ts`
|
||||
- `platform/desktopBridge.ts`
|
||||
2. Migrate direct [nativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/nativeApi.ts) callers by domain, not file-by-file: git-heavy components first, then orchestration/thread actions, then shell/dialog helpers.
|
||||
3. After the last caller is gone, delete [nativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/nativeApi.ts) and the `window.nativeApi` fallback entirely.
|
||||
4. In the final cleanup PR, remove `NativeApi` from [ipc.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/packages/contracts/src/ipc.ts) if nothing outside web still needs it.
|
||||
|
||||
## Phase 6: Remove React Query Completely
|
||||
1. Delete `@tanstack/react-query` from `apps/web/package.json`.
|
||||
2. Remove `QueryClientProvider` and router context from [router.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/router.ts) and [__root.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/routes/__root.tsx).
|
||||
3. Replace [desktopUpdateReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/desktopUpdateReactQuery.ts) with a writable atom plus `desktopBridge.onUpdateState`.
|
||||
4. Delete the old query-option tests.
|
||||
|
||||
## Public Interfaces And Types
|
||||
- Preserve the current server-state hook names during the transition.
|
||||
- Add permanent domain hooks: `useGitStatus`, `useGitBranches`, `useResolvePullRequest`, `useProjectSearchEntries`, `useCheckpointDiff`, `useDesktopUpdateState`.
|
||||
- Do not expose raw AtomRpc clients to components.
|
||||
- Do not add Suspense as part of this migration.
|
||||
- Final boundary is direct RPC for server features plus `desktopBridge` for local desktop features.
|
||||
|
||||
## Test Plan
|
||||
- Add unit tests for `rpc/serverState.ts`: snapshot bootstrapping, stream replay, provider/settings updates.
|
||||
- Add unit tests for git/project/checkpoint hooks: loading, error mapping, retry behavior, invalidation, keep-previous-result behavior.
|
||||
- Update the browser harness in [wsRpcHarness.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/test/wsRpcHarness.ts) to assert direct RPC + atom behavior instead of `__resetNativeApiForTests`.
|
||||
- Replace [wsNativeApi.test.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.test.ts), `gitReactQuery.test.ts`, `providerReactQuery.test.ts`, and `desktopUpdateReactQuery.test.ts` with equivalent atom-backed coverage.
|
||||
- Acceptance scenarios:
|
||||
- welcome still bootstraps snapshot and navigation
|
||||
- keybindings toast still responds to config stream updates
|
||||
- git status/branches refresh after checkout/pull/worktree actions
|
||||
- PR resolve dialog keeps cached result while typing
|
||||
- `@` path search refreshes after file mutations and orchestration events
|
||||
- diff panel refreshes when checkpoints arrive
|
||||
- desktop updater still reflects push events and button actions
|
||||
|
||||
## Assumptions And Defaults
|
||||
- Zustand stays in scope; only `react-query` is being removed.
|
||||
- `desktopBridge` remains the only non-RPC boundary.
|
||||
- The migration lands as 5-6 small PRs, each green independently.
|
||||
- Invalidations are explicit and scoped; do not recreate a global cache client abstraction.
|
||||
- Orchestration recovery/order logic stays as-is; only the data-fetching and mutation layer changes.
|
||||
@@ -15,6 +15,29 @@ The file must be a JSON array of rules:
|
||||
|
||||
See the full schema for more details: [`packages/contracts/src/keybindings.ts`](packages/contracts/src/keybindings.ts)
|
||||
|
||||
## Editor Schema Support
|
||||
|
||||
`keybindings.json` is intentionally a top-level JSON array, so it cannot carry an inline `$schema` property the way `settings.json` can.
|
||||
|
||||
To get autocomplete and hover docs in editors like VS Code, associate the file externally with the published schema:
|
||||
|
||||
```json
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["**/.t3/keybindings.json", "**/keybindings.json"],
|
||||
"url": "https://t3.codes/schemas/keybindings.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
If you want a pinned schema instead of the latest stable one, use a versioned URL such as:
|
||||
|
||||
```text
|
||||
https://t3.codes/schemas/keybindings/0.0.15.json
|
||||
```
|
||||
|
||||
## Defaults
|
||||
|
||||
```json
|
||||
@@ -23,7 +46,6 @@ See the full schema for more details: [`packages/contracts/src/keybindings.ts`](
|
||||
{ "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
|
||||
{ "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" },
|
||||
{ "key": "mod+w", "command": "terminal.close", "when": "terminalFocus" },
|
||||
{ "key": "mod+k", "command": "commandPalette.toggle", "when": "!terminalFocus" },
|
||||
{ "key": "mod+n", "command": "chat.new", "when": "!terminalFocus" },
|
||||
{ "key": "mod+shift+o", "command": "chat.new", "when": "!terminalFocus" },
|
||||
{ "key": "mod+shift+n", "command": "chat.newLocal", "when": "!terminalFocus" },
|
||||
@@ -51,7 +73,6 @@ Invalid rules are ignored. Invalid config files are ignored. Warnings are logged
|
||||
- `terminal.split`: split terminal (in focused terminal context by default)
|
||||
- `terminal.new`: create new terminal (in focused terminal context by default)
|
||||
- `terminal.close`: close/kill the focused terminal (in focused terminal context by default)
|
||||
- `commandPalette.toggle`: open or close the global command palette
|
||||
- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
|
||||
- `chat.newLocal`: create a new chat thread for the active project in a new environment (local/worktree determined by app settings (default `local`))
|
||||
- `editor.openFavorite`: open current project/worktree in the last-used editor
|
||||
|
||||
@@ -45,18 +45,8 @@ We are very very early in this project. Expect bugs.
|
||||
|
||||
We are not accepting contributions yet.
|
||||
|
||||
Observability guide: [docs/observability.md](./docs/observability.md)
|
||||
|
||||
## If you REALLY want to contribute still.... read this first
|
||||
|
||||
Before local development, prepare the environment and install dependencies:
|
||||
|
||||
```bash
|
||||
# Optional: only needed if you use mise for dev tool management.
|
||||
mise install
|
||||
bun install .
|
||||
```
|
||||
|
||||
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before opening an issue or PR.
|
||||
|
||||
Need support? Join the [Discord](https://discord.gg/jn4EGJjrvv).
|
||||
@@ -1,87 +1,68 @@
|
||||
# Remote Access
|
||||
# Remote Access Setup
|
||||
|
||||
Use this when you want to connect to a T3 Code server from another device such as a phone, tablet, or separate desktop app.
|
||||
Use this when you want to open T3 Code from another device (phone, tablet, another laptop).
|
||||
|
||||
## Recommended Setup
|
||||
## CLI ↔ Env option map
|
||||
|
||||
Use a trusted private network that meshes your devices together, such as a tailnet.
|
||||
The T3 Code CLI accepts the following configuration options, available either as CLI flags or environment variables:
|
||||
|
||||
That gives you:
|
||||
| CLI flag | Env var | Notes |
|
||||
| ----------------------- | --------------------- | ------------------------------------------------------------------------------------ |
|
||||
| `--mode <web\|desktop>` | `T3CODE_MODE` | Runtime mode. |
|
||||
| `--port <number>` | `T3CODE_PORT` | HTTP/WebSocket port. |
|
||||
| `--host <address>` | `T3CODE_HOST` | Bind interface/address. |
|
||||
| `--base-dir <path>` | `T3CODE_HOME` | Base directory. |
|
||||
| `--dev-url <url>` | `VITE_DEV_SERVER_URL` | Dev web URL redirect/proxy target. |
|
||||
| `--no-browser` | `T3CODE_NO_BROWSER` | Disable auto-open browser. |
|
||||
| `--auth-token <token>` | `T3CODE_AUTH_TOKEN` | WebSocket auth token. Use this for standard CLI and remote-server flows. |
|
||||
| `--bootstrap-fd <fd>` | `T3CODE_BOOTSTRAP_FD` | Read a one-shot bootstrap envelope from an inherited file descriptor during startup. |
|
||||
|
||||
- a stable address to connect to
|
||||
- transport security at the network layer
|
||||
- less exposure than opening the server to the public internet
|
||||
> TIP: Use the `--help` flag to see all available options and their descriptions.
|
||||
|
||||
## Enabling Network Access
|
||||
## Security First
|
||||
|
||||
There are two ways to expose your server for remote connections: from the desktop app or from the CLI.
|
||||
- Always set `--auth-token` before exposing the server outside localhost.
|
||||
- When you control the process launcher, prefer sending the auth token in a JSON envelope via `--bootstrap-fd <fd>`.
|
||||
With `--bootstrap-fd <fd>`, the launcher starts the server first, then sends a one-shot JSON envelope over the inherited file descriptor. This allows the auth token to be delivered without putting it in process environment or command line arguments.
|
||||
- Treat the token like a password.
|
||||
- Prefer binding to trusted interfaces (LAN IP or Tailnet IP) instead of opening all interfaces unless needed.
|
||||
|
||||
### Option 1: Desktop App
|
||||
## 1) Build + run server for remote access
|
||||
|
||||
If you are already running the desktop app and want to make it reachable from other devices:
|
||||
|
||||
1. Open **Settings** → **Connections**.
|
||||
2. Under **Manage Local Backend**, toggle **Network access** on. This will restart the app and run the backend on all network interfaces.
|
||||
3. The settings panel will show the address the server is reachable at (e.g. `http://192.168.x.y:3773`).
|
||||
4. Use **Create Link** to generate a pairing link you can share with another device.
|
||||
|
||||
### Option 2: Headless Server (CLI)
|
||||
|
||||
Use this when you want to run the server without a GUI, for example on a remote machine over SSH.
|
||||
|
||||
Run the server with `t3 serve`.
|
||||
Remote access should use the built web app (not local Vite redirect mode).
|
||||
|
||||
```bash
|
||||
npx t3 serve --host "$(tailscale ip -4)"
|
||||
bun run build
|
||||
TOKEN="$(openssl rand -hex 24)"
|
||||
bun run --cwd apps/server start -- --host 0.0.0.0 --port 3773 --auth-token "$TOKEN" --no-browser
|
||||
```
|
||||
|
||||
`t3 serve` starts the server without opening a browser and prints:
|
||||
Then open on your phone:
|
||||
|
||||
- a connection string
|
||||
- a pairing token
|
||||
- a pairing URL
|
||||
- a QR code for the pairing URL
|
||||
`http://<your-machine-ip>:3773`
|
||||
|
||||
From there, connect from another device in either of these ways:
|
||||
Example:
|
||||
|
||||
- scan the QR code on your phone
|
||||
- in the desktop app, enter the full pairing URL
|
||||
- in the desktop app, enter the host and token separately
|
||||
`http://192.168.1.42:3773`
|
||||
|
||||
Use `t3 serve --help` for the full flag reference. It supports the same general startup options as the normal server command, including an optional `cwd` argument.
|
||||
Notes:
|
||||
|
||||
> Note
|
||||
> The GUIs do not currently support adding projects on remote environments.
|
||||
> For now, use `t3 project ...` on the server machine instead.
|
||||
> Full GUI support for remote project management is coming soon.
|
||||
- `--host 0.0.0.0` listens on all IPv4 interfaces.
|
||||
- `--no-browser` prevents local auto-open, which is usually better for headless/remote sessions.
|
||||
- Ensure your OS firewall allows inbound TCP on the selected port.
|
||||
|
||||
## How Pairing Works
|
||||
## 2) Tailnet / Tailscale access
|
||||
|
||||
The remote device does not need a long-lived secret up front.
|
||||
If you use Tailscale, you can bind directly to your Tailnet address.
|
||||
|
||||
Instead:
|
||||
```bash
|
||||
TAILNET_IP="$(tailscale ip -4)"
|
||||
TOKEN="$(openssl rand -hex 24)"
|
||||
bun run --cwd apps/server start -- --host "$(tailscale ip -4)" --port 3773 --auth-token "$TOKEN" --no-browser
|
||||
```
|
||||
|
||||
1. `t3 serve` issues a one-time owner pairing token.
|
||||
2. The remote device exchanges that token with the server.
|
||||
3. The server creates an authenticated session for that device.
|
||||
Open from any device in your tailnet:
|
||||
|
||||
After pairing, future access is session-based. You do not need to keep reusing the original token unless you are pairing a new device.
|
||||
`http://<tailnet-ip>:3773`
|
||||
|
||||
## Managing Access Later
|
||||
|
||||
Use `t3 auth` to manage access after the initial pairing flow.
|
||||
|
||||
Typical uses:
|
||||
|
||||
- issue additional pairing credentials
|
||||
- inspect active sessions
|
||||
- revoke old pairing links or sessions
|
||||
|
||||
Use `t3 auth --help` and the nested subcommand help pages for the full reference.
|
||||
|
||||
## Security Notes
|
||||
|
||||
- Treat pairing URLs and pairing tokens like passwords.
|
||||
- Prefer binding `--host` to a trusted private address, such as a Tailnet IP, instead of exposing the server broadly.
|
||||
- Anyone with a valid pairing credential can create a session until that credential expires or is revoked.
|
||||
- Use `t3 auth` to revoke credentials or sessions you no longer trust.
|
||||
You can also bind `--host 0.0.0.0` and connect through the Tailnet IP, but binding directly to the Tailnet IP limits exposure.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/desktop",
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.15",
|
||||
"private": true,
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
@@ -24,7 +24,8 @@
|
||||
"@types/node": "catalog:",
|
||||
"tsdown": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
"vitest": "catalog:",
|
||||
"wait-on": "^8.0.2"
|
||||
},
|
||||
"productName": "T3 Code (Alpha)"
|
||||
}
|
||||
@@ -1,39 +1,27 @@
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
import { watch } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import waitOn from "wait-on";
|
||||
|
||||
import { desktopDir, resolveElectronPath } from "./electron-launcher.mjs";
|
||||
import { waitForResources } from "./wait-for-resources.mjs";
|
||||
|
||||
const devServerUrl = process.env.VITE_DEV_SERVER_URL?.trim();
|
||||
if (!devServerUrl) {
|
||||
throw new Error("VITE_DEV_SERVER_URL is required for desktop development.");
|
||||
}
|
||||
|
||||
const devServer = new URL(devServerUrl);
|
||||
const port = Number.parseInt(devServer.port, 10);
|
||||
if (!Number.isInteger(port) || port <= 0) {
|
||||
throw new Error(`VITE_DEV_SERVER_URL must include an explicit port: ${devServerUrl}`);
|
||||
}
|
||||
|
||||
const port = Number(process.env.ELECTRON_RENDERER_PORT ?? 5733);
|
||||
const devServerUrl = `http://localhost:${port}`;
|
||||
const requiredFiles = [
|
||||
"dist-electron/main.js",
|
||||
"dist-electron/preload.js",
|
||||
"../server/dist/bin.mjs",
|
||||
"../server/dist/index.mjs",
|
||||
];
|
||||
const watchedDirectories = [
|
||||
{ directory: "dist-electron", files: new Set(["main.js", "preload.js"]) },
|
||||
{ directory: "../server/dist", files: new Set(["bin.mjs"]) },
|
||||
{ directory: "../server/dist", files: new Set(["index.mjs"]) },
|
||||
];
|
||||
const forcedShutdownTimeoutMs = 1_500;
|
||||
const restartDebounceMs = 120;
|
||||
const childTreeGracePeriodMs = 1_200;
|
||||
|
||||
await waitForResources({
|
||||
baseDir: desktopDir,
|
||||
files: requiredFiles,
|
||||
tcpHost: devServer.hostname,
|
||||
tcpPort: port,
|
||||
await waitOn({
|
||||
resources: [`tcp:${port}`, ...requiredFiles.map((filePath) => `file:${filePath}`)],
|
||||
});
|
||||
|
||||
const childEnv = { ...process.env };
|
||||
@@ -72,7 +60,10 @@ function startApp() {
|
||||
[`--t3code-dev-root=${desktopDir}`, "dist-electron/main.js"],
|
||||
{
|
||||
cwd: desktopDir,
|
||||
env: childEnv,
|
||||
env: {
|
||||
...childEnv,
|
||||
VITE_DEV_SERVER_URL: devServerUrl,
|
||||
},
|
||||
stdio: "inherit",
|
||||
},
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
|
||||
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
|
||||
const APP_BUNDLE_ID = isDevelopment ? "com.t3tools.t3code.dev" : "com.t3tools.t3code";
|
||||
const APP_BUNDLE_ID = "com.t3tools.t3code";
|
||||
const LAUNCHER_VERSION = 1;
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
import * as FileSystem from "node:fs/promises";
|
||||
import * as Net from "node:net";
|
||||
import * as Path from "node:path";
|
||||
import * as Timers from "node:timers/promises";
|
||||
|
||||
const defaultTcpHosts = ["127.0.0.1", "localhost", "::1"];
|
||||
|
||||
async function fileExists(filePath) {
|
||||
try {
|
||||
await FileSystem.access(filePath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function tcpPortIsReady({ host, port, connectTimeoutMs = 500 }) {
|
||||
return new Promise((resolveReady) => {
|
||||
const socket = Net.createConnection({ host, port });
|
||||
let settled = false;
|
||||
|
||||
const finish = (ready) => {
|
||||
if (settled) {
|
||||
return;
|
||||
}
|
||||
|
||||
settled = true;
|
||||
socket.removeAllListeners();
|
||||
socket.destroy();
|
||||
resolveReady(ready);
|
||||
};
|
||||
|
||||
socket.once("connect", () => {
|
||||
finish(true);
|
||||
});
|
||||
socket.once("timeout", () => {
|
||||
finish(false);
|
||||
});
|
||||
socket.once("error", () => {
|
||||
finish(false);
|
||||
});
|
||||
socket.setTimeout(connectTimeoutMs);
|
||||
});
|
||||
}
|
||||
|
||||
async function resolvePendingResources({ baseDir, files, tcpPort, tcpHosts, connectTimeoutMs }) {
|
||||
const pendingFiles = [];
|
||||
|
||||
for (const relativeFilePath of files) {
|
||||
const ready = await fileExists(Path.resolve(baseDir, relativeFilePath));
|
||||
if (!ready) {
|
||||
pendingFiles.push(relativeFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
let tcpReady = false;
|
||||
for (const host of tcpHosts) {
|
||||
tcpReady = await tcpPortIsReady({
|
||||
host,
|
||||
port: tcpPort,
|
||||
connectTimeoutMs,
|
||||
});
|
||||
if (tcpReady) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
pendingFiles,
|
||||
tcpReady,
|
||||
};
|
||||
}
|
||||
|
||||
export async function waitForResources({
|
||||
baseDir,
|
||||
files = [],
|
||||
intervalMs = 100,
|
||||
timeoutMs = 120_000,
|
||||
tcpHost,
|
||||
tcpPort,
|
||||
connectTimeoutMs = 500,
|
||||
}) {
|
||||
if (!Number.isInteger(tcpPort) || tcpPort <= 0) {
|
||||
throw new TypeError("waitForResources requires a positive integer tcpPort");
|
||||
}
|
||||
|
||||
const startedAt = Date.now();
|
||||
const tcpHosts = tcpHost ? [tcpHost] : defaultTcpHosts;
|
||||
|
||||
while (true) {
|
||||
const { pendingFiles, tcpReady } = await resolvePendingResources({
|
||||
baseDir,
|
||||
files,
|
||||
tcpPort,
|
||||
tcpHosts,
|
||||
connectTimeoutMs,
|
||||
});
|
||||
|
||||
if (pendingFiles.length === 0 && tcpReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Date.now() - startedAt >= timeoutMs) {
|
||||
const pendingResources = [];
|
||||
if (!tcpReady) {
|
||||
pendingResources.push(tcpHost ? `tcp:${tcpHost}:${tcpPort}` : `tcp:${tcpPort}`);
|
||||
}
|
||||
for (const filePath of pendingFiles) {
|
||||
pendingResources.push(`file:${filePath}`);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Timed out waiting for desktop dev resources after ${timeoutMs}ms: ${pendingResources.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
await Timers.setTimeout(intervalMs);
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { resolveDesktopBackendPort } from "./backendPort";
|
||||
|
||||
describe("resolveDesktopBackendPort", () => {
|
||||
it("returns the starting port when it is available", async () => {
|
||||
const canListenOnHost = vi.fn(async (port: number) => port === 3773);
|
||||
|
||||
await expect(
|
||||
resolveDesktopBackendPort({
|
||||
host: "127.0.0.1",
|
||||
startPort: 3773,
|
||||
canListenOnHost,
|
||||
}),
|
||||
).resolves.toBe(3773);
|
||||
|
||||
expect(canListenOnHost).toHaveBeenCalledTimes(1);
|
||||
expect(canListenOnHost).toHaveBeenCalledWith(3773, "127.0.0.1");
|
||||
});
|
||||
|
||||
it("increments sequentially until it finds an available port", async () => {
|
||||
const canListenOnHost = vi.fn(async (port: number) => port === 3775);
|
||||
|
||||
await expect(
|
||||
resolveDesktopBackendPort({
|
||||
host: "127.0.0.1",
|
||||
startPort: 3773,
|
||||
canListenOnHost,
|
||||
}),
|
||||
).resolves.toBe(3775);
|
||||
|
||||
expect(canListenOnHost.mock.calls).toEqual([
|
||||
[3773, "127.0.0.1"],
|
||||
[3774, "127.0.0.1"],
|
||||
[3775, "127.0.0.1"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("treats wildcard-bound ports as unavailable even when loopback probing succeeds", async () => {
|
||||
const canListenOnHost = vi.fn(async (port: number, host: string) => {
|
||||
if (port === 3773 && host === "127.0.0.1") return true;
|
||||
if (port === 3773 && host === "0.0.0.0") return false;
|
||||
return port === 3774;
|
||||
});
|
||||
|
||||
await expect(
|
||||
resolveDesktopBackendPort({
|
||||
host: "127.0.0.1",
|
||||
requiredHosts: ["0.0.0.0"],
|
||||
startPort: 3773,
|
||||
canListenOnHost,
|
||||
}),
|
||||
).resolves.toBe(3774);
|
||||
|
||||
expect(canListenOnHost.mock.calls).toEqual([
|
||||
[3773, "127.0.0.1"],
|
||||
[3773, "0.0.0.0"],
|
||||
[3774, "127.0.0.1"],
|
||||
[3774, "0.0.0.0"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("checks overlapping hosts sequentially to avoid self-interference", async () => {
|
||||
let inFlightCount = 0;
|
||||
const canListenOnHost = vi.fn(async (_port: number, _host: string) => {
|
||||
inFlightCount += 1;
|
||||
const overlapped = inFlightCount > 1;
|
||||
await Promise.resolve();
|
||||
inFlightCount -= 1;
|
||||
return !overlapped;
|
||||
});
|
||||
|
||||
await expect(
|
||||
resolveDesktopBackendPort({
|
||||
host: "127.0.0.1",
|
||||
requiredHosts: ["0.0.0.0", "::"],
|
||||
startPort: 3773,
|
||||
maxPort: 3773,
|
||||
canListenOnHost,
|
||||
}),
|
||||
).resolves.toBe(3773);
|
||||
|
||||
expect(canListenOnHost.mock.calls).toEqual([
|
||||
[3773, "127.0.0.1"],
|
||||
[3773, "0.0.0.0"],
|
||||
[3773, "::"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("fails when the scan range is exhausted", async () => {
|
||||
const canListenOnHost = vi.fn(async () => false);
|
||||
|
||||
await expect(
|
||||
resolveDesktopBackendPort({
|
||||
host: "127.0.0.1",
|
||||
startPort: 65534,
|
||||
maxPort: 65535,
|
||||
canListenOnHost,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
"No desktop backend port is available on hosts 127.0.0.1 between 65534 and 65535",
|
||||
);
|
||||
|
||||
expect(canListenOnHost.mock.calls).toEqual([
|
||||
[65534, "127.0.0.1"],
|
||||
[65535, "127.0.0.1"],
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -1,83 +0,0 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
|
||||
export const DEFAULT_DESKTOP_BACKEND_PORT = 3773;
|
||||
const MAX_TCP_PORT = 65_535;
|
||||
|
||||
export interface ResolveDesktopBackendPortOptions {
|
||||
readonly host: string;
|
||||
readonly startPort?: number;
|
||||
readonly maxPort?: number;
|
||||
readonly requiredHosts?: ReadonlyArray<string>;
|
||||
readonly canListenOnHost?: (port: number, host: string) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const defaultCanListenOnHost = async (port: number, host: string): Promise<boolean> =>
|
||||
Effect.service(NetService).pipe(
|
||||
Effect.flatMap((net) => net.canListenOnHost(port, host)),
|
||||
Effect.provide(NetService.layer),
|
||||
Effect.runPromise,
|
||||
);
|
||||
|
||||
const isValidPort = (port: number): boolean =>
|
||||
Number.isInteger(port) && port >= 1 && port <= MAX_TCP_PORT;
|
||||
|
||||
const normalizeHosts = (
|
||||
host: string,
|
||||
requiredHosts: ReadonlyArray<string>,
|
||||
): ReadonlyArray<string> =>
|
||||
Array.from(
|
||||
new Set(
|
||||
[host, ...requiredHosts]
|
||||
.map((candidate) => candidate.trim())
|
||||
.filter((candidate) => candidate.length > 0),
|
||||
),
|
||||
);
|
||||
|
||||
async function canListenOnAllHosts(
|
||||
port: number,
|
||||
hosts: ReadonlyArray<string>,
|
||||
canListenOnHost: (port: number, host: string) => Promise<boolean>,
|
||||
): Promise<boolean> {
|
||||
for (const candidateHost of hosts) {
|
||||
if (!(await canListenOnHost(port, candidateHost))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function resolveDesktopBackendPort({
|
||||
host,
|
||||
startPort = DEFAULT_DESKTOP_BACKEND_PORT,
|
||||
maxPort = MAX_TCP_PORT,
|
||||
requiredHosts = [],
|
||||
canListenOnHost = defaultCanListenOnHost,
|
||||
}: ResolveDesktopBackendPortOptions): Promise<number> {
|
||||
if (!isValidPort(startPort)) {
|
||||
throw new Error(`Invalid desktop backend start port: ${startPort}`);
|
||||
}
|
||||
|
||||
if (!isValidPort(maxPort)) {
|
||||
throw new Error(`Invalid desktop backend max port: ${maxPort}`);
|
||||
}
|
||||
|
||||
if (maxPort < startPort) {
|
||||
throw new Error(`Desktop backend max port ${maxPort} is below start port ${startPort}`);
|
||||
}
|
||||
|
||||
const hostsToCheck = normalizeHosts(host, requiredHosts);
|
||||
|
||||
// Keep desktop startup predictable across app restarts by probing upward from
|
||||
// the same preferred port instead of picking a fresh ephemeral port.
|
||||
for (let port = startPort; port <= maxPort; port += 1) {
|
||||
if (await canListenOnAllHosts(port, hostsToCheck, canListenOnHost)) {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`No desktop backend port is available on hosts ${hostsToCheck.join(", ")} between ${startPort} and ${maxPort}`,
|
||||
);
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
BackendReadinessAbortedError,
|
||||
isBackendReadinessAborted,
|
||||
waitForHttpReady,
|
||||
} from "./backendReadiness";
|
||||
|
||||
describe("waitForHttpReady", () => {
|
||||
it("returns once the backend serves the requested readiness path", async () => {
|
||||
const fetchImpl = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(new Response(null, { status: 503 }))
|
||||
.mockResolvedValueOnce(new Response(null, { status: 200 }));
|
||||
|
||||
await waitForHttpReady("http://127.0.0.1:3773", {
|
||||
fetchImpl,
|
||||
timeoutMs: 1_000,
|
||||
intervalMs: 0,
|
||||
});
|
||||
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(2);
|
||||
expect(fetchImpl).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
"http://127.0.0.1:3773/",
|
||||
expect.objectContaining({ redirect: "manual" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("retries after a readiness request stalls past the per-request timeout", async () => {
|
||||
const fetchImpl = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementationOnce(
|
||||
(_input, init) =>
|
||||
new Promise((_resolve, reject) => {
|
||||
init?.signal?.addEventListener(
|
||||
"abort",
|
||||
() => {
|
||||
reject(new Error("request timed out"));
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
}) as ReturnType<typeof fetch>,
|
||||
)
|
||||
.mockResolvedValueOnce(new Response(null, { status: 200 }));
|
||||
|
||||
await waitForHttpReady("http://127.0.0.1:3773", {
|
||||
fetchImpl,
|
||||
timeoutMs: 100,
|
||||
intervalMs: 0,
|
||||
requestTimeoutMs: 1,
|
||||
});
|
||||
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("aborts an in-flight readiness wait", async () => {
|
||||
const controller = new AbortController();
|
||||
const fetchImpl = vi.fn<typeof fetch>().mockImplementation(
|
||||
() =>
|
||||
new Promise((_resolve, reject) => {
|
||||
controller.signal.addEventListener(
|
||||
"abort",
|
||||
() => {
|
||||
reject(new BackendReadinessAbortedError());
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
}) as ReturnType<typeof fetch>,
|
||||
);
|
||||
|
||||
const waitPromise = waitForHttpReady("http://127.0.0.1:3773", {
|
||||
fetchImpl,
|
||||
timeoutMs: 1_000,
|
||||
intervalMs: 0,
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
controller.abort();
|
||||
|
||||
await expect(waitPromise).rejects.toBeInstanceOf(BackendReadinessAbortedError);
|
||||
});
|
||||
|
||||
it("recognizes aborted readiness errors", () => {
|
||||
expect(isBackendReadinessAborted(new BackendReadinessAbortedError())).toBe(true);
|
||||
expect(isBackendReadinessAborted(new Error("nope"))).toBe(false);
|
||||
});
|
||||
|
||||
it("supports custom readiness predicates", async () => {
|
||||
const fetchImpl = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockResolvedValueOnce(new Response(null, { status: 200 }))
|
||||
.mockResolvedValueOnce(new Response(null, { status: 204 }));
|
||||
|
||||
await waitForHttpReady("http://127.0.0.1:3773", {
|
||||
fetchImpl,
|
||||
timeoutMs: 1_000,
|
||||
intervalMs: 0,
|
||||
path: "/api/healthz",
|
||||
isReady: (response) => response.status === 204,
|
||||
});
|
||||
|
||||
expect(fetchImpl).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
"http://127.0.0.1:3773/api/healthz",
|
||||
expect.objectContaining({ redirect: "manual" }),
|
||||
);
|
||||
expect(fetchImpl).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
"http://127.0.0.1:3773/api/healthz",
|
||||
expect.objectContaining({ redirect: "manual" }),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,107 +0,0 @@
|
||||
export interface WaitForHttpReadyOptions {
|
||||
readonly timeoutMs?: number;
|
||||
readonly intervalMs?: number;
|
||||
readonly requestTimeoutMs?: number;
|
||||
readonly fetchImpl?: typeof fetch;
|
||||
readonly signal?: AbortSignal;
|
||||
readonly path?: string;
|
||||
readonly isReady?: (response: Response) => boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 30_000;
|
||||
const DEFAULT_INTERVAL_MS = 100;
|
||||
const DEFAULT_REQUEST_TIMEOUT_MS = 1_000;
|
||||
|
||||
export class BackendReadinessAbortedError extends Error {
|
||||
constructor() {
|
||||
super("Backend readiness wait was aborted.");
|
||||
this.name = "BackendReadinessAbortedError";
|
||||
}
|
||||
}
|
||||
|
||||
function delay(ms: number, signal: AbortSignal | undefined): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
cleanup();
|
||||
resolve();
|
||||
}, ms);
|
||||
|
||||
const onAbort = () => {
|
||||
cleanup();
|
||||
reject(new BackendReadinessAbortedError());
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
clearTimeout(timer);
|
||||
signal?.removeEventListener("abort", onAbort);
|
||||
};
|
||||
|
||||
if (signal?.aborted) {
|
||||
cleanup();
|
||||
reject(new BackendReadinessAbortedError());
|
||||
return;
|
||||
}
|
||||
|
||||
signal?.addEventListener("abort", onAbort, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
export function isBackendReadinessAborted(error: unknown): error is BackendReadinessAbortedError {
|
||||
return error instanceof BackendReadinessAbortedError;
|
||||
}
|
||||
|
||||
export async function waitForHttpReady(
|
||||
baseUrl: string,
|
||||
options?: WaitForHttpReadyOptions,
|
||||
): Promise<void> {
|
||||
const fetchImpl = options?.fetchImpl ?? fetch;
|
||||
const signal = options?.signal;
|
||||
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
||||
const intervalMs = options?.intervalMs ?? DEFAULT_INTERVAL_MS;
|
||||
const requestTimeoutMs = options?.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
||||
const readinessPath = options?.path ?? "/";
|
||||
const isReady = options?.isReady ?? ((response: Response) => response.ok);
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
|
||||
for (;;) {
|
||||
if (signal?.aborted) {
|
||||
throw new BackendReadinessAbortedError();
|
||||
}
|
||||
|
||||
const requestController = new AbortController();
|
||||
const requestTimeout = setTimeout(() => {
|
||||
requestController.abort();
|
||||
}, requestTimeoutMs);
|
||||
const abortRequest = () => {
|
||||
requestController.abort();
|
||||
};
|
||||
signal?.addEventListener("abort", abortRequest, { once: true });
|
||||
|
||||
try {
|
||||
const response = await fetchImpl(new URL(readinessPath, baseUrl).toString(), {
|
||||
redirect: "manual",
|
||||
signal: requestController.signal,
|
||||
});
|
||||
if (isReady(response)) {
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
if (isBackendReadinessAborted(error)) {
|
||||
throw error;
|
||||
}
|
||||
if (signal?.aborted) {
|
||||
throw new BackendReadinessAbortedError();
|
||||
}
|
||||
// Retry until the backend becomes reachable or the deadline expires.
|
||||
} finally {
|
||||
clearTimeout(requestTimeout);
|
||||
signal?.removeEventListener("abort", abortRequest);
|
||||
}
|
||||
|
||||
if (Date.now() >= deadline) {
|
||||
throw new Error(`Timed out waiting for backend readiness at ${baseUrl}.`);
|
||||
}
|
||||
|
||||
await delay(intervalMs, signal);
|
||||
}
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
|
||||
import {
|
||||
EnvironmentId,
|
||||
type ClientSettings,
|
||||
type PersistedSavedEnvironmentRecord,
|
||||
} from "@t3tools/contracts";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
readClientSettings,
|
||||
readSavedEnvironmentRegistry,
|
||||
readSavedEnvironmentSecret,
|
||||
removeSavedEnvironmentSecret,
|
||||
writeClientSettings,
|
||||
writeSavedEnvironmentRegistry,
|
||||
writeSavedEnvironmentSecret,
|
||||
type DesktopSecretStorage,
|
||||
} from "./clientPersistence";
|
||||
|
||||
const tempDirectories: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const directory of tempDirectories.splice(0)) {
|
||||
fs.rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
function makeTempPath(fileName: string): string {
|
||||
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "t3-client-persistence-test-"));
|
||||
tempDirectories.push(directory);
|
||||
return path.join(directory, fileName);
|
||||
}
|
||||
|
||||
function makeSecretStorage(available: boolean): DesktopSecretStorage {
|
||||
return {
|
||||
isEncryptionAvailable: () => available,
|
||||
encryptString: (value) => Buffer.from(`enc:${value}`, "utf8"),
|
||||
decryptString: (value) => {
|
||||
const decoded = value.toString("utf8");
|
||||
if (!decoded.startsWith("enc:")) {
|
||||
throw new Error("invalid secret");
|
||||
}
|
||||
return decoded.slice("enc:".length);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const clientSettings: ClientSettings = {
|
||||
confirmThreadArchive: true,
|
||||
confirmThreadDelete: false,
|
||||
diffWordWrap: true,
|
||||
sidebarProjectSortOrder: "manual",
|
||||
sidebarThreadSortOrder: "created_at",
|
||||
timestampFormat: "24-hour",
|
||||
};
|
||||
|
||||
const savedRegistryRecord: PersistedSavedEnvironmentRecord = {
|
||||
environmentId: EnvironmentId.make("environment-1"),
|
||||
label: "Remote environment",
|
||||
httpBaseUrl: "https://remote.example.com/",
|
||||
wsBaseUrl: "wss://remote.example.com/",
|
||||
createdAt: "2026-04-09T00:00:00.000Z",
|
||||
lastConnectedAt: "2026-04-09T01:00:00.000Z",
|
||||
};
|
||||
|
||||
describe("clientPersistence", () => {
|
||||
it("persists and reloads client settings", () => {
|
||||
const settingsPath = makeTempPath("client-settings.json");
|
||||
|
||||
writeClientSettings(settingsPath, clientSettings);
|
||||
|
||||
expect(readClientSettings(settingsPath)).toEqual(clientSettings);
|
||||
});
|
||||
|
||||
it("persists and reloads saved environment metadata", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
|
||||
writeSavedEnvironmentRegistry(registryPath, [savedRegistryRecord]);
|
||||
|
||||
expect(readSavedEnvironmentRegistry(registryPath)).toEqual([savedRegistryRecord]);
|
||||
});
|
||||
|
||||
it("persists encrypted saved environment secrets when encryption is available", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
const secretStorage = makeSecretStorage(true);
|
||||
|
||||
writeSavedEnvironmentRegistry(registryPath, [savedRegistryRecord]);
|
||||
|
||||
expect(
|
||||
writeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secret: "bearer-token",
|
||||
secretStorage,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
readSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secretStorage,
|
||||
}),
|
||||
).toBe("bearer-token");
|
||||
|
||||
expect(JSON.parse(fs.readFileSync(registryPath, "utf8"))).toEqual({
|
||||
records: [
|
||||
{
|
||||
...savedRegistryRecord,
|
||||
encryptedBearerToken: Buffer.from("enc:bearer-token", "utf8").toString("base64"),
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves existing secrets when encryption is unavailable", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
const availableSecretStorage = makeSecretStorage(true);
|
||||
|
||||
writeSavedEnvironmentRegistry(registryPath, [savedRegistryRecord]);
|
||||
|
||||
writeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secret: "bearer-token",
|
||||
secretStorage: availableSecretStorage,
|
||||
});
|
||||
|
||||
expect(
|
||||
writeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secret: "next-token",
|
||||
secretStorage: makeSecretStorage(false),
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
readSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secretStorage: availableSecretStorage,
|
||||
}),
|
||||
).toBe("bearer-token");
|
||||
});
|
||||
|
||||
it("removes saved environment secrets", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
const secretStorage = makeSecretStorage(true);
|
||||
|
||||
writeSavedEnvironmentRegistry(registryPath, [savedRegistryRecord]);
|
||||
|
||||
writeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secret: "bearer-token",
|
||||
secretStorage,
|
||||
});
|
||||
|
||||
removeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
});
|
||||
|
||||
expect(
|
||||
readSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secretStorage,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("treats malformed secrets documents as empty", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
fs.writeFileSync(registryPath, "{}\n", "utf8");
|
||||
|
||||
expect(
|
||||
readSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secretStorage: makeSecretStorage(true),
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
expect(() =>
|
||||
removeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
}),
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it("returns false when writing a secret without metadata", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
|
||||
expect(
|
||||
writeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secret: "bearer-token",
|
||||
secretStorage: makeSecretStorage(true),
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("preserves encrypted secrets when metadata is rewritten", () => {
|
||||
const registryPath = makeTempPath("saved-environments.json");
|
||||
const secretStorage = makeSecretStorage(true);
|
||||
|
||||
writeSavedEnvironmentRegistry(registryPath, [savedRegistryRecord]);
|
||||
|
||||
writeSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secret: "bearer-token",
|
||||
secretStorage,
|
||||
});
|
||||
|
||||
writeSavedEnvironmentRegistry(registryPath, [savedRegistryRecord]);
|
||||
|
||||
expect(readSavedEnvironmentRegistry(registryPath)).toEqual([savedRegistryRecord]);
|
||||
expect(
|
||||
readSavedEnvironmentSecret({
|
||||
registryPath,
|
||||
environmentId: savedRegistryRecord.environmentId,
|
||||
secretStorage,
|
||||
}),
|
||||
).toBe("bearer-token");
|
||||
});
|
||||
});
|
||||
@@ -1,216 +0,0 @@
|
||||
import * as FS from "node:fs";
|
||||
import * as Path from "node:path";
|
||||
|
||||
import type { ClientSettings, PersistedSavedEnvironmentRecord } from "@t3tools/contracts";
|
||||
import { Predicate } from "effect";
|
||||
|
||||
interface ClientSettingsDocument {
|
||||
readonly settings: ClientSettings;
|
||||
}
|
||||
|
||||
interface PersistedSavedEnvironmentStorageRecord extends PersistedSavedEnvironmentRecord {
|
||||
readonly encryptedBearerToken?: string;
|
||||
}
|
||||
|
||||
interface SavedEnvironmentRegistryDocument {
|
||||
readonly records: readonly PersistedSavedEnvironmentStorageRecord[];
|
||||
}
|
||||
|
||||
export interface DesktopSecretStorage {
|
||||
readonly isEncryptionAvailable: () => boolean;
|
||||
readonly encryptString: (value: string) => Buffer;
|
||||
readonly decryptString: (value: Buffer) => string;
|
||||
}
|
||||
|
||||
function readJsonFile<T>(filePath: string): T | null {
|
||||
try {
|
||||
if (!FS.existsSync(filePath)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parse(FS.readFileSync(filePath, "utf8")) as T;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJsonFile(filePath: string, value: unknown): void {
|
||||
const directory = Path.dirname(filePath);
|
||||
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
||||
FS.mkdirSync(directory, { recursive: true });
|
||||
FS.writeFileSync(tempPath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
||||
FS.renameSync(tempPath, filePath);
|
||||
}
|
||||
|
||||
function isPersistedSavedEnvironmentStorageRecord(
|
||||
value: unknown,
|
||||
): value is PersistedSavedEnvironmentStorageRecord {
|
||||
return (
|
||||
Predicate.isObject(value) &&
|
||||
typeof value.environmentId === "string" &&
|
||||
typeof value.label === "string" &&
|
||||
typeof value.httpBaseUrl === "string" &&
|
||||
typeof value.wsBaseUrl === "string" &&
|
||||
typeof value.createdAt === "string" &&
|
||||
(value.lastConnectedAt === null || typeof value.lastConnectedAt === "string") &&
|
||||
(value.encryptedBearerToken === undefined || typeof value.encryptedBearerToken === "string")
|
||||
);
|
||||
}
|
||||
|
||||
function readSavedEnvironmentRegistryDocument(filePath: string): SavedEnvironmentRegistryDocument {
|
||||
const parsed = readJsonFile<SavedEnvironmentRegistryDocument>(filePath);
|
||||
if (!Predicate.isObject(parsed)) {
|
||||
return { records: [] };
|
||||
}
|
||||
|
||||
return {
|
||||
records: Array.isArray(parsed.records)
|
||||
? parsed.records.filter(isPersistedSavedEnvironmentStorageRecord)
|
||||
: [],
|
||||
};
|
||||
}
|
||||
|
||||
function toPersistedSavedEnvironmentRecord(
|
||||
record: PersistedSavedEnvironmentStorageRecord,
|
||||
): PersistedSavedEnvironmentRecord {
|
||||
return {
|
||||
environmentId: record.environmentId,
|
||||
label: record.label,
|
||||
httpBaseUrl: record.httpBaseUrl,
|
||||
wsBaseUrl: record.wsBaseUrl,
|
||||
createdAt: record.createdAt,
|
||||
lastConnectedAt: record.lastConnectedAt,
|
||||
};
|
||||
}
|
||||
|
||||
export function readClientSettings(settingsPath: string): ClientSettings | null {
|
||||
return readJsonFile<ClientSettingsDocument>(settingsPath)?.settings ?? null;
|
||||
}
|
||||
|
||||
export function writeClientSettings(settingsPath: string, settings: ClientSettings): void {
|
||||
writeJsonFile(settingsPath, { settings } satisfies ClientSettingsDocument);
|
||||
}
|
||||
|
||||
export function readSavedEnvironmentRegistry(
|
||||
registryPath: string,
|
||||
): readonly PersistedSavedEnvironmentRecord[] {
|
||||
return readSavedEnvironmentRegistryDocument(registryPath).records.map((record) =>
|
||||
toPersistedSavedEnvironmentRecord(record),
|
||||
);
|
||||
}
|
||||
|
||||
export function writeSavedEnvironmentRegistry(
|
||||
registryPath: string,
|
||||
records: readonly PersistedSavedEnvironmentRecord[],
|
||||
): void {
|
||||
const currentDocument = readSavedEnvironmentRegistryDocument(registryPath);
|
||||
const encryptedBearerTokenById = new Map(
|
||||
currentDocument.records.flatMap((record) =>
|
||||
record.encryptedBearerToken
|
||||
? [[record.environmentId, record.encryptedBearerToken] as const]
|
||||
: [],
|
||||
),
|
||||
);
|
||||
writeJsonFile(registryPath, {
|
||||
records: records.map((record) => {
|
||||
const encryptedBearerToken = encryptedBearerTokenById.get(record.environmentId);
|
||||
return encryptedBearerToken
|
||||
? {
|
||||
environmentId: record.environmentId,
|
||||
label: record.label,
|
||||
httpBaseUrl: record.httpBaseUrl,
|
||||
wsBaseUrl: record.wsBaseUrl,
|
||||
createdAt: record.createdAt,
|
||||
lastConnectedAt: record.lastConnectedAt,
|
||||
encryptedBearerToken,
|
||||
}
|
||||
: record;
|
||||
}),
|
||||
} satisfies SavedEnvironmentRegistryDocument);
|
||||
}
|
||||
|
||||
export function readSavedEnvironmentSecret(input: {
|
||||
readonly registryPath: string;
|
||||
readonly environmentId: string;
|
||||
readonly secretStorage: DesktopSecretStorage;
|
||||
}): string | null {
|
||||
const document = readSavedEnvironmentRegistryDocument(input.registryPath);
|
||||
const encoded = document.records.find(
|
||||
(record) => record.environmentId === input.environmentId,
|
||||
)?.encryptedBearerToken;
|
||||
if (!encoded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!input.secretStorage.isEncryptionAvailable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return input.secretStorage.decryptString(Buffer.from(encoded, "base64"));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeSavedEnvironmentSecret(input: {
|
||||
readonly registryPath: string;
|
||||
readonly environmentId: string;
|
||||
readonly secret: string;
|
||||
readonly secretStorage: DesktopSecretStorage;
|
||||
}): boolean {
|
||||
const document = readSavedEnvironmentRegistryDocument(input.registryPath);
|
||||
|
||||
if (!input.secretStorage.isEncryptionAvailable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let found = false;
|
||||
|
||||
writeJsonFile(input.registryPath, {
|
||||
records: document.records.map((record) => {
|
||||
if (record.environmentId !== input.environmentId) {
|
||||
return record;
|
||||
}
|
||||
|
||||
found = true;
|
||||
const encryptedBearerToken = input.secretStorage
|
||||
.encryptString(input.secret)
|
||||
.toString("base64");
|
||||
return {
|
||||
environmentId: record.environmentId,
|
||||
label: record.label,
|
||||
httpBaseUrl: record.httpBaseUrl,
|
||||
wsBaseUrl: record.wsBaseUrl,
|
||||
createdAt: record.createdAt,
|
||||
lastConnectedAt: record.lastConnectedAt,
|
||||
encryptedBearerToken,
|
||||
} satisfies PersistedSavedEnvironmentStorageRecord;
|
||||
}),
|
||||
} satisfies SavedEnvironmentRegistryDocument);
|
||||
return found;
|
||||
}
|
||||
|
||||
export function removeSavedEnvironmentSecret(input: {
|
||||
readonly registryPath: string;
|
||||
readonly environmentId: string;
|
||||
}): void {
|
||||
const document = readSavedEnvironmentRegistryDocument(input.registryPath);
|
||||
if (
|
||||
!document.records.some(
|
||||
(record) =>
|
||||
record.environmentId === input.environmentId && record.encryptedBearerToken !== undefined,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeJsonFile(input.registryPath, {
|
||||
records: document.records.map((record) => {
|
||||
if (record.environmentId !== input.environmentId) {
|
||||
return record;
|
||||
}
|
||||
|
||||
return toPersistedSavedEnvironmentRecord(record);
|
||||
}),
|
||||
} satisfies SavedEnvironmentRegistryDocument);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
DEFAULT_DESKTOP_SETTINGS,
|
||||
readDesktopSettings,
|
||||
setDesktopServerExposurePreference,
|
||||
writeDesktopSettings,
|
||||
} from "./desktopSettings";
|
||||
|
||||
const tempDirectories: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const directory of tempDirectories.splice(0)) {
|
||||
fs.rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
function makeSettingsPath() {
|
||||
const directory = fs.mkdtempSync(path.join(os.tmpdir(), "t3-desktop-settings-test-"));
|
||||
tempDirectories.push(directory);
|
||||
return path.join(directory, "desktop-settings.json");
|
||||
}
|
||||
|
||||
describe("desktopSettings", () => {
|
||||
it("returns defaults when no settings file exists", () => {
|
||||
expect(readDesktopSettings(makeSettingsPath())).toEqual(DEFAULT_DESKTOP_SETTINGS);
|
||||
});
|
||||
|
||||
it("persists and reloads the configured server exposure mode", () => {
|
||||
const settingsPath = makeSettingsPath();
|
||||
|
||||
writeDesktopSettings(settingsPath, {
|
||||
serverExposureMode: "network-accessible",
|
||||
});
|
||||
|
||||
expect(readDesktopSettings(settingsPath)).toEqual({
|
||||
serverExposureMode: "network-accessible",
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves the requested network-accessible preference across temporary fallback", () => {
|
||||
expect(
|
||||
setDesktopServerExposurePreference(
|
||||
{
|
||||
serverExposureMode: "local-only",
|
||||
},
|
||||
"network-accessible",
|
||||
),
|
||||
).toEqual({
|
||||
serverExposureMode: "network-accessible",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to defaults when the settings file is malformed", () => {
|
||||
const settingsPath = makeSettingsPath();
|
||||
fs.writeFileSync(settingsPath, "{not-json", "utf8");
|
||||
|
||||
expect(readDesktopSettings(settingsPath)).toEqual(DEFAULT_DESKTOP_SETTINGS);
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
import * as FS from "node:fs";
|
||||
import * as Path from "node:path";
|
||||
import type { DesktopServerExposureMode } from "@t3tools/contracts";
|
||||
|
||||
export interface DesktopSettings {
|
||||
readonly serverExposureMode: DesktopServerExposureMode;
|
||||
}
|
||||
|
||||
export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
|
||||
serverExposureMode: "local-only",
|
||||
};
|
||||
|
||||
export function setDesktopServerExposurePreference(
|
||||
settings: DesktopSettings,
|
||||
requestedMode: DesktopServerExposureMode,
|
||||
): DesktopSettings {
|
||||
return settings.serverExposureMode === requestedMode
|
||||
? settings
|
||||
: {
|
||||
...settings,
|
||||
serverExposureMode: requestedMode,
|
||||
};
|
||||
}
|
||||
|
||||
export function readDesktopSettings(settingsPath: string): DesktopSettings {
|
||||
try {
|
||||
if (!FS.existsSync(settingsPath)) {
|
||||
return DEFAULT_DESKTOP_SETTINGS;
|
||||
}
|
||||
|
||||
const raw = FS.readFileSync(settingsPath, "utf8");
|
||||
const parsed = JSON.parse(raw) as {
|
||||
readonly serverExposureMode?: unknown;
|
||||
};
|
||||
|
||||
return {
|
||||
serverExposureMode:
|
||||
parsed.serverExposureMode === "network-accessible" ? "network-accessible" : "local-only",
|
||||
};
|
||||
} catch {
|
||||
return DEFAULT_DESKTOP_SETTINGS;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeDesktopSettings(settingsPath: string, settings: DesktopSettings): void {
|
||||
const directory = Path.dirname(settingsPath);
|
||||
const tempPath = `${settingsPath}.${process.pid}.${Date.now()}.tmp`;
|
||||
FS.mkdirSync(directory, { recursive: true });
|
||||
FS.writeFileSync(tempPath, `${JSON.stringify(settings, null, 2)}\n`, "utf8");
|
||||
FS.renameSync(tempPath, settingsPath);
|
||||
}
|
||||
@@ -12,38 +12,13 @@ const UPDATE_GET_STATE_CHANNEL = "desktop:update-get-state";
|
||||
const UPDATE_CHECK_CHANNEL = "desktop:update-check";
|
||||
const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
|
||||
const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
|
||||
const GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL = "desktop:get-local-environment-bootstrap";
|
||||
const GET_CLIENT_SETTINGS_CHANNEL = "desktop:get-client-settings";
|
||||
const SET_CLIENT_SETTINGS_CHANNEL = "desktop:set-client-settings";
|
||||
const GET_SAVED_ENVIRONMENT_REGISTRY_CHANNEL = "desktop:get-saved-environment-registry";
|
||||
const SET_SAVED_ENVIRONMENT_REGISTRY_CHANNEL = "desktop:set-saved-environment-registry";
|
||||
const GET_SAVED_ENVIRONMENT_SECRET_CHANNEL = "desktop:get-saved-environment-secret";
|
||||
const SET_SAVED_ENVIRONMENT_SECRET_CHANNEL = "desktop:set-saved-environment-secret";
|
||||
const REMOVE_SAVED_ENVIRONMENT_SECRET_CHANNEL = "desktop:remove-saved-environment-secret";
|
||||
const GET_SERVER_EXPOSURE_STATE_CHANNEL = "desktop:get-server-exposure-state";
|
||||
const SET_SERVER_EXPOSURE_MODE_CHANNEL = "desktop:set-server-exposure-mode";
|
||||
const GET_WS_URL_CHANNEL = "desktop:get-ws-url";
|
||||
|
||||
contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
getLocalEnvironmentBootstrap: () => {
|
||||
const result = ipcRenderer.sendSync(GET_LOCAL_ENVIRONMENT_BOOTSTRAP_CHANNEL);
|
||||
if (typeof result !== "object" || result === null) {
|
||||
return null;
|
||||
}
|
||||
return result as ReturnType<DesktopBridge["getLocalEnvironmentBootstrap"]>;
|
||||
getWsUrl: () => {
|
||||
const result = ipcRenderer.sendSync(GET_WS_URL_CHANNEL);
|
||||
return typeof result === "string" ? result : null;
|
||||
},
|
||||
getClientSettings: () => ipcRenderer.invoke(GET_CLIENT_SETTINGS_CHANNEL),
|
||||
setClientSettings: (settings) => ipcRenderer.invoke(SET_CLIENT_SETTINGS_CHANNEL, settings),
|
||||
getSavedEnvironmentRegistry: () => ipcRenderer.invoke(GET_SAVED_ENVIRONMENT_REGISTRY_CHANNEL),
|
||||
setSavedEnvironmentRegistry: (records) =>
|
||||
ipcRenderer.invoke(SET_SAVED_ENVIRONMENT_REGISTRY_CHANNEL, records),
|
||||
getSavedEnvironmentSecret: (environmentId) =>
|
||||
ipcRenderer.invoke(GET_SAVED_ENVIRONMENT_SECRET_CHANNEL, environmentId),
|
||||
setSavedEnvironmentSecret: (environmentId, secret) =>
|
||||
ipcRenderer.invoke(SET_SAVED_ENVIRONMENT_SECRET_CHANNEL, environmentId, secret),
|
||||
removeSavedEnvironmentSecret: (environmentId) =>
|
||||
ipcRenderer.invoke(REMOVE_SAVED_ENVIRONMENT_SECRET_CHANNEL, environmentId),
|
||||
getServerExposureState: () => ipcRenderer.invoke(GET_SERVER_EXPOSURE_STATE_CHANNEL),
|
||||
setServerExposureMode: (mode) => ipcRenderer.invoke(SET_SERVER_EXPOSURE_MODE_CHANNEL, mode),
|
||||
pickFolder: () => ipcRenderer.invoke(PICK_FOLDER_CHANNEL),
|
||||
confirm: (message) => ipcRenderer.invoke(CONFIRM_CHANNEL, message),
|
||||
setTheme: (theme) => ipcRenderer.invoke(SET_THEME_CHANNEL, theme),
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { resolveDesktopServerExposure, resolveLanAdvertisedHost } from "./serverExposure";
|
||||
|
||||
describe("resolveLanAdvertisedHost", () => {
|
||||
it("prefers an explicit host override", () => {
|
||||
expect(
|
||||
resolveLanAdvertisedHost(
|
||||
{
|
||||
en0: [
|
||||
{
|
||||
address: "192.168.1.44",
|
||||
family: "IPv4",
|
||||
internal: false,
|
||||
netmask: "255.255.255.0",
|
||||
cidr: "192.168.1.44/24",
|
||||
mac: "00:00:00:00:00:00",
|
||||
},
|
||||
],
|
||||
},
|
||||
"10.0.0.9",
|
||||
),
|
||||
).toBe("10.0.0.9");
|
||||
});
|
||||
|
||||
it("returns the first usable non-internal IPv4 address", () => {
|
||||
expect(
|
||||
resolveLanAdvertisedHost(
|
||||
{
|
||||
lo0: [
|
||||
{
|
||||
address: "127.0.0.1",
|
||||
family: "IPv4",
|
||||
internal: true,
|
||||
netmask: "255.0.0.0",
|
||||
cidr: "127.0.0.1/8",
|
||||
mac: "00:00:00:00:00:00",
|
||||
},
|
||||
],
|
||||
en0: [
|
||||
{
|
||||
address: "192.168.1.44",
|
||||
family: "IPv4",
|
||||
internal: false,
|
||||
netmask: "255.255.255.0",
|
||||
cidr: "192.168.1.44/24",
|
||||
mac: "00:00:00:00:00:00",
|
||||
},
|
||||
],
|
||||
},
|
||||
undefined,
|
||||
),
|
||||
).toBe("192.168.1.44");
|
||||
});
|
||||
|
||||
it("returns null when no usable network address is available", () => {
|
||||
expect(
|
||||
resolveLanAdvertisedHost(
|
||||
{
|
||||
lo0: [
|
||||
{
|
||||
address: "127.0.0.1",
|
||||
family: "IPv4",
|
||||
internal: true,
|
||||
netmask: "255.0.0.0",
|
||||
cidr: "127.0.0.1/8",
|
||||
mac: "00:00:00:00:00:00",
|
||||
},
|
||||
],
|
||||
},
|
||||
undefined,
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveDesktopServerExposure", () => {
|
||||
it("keeps the desktop server loopback-only when local-only mode is selected", () => {
|
||||
expect(
|
||||
resolveDesktopServerExposure({
|
||||
mode: "local-only",
|
||||
port: 3773,
|
||||
networkInterfaces: {},
|
||||
}),
|
||||
).toEqual({
|
||||
mode: "local-only",
|
||||
bindHost: "127.0.0.1",
|
||||
localHttpUrl: "http://127.0.0.1:3773",
|
||||
localWsUrl: "ws://127.0.0.1:3773",
|
||||
endpointUrl: null,
|
||||
advertisedHost: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("binds to all interfaces in network-accessible mode", () => {
|
||||
expect(
|
||||
resolveDesktopServerExposure({
|
||||
mode: "network-accessible",
|
||||
port: 3773,
|
||||
networkInterfaces: {
|
||||
en0: [
|
||||
{
|
||||
address: "192.168.1.44",
|
||||
family: "IPv4",
|
||||
internal: false,
|
||||
netmask: "255.255.255.0",
|
||||
cidr: "192.168.1.44/24",
|
||||
mac: "00:00:00:00:00:00",
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
mode: "network-accessible",
|
||||
bindHost: "0.0.0.0",
|
||||
localHttpUrl: "http://127.0.0.1:3773",
|
||||
localWsUrl: "ws://127.0.0.1:3773",
|
||||
endpointUrl: "http://192.168.1.44:3773",
|
||||
advertisedHost: "192.168.1.44",
|
||||
});
|
||||
});
|
||||
|
||||
it("stays network-accessible even when no LAN address is currently detectable", () => {
|
||||
expect(
|
||||
resolveDesktopServerExposure({
|
||||
mode: "network-accessible",
|
||||
port: 3773,
|
||||
networkInterfaces: {},
|
||||
}),
|
||||
).toEqual({
|
||||
mode: "network-accessible",
|
||||
bindHost: "0.0.0.0",
|
||||
localHttpUrl: "http://127.0.0.1:3773",
|
||||
localWsUrl: "ws://127.0.0.1:3773",
|
||||
endpointUrl: null,
|
||||
advertisedHost: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,80 +0,0 @@
|
||||
import type { NetworkInterfaceInfo } from "node:os";
|
||||
import type { DesktopServerExposureMode } from "@t3tools/contracts";
|
||||
|
||||
const DESKTOP_LOOPBACK_HOST = "127.0.0.1";
|
||||
const DESKTOP_LAN_BIND_HOST = "0.0.0.0";
|
||||
|
||||
export interface DesktopServerExposure {
|
||||
readonly mode: DesktopServerExposureMode;
|
||||
readonly bindHost: string;
|
||||
readonly localHttpUrl: string;
|
||||
readonly localWsUrl: string;
|
||||
readonly endpointUrl: string | null;
|
||||
readonly advertisedHost: string | null;
|
||||
}
|
||||
|
||||
const normalizeOptionalHost = (value: string | undefined): string | undefined => {
|
||||
const normalized = value?.trim();
|
||||
return normalized && normalized.length > 0 ? normalized : undefined;
|
||||
};
|
||||
|
||||
const isUsableLanIpv4Address = (address: string): boolean =>
|
||||
!address.startsWith("127.") && !address.startsWith("169.254.");
|
||||
|
||||
export function resolveLanAdvertisedHost(
|
||||
networkInterfaces: NodeJS.Dict<NetworkInterfaceInfo[]>,
|
||||
explicitHost: string | undefined,
|
||||
): string | null {
|
||||
const normalizedExplicitHost = normalizeOptionalHost(explicitHost);
|
||||
if (normalizedExplicitHost) {
|
||||
return normalizedExplicitHost;
|
||||
}
|
||||
|
||||
for (const interfaceAddresses of Object.values(networkInterfaces)) {
|
||||
if (!interfaceAddresses) continue;
|
||||
|
||||
for (const address of interfaceAddresses) {
|
||||
if (address.internal) continue;
|
||||
if (address.family !== "IPv4") continue;
|
||||
if (!isUsableLanIpv4Address(address.address)) continue;
|
||||
return address.address;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolveDesktopServerExposure(input: {
|
||||
readonly mode: DesktopServerExposureMode;
|
||||
readonly port: number;
|
||||
readonly networkInterfaces: NodeJS.Dict<NetworkInterfaceInfo[]>;
|
||||
readonly advertisedHostOverride?: string;
|
||||
}): DesktopServerExposure {
|
||||
const localHttpUrl = `http://${DESKTOP_LOOPBACK_HOST}:${input.port}`;
|
||||
const localWsUrl = `ws://${DESKTOP_LOOPBACK_HOST}:${input.port}`;
|
||||
|
||||
if (input.mode === "local-only") {
|
||||
return {
|
||||
mode: input.mode,
|
||||
bindHost: DESKTOP_LOOPBACK_HOST,
|
||||
localHttpUrl,
|
||||
localWsUrl,
|
||||
endpointUrl: null,
|
||||
advertisedHost: null,
|
||||
};
|
||||
}
|
||||
|
||||
const advertisedHost = resolveLanAdvertisedHost(
|
||||
input.networkInterfaces,
|
||||
input.advertisedHostOverride,
|
||||
);
|
||||
|
||||
return {
|
||||
mode: input.mode,
|
||||
bindHost: DESKTOP_LAN_BIND_HOST,
|
||||
localHttpUrl,
|
||||
localWsUrl,
|
||||
endpointUrl: advertisedHost ? `http://${advertisedHost}:${input.port}` : null,
|
||||
advertisedHost,
|
||||
};
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ServerListeningDetector } from "./serverListeningDetector";
|
||||
|
||||
describe("ServerListeningDetector", () => {
|
||||
it("resolves when the server logs the listening line", async () => {
|
||||
const detector = new ServerListeningDetector();
|
||||
|
||||
detector.push("[01:23:30.571] INFO (#148): Listening on http://0.0.0.0:7011\n");
|
||||
|
||||
await expect(detector.promise).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("resolves when the listening line arrives across multiple chunks", async () => {
|
||||
const detector = new ServerListeningDetector();
|
||||
|
||||
detector.push("[01:23:30.571] INFO (#148): Listen");
|
||||
detector.push("ing on http://0.0.0.0:7011\n");
|
||||
|
||||
await expect(detector.promise).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("rejects when the server exits before logging readiness", async () => {
|
||||
const detector = new ServerListeningDetector();
|
||||
const error = new Error("server exited");
|
||||
|
||||
detector.fail(error);
|
||||
|
||||
await expect(detector.promise).rejects.toBe(error);
|
||||
});
|
||||
});
|
||||
@@ -1,56 +0,0 @@
|
||||
const LISTENING_LOG_FRAGMENT = "Listening on http://";
|
||||
const MAX_BUFFER_CHARS = 8_192;
|
||||
|
||||
export class ServerListeningDetector {
|
||||
private buffer = "";
|
||||
private settled = false;
|
||||
private readonly resolvePromise: () => void;
|
||||
private readonly rejectPromise: (error: unknown) => void;
|
||||
readonly promise: Promise<void>;
|
||||
|
||||
constructor() {
|
||||
let resolvePromise: (() => void) | null = null;
|
||||
let rejectPromise: ((error: unknown) => void) | null = null;
|
||||
|
||||
this.promise = new Promise<void>((resolve, reject) => {
|
||||
resolvePromise = resolve;
|
||||
rejectPromise = reject;
|
||||
});
|
||||
|
||||
this.resolvePromise = () => {
|
||||
if (this.settled) {
|
||||
return;
|
||||
}
|
||||
this.settled = true;
|
||||
resolvePromise?.();
|
||||
};
|
||||
this.rejectPromise = (error) => {
|
||||
if (this.settled) {
|
||||
return;
|
||||
}
|
||||
this.settled = true;
|
||||
rejectPromise?.(error);
|
||||
};
|
||||
}
|
||||
|
||||
push(chunk: unknown): void {
|
||||
if (this.settled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const text = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
||||
this.buffer = `${this.buffer}${text.replace(/\r/g, "")}`;
|
||||
if (this.buffer.includes(LISTENING_LOG_FRAGMENT)) {
|
||||
this.resolvePromise();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.buffer.length > MAX_BUFFER_CHARS) {
|
||||
this.buffer = this.buffer.slice(-MAX_BUFFER_CHARS);
|
||||
}
|
||||
}
|
||||
|
||||
fail(error: unknown): void {
|
||||
this.rejectPromise(error);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,11 @@ describe("syncShellEnvironment", () => {
|
||||
it("hydrates PATH and missing SSH_AUTH_SOCK from the login shell on macOS", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/Users/test/.local/bin:/usr/bin",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
const readEnvironment = vi.fn(() => ({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/secretive.sock",
|
||||
HOMEBREW_PREFIX: "/opt/homebrew",
|
||||
}));
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
@@ -19,18 +18,9 @@ describe("syncShellEnvironment", () => {
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(readEnvironment).toHaveBeenCalledWith("/bin/zsh", [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
"HOMEBREW_REPOSITORY",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
]);
|
||||
expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin:/Users/test/.local/bin");
|
||||
expect(readEnvironment).toHaveBeenCalledWith("/bin/zsh", ["PATH", "SSH_AUTH_SOCK"]);
|
||||
expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/secretive.sock");
|
||||
expect(env.HOMEBREW_PREFIX).toBe("/opt/homebrew");
|
||||
});
|
||||
|
||||
it("preserves an inherited SSH_AUTH_SOCK value", () => {
|
||||
@@ -87,67 +77,11 @@ describe("syncShellEnvironment", () => {
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(readEnvironment).toHaveBeenCalledWith("/bin/zsh", [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
"HOMEBREW_REPOSITORY",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
]);
|
||||
expect(readEnvironment).toHaveBeenCalledWith("/bin/zsh", ["PATH", "SSH_AUTH_SOCK"]);
|
||||
expect(env.PATH).toBe("/home/linuxbrew/.linuxbrew/bin:/usr/bin");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/secretive.sock");
|
||||
});
|
||||
|
||||
it("falls back to launchctl PATH on macOS when shell probing does not return one", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/opt/homebrew/bin/nu",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
const readEnvironment = vi
|
||||
.fn()
|
||||
.mockImplementationOnce(() => {
|
||||
throw new Error("unknown flag");
|
||||
})
|
||||
.mockImplementationOnce(() => ({}));
|
||||
const readLaunchctlPath = vi.fn(() => "/opt/homebrew/bin:/usr/bin");
|
||||
const logWarning = vi.fn();
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
platform: "darwin",
|
||||
readEnvironment,
|
||||
readLaunchctlPath,
|
||||
userShell: "/bin/zsh",
|
||||
logWarning,
|
||||
});
|
||||
|
||||
expect(readEnvironment).toHaveBeenNthCalledWith(1, "/opt/homebrew/bin/nu", [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
"HOMEBREW_REPOSITORY",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
]);
|
||||
expect(readEnvironment).toHaveBeenNthCalledWith(2, "/bin/zsh", [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
"HOMEBREW_REPOSITORY",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
]);
|
||||
expect(readLaunchctlPath).toHaveBeenCalledTimes(1);
|
||||
expect(logWarning).toHaveBeenCalledWith(
|
||||
"Failed to read login shell environment from /opt/homebrew/bin/nu.",
|
||||
expect.any(Error),
|
||||
);
|
||||
expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
});
|
||||
|
||||
it("does nothing outside macOS and linux", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "C:/Program Files/Git/bin/bash.exe",
|
||||
|
||||
@@ -1,79 +1,36 @@
|
||||
import {
|
||||
listLoginShellCandidates,
|
||||
mergePathEntries,
|
||||
readPathFromLaunchctl,
|
||||
readEnvironmentFromLoginShell,
|
||||
resolveLoginShell,
|
||||
ShellEnvironmentReader,
|
||||
} from "@t3tools/shared/shell";
|
||||
|
||||
const LOGIN_SHELL_ENV_NAMES = [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
"HOMEBREW_REPOSITORY",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
] as const;
|
||||
|
||||
function logShellEnvironmentWarning(message: string, error?: unknown): void {
|
||||
console.warn(`[desktop] ${message}`, error instanceof Error ? error.message : (error ?? ""));
|
||||
}
|
||||
|
||||
export function syncShellEnvironment(
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
options: {
|
||||
platform?: NodeJS.Platform;
|
||||
readEnvironment?: ShellEnvironmentReader;
|
||||
readLaunchctlPath?: typeof readPathFromLaunchctl;
|
||||
userShell?: string;
|
||||
logWarning?: (message: string, error?: unknown) => void;
|
||||
} = {},
|
||||
): void {
|
||||
const platform = options.platform ?? process.platform;
|
||||
if (platform !== "darwin" && platform !== "linux") return;
|
||||
|
||||
const logWarning = options.logWarning ?? logShellEnvironmentWarning;
|
||||
const readEnvironment = options.readEnvironment ?? readEnvironmentFromLoginShell;
|
||||
const shellEnvironment: Partial<Record<string, string>> = {};
|
||||
|
||||
try {
|
||||
for (const shell of listLoginShellCandidates(platform, env.SHELL, options.userShell)) {
|
||||
try {
|
||||
Object.assign(shellEnvironment, readEnvironment(shell, LOGIN_SHELL_ENV_NAMES));
|
||||
if (shellEnvironment.PATH) {
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
logWarning(`Failed to read login shell environment from ${shell}.`, error);
|
||||
}
|
||||
}
|
||||
const shell = resolveLoginShell(platform, env.SHELL);
|
||||
if (!shell) return;
|
||||
|
||||
const launchctlPath =
|
||||
platform === "darwin" && !shellEnvironment.PATH
|
||||
? (options.readLaunchctlPath ?? readPathFromLaunchctl)()
|
||||
: undefined;
|
||||
const mergedPath = mergePathEntries(shellEnvironment.PATH ?? launchctlPath, env.PATH, platform);
|
||||
if (mergedPath) {
|
||||
env.PATH = mergedPath;
|
||||
const shellEnvironment = (options.readEnvironment ?? readEnvironmentFromLoginShell)(shell, [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
]);
|
||||
|
||||
if (shellEnvironment.PATH) {
|
||||
env.PATH = shellEnvironment.PATH;
|
||||
}
|
||||
|
||||
if (!env.SSH_AUTH_SOCK && shellEnvironment.SSH_AUTH_SOCK) {
|
||||
env.SSH_AUTH_SOCK = shellEnvironment.SSH_AUTH_SOCK;
|
||||
}
|
||||
|
||||
for (const name of [
|
||||
"HOMEBREW_PREFIX",
|
||||
"HOMEBREW_CELLAR",
|
||||
"HOMEBREW_REPOSITORY",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
] as const) {
|
||||
if (!env[name] && shellEnvironment[name]) {
|
||||
env[name] = shellEnvironment[name];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logWarning("Failed to synchronize the desktop shell environment.", error);
|
||||
} catch {
|
||||
// Keep inherited environment if shell lookup fails.
|
||||
}
|
||||
}
|
||||
@@ -71,37 +71,10 @@ describe("getAutoUpdateDisabledReason", () => {
|
||||
platform: "darwin",
|
||||
appImage: undefined,
|
||||
disabledByEnv: false,
|
||||
hasUpdateFeedConfig: true,
|
||||
}),
|
||||
).toContain("packaged production builds");
|
||||
});
|
||||
|
||||
it("reports packaged local builds without an update feed as disabled", () => {
|
||||
expect(
|
||||
getAutoUpdateDisabledReason({
|
||||
isDevelopment: false,
|
||||
isPackaged: true,
|
||||
platform: "darwin",
|
||||
appImage: undefined,
|
||||
disabledByEnv: false,
|
||||
hasUpdateFeedConfig: false,
|
||||
}),
|
||||
).toContain("no update feed");
|
||||
});
|
||||
|
||||
it("allows packaged builds with an update feed", () => {
|
||||
expect(
|
||||
getAutoUpdateDisabledReason({
|
||||
isDevelopment: false,
|
||||
isPackaged: true,
|
||||
platform: "darwin",
|
||||
appImage: undefined,
|
||||
disabledByEnv: false,
|
||||
hasUpdateFeedConfig: true,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("reports env-disabled auto updates", () => {
|
||||
expect(
|
||||
getAutoUpdateDisabledReason({
|
||||
@@ -110,7 +83,6 @@ describe("getAutoUpdateDisabledReason", () => {
|
||||
platform: "darwin",
|
||||
appImage: undefined,
|
||||
disabledByEnv: true,
|
||||
hasUpdateFeedConfig: true,
|
||||
}),
|
||||
).toContain("T3CODE_DISABLE_AUTO_UPDATE");
|
||||
});
|
||||
@@ -123,7 +95,6 @@ describe("getAutoUpdateDisabledReason", () => {
|
||||
platform: "linux",
|
||||
appImage: undefined,
|
||||
disabledByEnv: false,
|
||||
hasUpdateFeedConfig: true,
|
||||
}),
|
||||
).toContain("AppImage");
|
||||
});
|
||||
|
||||
@@ -34,11 +34,7 @@ export function getAutoUpdateDisabledReason(args: {
|
||||
platform: NodeJS.Platform;
|
||||
appImage?: string | undefined;
|
||||
disabledByEnv: boolean;
|
||||
hasUpdateFeedConfig: boolean;
|
||||
}): string | null {
|
||||
if (!args.hasUpdateFeedConfig) {
|
||||
return "Automatic updates are not available because no update feed is configured.";
|
||||
}
|
||||
if (args.isDevelopment || !args.isPackaged) {
|
||||
return "Automatic updates are only available in packaged production builds.";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "T3 Code Keybindings",
|
||||
"description": "Ordered list of custom keybinding rules persisted in `keybindings.json`.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"key": {
|
||||
"type": "string",
|
||||
"description": "Keyboard shortcut to listen for."
|
||||
},
|
||||
"command": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"terminal.toggle",
|
||||
"terminal.split",
|
||||
"terminal.new",
|
||||
"terminal.close",
|
||||
"diff.toggle",
|
||||
"chat.new",
|
||||
"chat.newLocal",
|
||||
"editor.openFavorite",
|
||||
"thread.previous",
|
||||
"thread.next",
|
||||
"thread.jump.1",
|
||||
"thread.jump.2",
|
||||
"thread.jump.3",
|
||||
"thread.jump.4",
|
||||
"thread.jump.5",
|
||||
"thread.jump.6",
|
||||
"thread.jump.7",
|
||||
"thread.jump.8",
|
||||
"thread.jump.9"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^script\\.[\\s\\S]*?\\.run$",
|
||||
"description": "Command identifier for running a project script, formatted as `script.<id>.run`."
|
||||
}
|
||||
],
|
||||
"description": "Command to execute when the shortcut matches."
|
||||
},
|
||||
"when": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Optional expression limiting when the shortcut is active."
|
||||
}
|
||||
},
|
||||
"required": ["key", "command"],
|
||||
"additionalProperties": false,
|
||||
"description": "Single keybinding rule entry in `keybindings.json`."
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"maxItems": 256,
|
||||
"description": "Ordered list of custom keybinding rules persisted in `keybindings.json`."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "T3 Code Keybindings",
|
||||
"description": "Ordered list of custom keybinding rules persisted in `keybindings.json`.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"key": {
|
||||
"type": "string",
|
||||
"description": "Keyboard shortcut to listen for."
|
||||
},
|
||||
"command": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"terminal.toggle",
|
||||
"terminal.split",
|
||||
"terminal.new",
|
||||
"terminal.close",
|
||||
"diff.toggle",
|
||||
"chat.new",
|
||||
"chat.newLocal",
|
||||
"editor.openFavorite",
|
||||
"thread.previous",
|
||||
"thread.next",
|
||||
"thread.jump.1",
|
||||
"thread.jump.2",
|
||||
"thread.jump.3",
|
||||
"thread.jump.4",
|
||||
"thread.jump.5",
|
||||
"thread.jump.6",
|
||||
"thread.jump.7",
|
||||
"thread.jump.8",
|
||||
"thread.jump.9"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^script\\.[\\s\\S]*?\\.run$",
|
||||
"description": "Command identifier for running a project script, formatted as `script.<id>.run`."
|
||||
}
|
||||
],
|
||||
"description": "Command to execute when the shortcut matches."
|
||||
},
|
||||
"when": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Optional expression limiting when the shortcut is active."
|
||||
}
|
||||
},
|
||||
"required": ["key", "command"],
|
||||
"additionalProperties": false,
|
||||
"description": "Single keybinding rule entry in `keybindings.json`."
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"maxItems": 256,
|
||||
"description": "Ordered list of custom keybinding rules persisted in `keybindings.json`."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "T3 Code Server Settings",
|
||||
"description": "Server-authoritative settings persisted in `settings.json`.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"description": "Optional JSON Schema reference for editor tooling. May point to the stable or versioned T3 Code settings schema URL."
|
||||
},
|
||||
"enableAssistantStreaming": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Whether server-driven assistant responses should stream incrementally to clients when the active provider supports it."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Show token-by-token output while a response is in progress."
|
||||
},
|
||||
"defaultThreadEnvMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["local", "worktree"],
|
||||
"description": "Default execution environment to use when creating new threads."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Pick the default workspace mode for newly created draft threads."
|
||||
},
|
||||
"textGenerationModelSelection": {
|
||||
"anyOf": [
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["codex"],
|
||||
"description": "The provider used for text generation."
|
||||
},
|
||||
"model": {
|
||||
"type": "string",
|
||||
"description": "The Codex model slug to use for text generation."
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"reasoningEffort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["xhigh", "high", "medium", "low"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Reasoning depth for Codex text generation. Higher values trade latency and cost for stronger reasoning."
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether to prefer Codex fast mode when the selected model supports it."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Optional Codex-specific tuning knobs for the selected model."
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false,
|
||||
"description": "Text generation model selection for the Codex provider."
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["claudeAgent"],
|
||||
"description": "The provider used for text generation."
|
||||
},
|
||||
"model": {
|
||||
"type": "string",
|
||||
"description": "The Claude model slug to use for text generation."
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"thinking": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether Claude should enable extended thinking for the selected model."
|
||||
},
|
||||
"effort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["low", "medium", "high", "max", "ultrathink"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Reasoning effort for Claude text generation. Higher values trade latency and cost for stronger reasoning."
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether to prefer Claude fast mode when the selected model supports it."
|
||||
},
|
||||
"contextWindow": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Optional Claude context window preset to request for the selected model, if supported."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Optional Claude-specific tuning knobs for the selected model."
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false,
|
||||
"description": "Text generation model selection for the Claude provider."
|
||||
}
|
||||
],
|
||||
"description": "Default provider and model to use for server-side text generation features."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Configure the model used for generated commit messages, PR titles, and similar Git text."
|
||||
},
|
||||
"providers": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"codex": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Whether the Codex provider is enabled and available for selection."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether the Codex provider is enabled and available for selection."
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Path to the Codex executable. Leave blank to resolve the `codex` executable from PATH."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Path to the Codex binary"
|
||||
},
|
||||
"homePath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Optional Codex home directory. Leave blank to use the default provider-managed location."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Optional custom Codex home and config directory."
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Additional Codex model slugs to surface in the UI alongside discovered defaults."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Additional Codex model slugs to surface in the UI alongside discovered defaults."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Configuration for the Codex provider."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Configuration for the Codex provider."
|
||||
},
|
||||
"claudeAgent": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Whether the Claude provider is enabled and available for selection."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether the Claude provider is enabled and available for selection."
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Path to the Claude executable. Leave blank to resolve the `claude` executable from PATH."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Path to the Claude binary"
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Additional Claude model slugs to surface in the UI alongside discovered defaults."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Additional Claude model slugs to surface in the UI alongside discovered defaults."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Configuration for the Claude provider."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Configuration for the Claude provider."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Provider-specific server configuration."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Provider-specific server configuration."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "T3 Code Server Settings",
|
||||
"description": "Server-authoritative settings persisted in `settings.json`.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"description": "Optional JSON Schema reference for editor tooling. May point to the stable or versioned T3 Code settings schema URL."
|
||||
},
|
||||
"enableAssistantStreaming": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Whether server-driven assistant responses should stream incrementally to clients when the active provider supports it."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Show token-by-token output while a response is in progress."
|
||||
},
|
||||
"defaultThreadEnvMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["local", "worktree"],
|
||||
"description": "Default execution environment to use when creating new threads."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Pick the default workspace mode for newly created draft threads."
|
||||
},
|
||||
"textGenerationModelSelection": {
|
||||
"anyOf": [
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["codex"],
|
||||
"description": "The provider used for text generation."
|
||||
},
|
||||
"model": {
|
||||
"type": "string",
|
||||
"description": "The Codex model slug to use for text generation."
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"reasoningEffort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["xhigh", "high", "medium", "low"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Reasoning depth for Codex text generation. Higher values trade latency and cost for stronger reasoning."
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether to prefer Codex fast mode when the selected model supports it."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Optional Codex-specific tuning knobs for the selected model."
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false,
|
||||
"description": "Text generation model selection for the Codex provider."
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["claudeAgent"],
|
||||
"description": "The provider used for text generation."
|
||||
},
|
||||
"model": {
|
||||
"type": "string",
|
||||
"description": "The Claude model slug to use for text generation."
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"thinking": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether Claude should enable extended thinking for the selected model."
|
||||
},
|
||||
"effort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["low", "medium", "high", "max", "ultrathink"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Reasoning effort for Claude text generation. Higher values trade latency and cost for stronger reasoning."
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether to prefer Claude fast mode when the selected model supports it."
|
||||
},
|
||||
"contextWindow": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Optional Claude context window preset to request for the selected model, if supported."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Optional Claude-specific tuning knobs for the selected model."
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false,
|
||||
"description": "Text generation model selection for the Claude provider."
|
||||
}
|
||||
],
|
||||
"description": "Default provider and model to use for server-side text generation features."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Configure the model used for generated commit messages, PR titles, and similar Git text."
|
||||
},
|
||||
"providers": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"codex": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Whether the Codex provider is enabled and available for selection."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether the Codex provider is enabled and available for selection."
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Path to the Codex executable. Leave blank to resolve the `codex` executable from PATH."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Path to the Codex binary"
|
||||
},
|
||||
"homePath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Optional Codex home directory. Leave blank to use the default provider-managed location."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Optional custom Codex home and config directory."
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Additional Codex model slugs to surface in the UI alongside discovered defaults."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Additional Codex model slugs to surface in the UI alongside discovered defaults."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Configuration for the Codex provider."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Configuration for the Codex provider."
|
||||
},
|
||||
"claudeAgent": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Whether the Claude provider is enabled and available for selection."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Whether the Claude provider is enabled and available for selection."
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Path to the Claude executable. Leave blank to resolve the `claude` executable from PATH."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Path to the Claude binary"
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Additional Claude model slugs to surface in the UI alongside discovered defaults."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Additional Claude model slugs to surface in the UI alongside discovered defaults."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Configuration for the Claude provider."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Configuration for the Claude provider."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"description": "Provider-specific server configuration."
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Provider-specific server configuration."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
import { RELEASES_URL } from "../lib/releases";
|
||||
---
|
||||
|
||||
<Layout title="Download — T3 Code" description="Download T3 Code for macOS, Windows, or Linux.">
|
||||
@@ -18,11 +17,11 @@ import { RELEASES_URL } from "../lib/releases";
|
||||
<h2 class="platform-name">macOS</h2>
|
||||
</div>
|
||||
<div class="download-cards">
|
||||
<a class="download-card" data-asset="arm64.dmg" href={RELEASES_URL}>
|
||||
<a class="download-card" data-asset="arm64.dmg" href="#">
|
||||
<span class="card-arch">Apple Silicon (arm64)</span>
|
||||
<span class="card-format">.dmg</span>
|
||||
</a>
|
||||
<a class="download-card" data-asset="x64.dmg" href={RELEASES_URL}>
|
||||
<a class="download-card" data-asset="x64.dmg" href="#">
|
||||
<span class="card-arch">Intel (x64)</span>
|
||||
<span class="card-format">.dmg</span>
|
||||
</a>
|
||||
@@ -36,7 +35,7 @@ import { RELEASES_URL } from "../lib/releases";
|
||||
<h2 class="platform-name">Windows</h2>
|
||||
</div>
|
||||
<div class="download-cards">
|
||||
<a class="download-card" data-asset="x64.exe" href={RELEASES_URL}>
|
||||
<a class="download-card" data-asset="x64.exe" href="#">
|
||||
<span class="card-arch">Windows 10, 11</span>
|
||||
<span class="card-format">.exe</span>
|
||||
</a>
|
||||
@@ -50,7 +49,7 @@ import { RELEASES_URL } from "../lib/releases";
|
||||
<h2 class="platform-name">Linux</h2>
|
||||
</div>
|
||||
<div class="download-cards">
|
||||
<a class="download-card" data-asset="x86_64.AppImage" href={RELEASES_URL}>
|
||||
<a class="download-card" data-asset="x86_64.AppImage" href="#">
|
||||
<span class="card-arch">x86_64</span>
|
||||
<span class="card-format">AppImage</span>
|
||||
</a>
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# Expo
|
||||
.expo/
|
||||
dist/
|
||||
web-build/
|
||||
expo-env.d.ts
|
||||
|
||||
# Native
|
||||
.kotlin/
|
||||
*.orig.*
|
||||
*.jks
|
||||
*.p8
|
||||
*.p12
|
||||
*.key
|
||||
*.mobileprovision
|
||||
|
||||
# Metro
|
||||
.metro-health-check*
|
||||
|
||||
# debug
|
||||
npm-debug.*
|
||||
yarn-debug.*
|
||||
yarn-error.*
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
|
||||
# generated native folders
|
||||
/ios
|
||||
/android
|
||||
@@ -1,65 +0,0 @@
|
||||
# T3 Code Mobile
|
||||
|
||||
> [!WARNING]
|
||||
> T3 Code Mobile is currently in development and is not distributed yet. If you want to try it out, you can build it from source.
|
||||
|
||||
## Quickstart
|
||||
|
||||
> [!NOTE]
|
||||
> Uses native modules so using Expo Go is not supported. You need to use the Expo Dev Client.
|
||||
|
||||
This app has three variants:
|
||||
|
||||
- `development`: Expo dev client, installable side-by-side as `T3 Code Dev`
|
||||
- `preview`: persistent internal preview build, installable side-by-side as `T3 Code Preview`
|
||||
- `production`: store/release build as `T3 Code`
|
||||
|
||||
Run commands from `apps/mobile`.
|
||||
|
||||
## Development
|
||||
|
||||
Start Metro for the dev client:
|
||||
|
||||
```bash
|
||||
bun run dev:client
|
||||
```
|
||||
|
||||
Build and run the local iOS dev client:
|
||||
|
||||
```bash
|
||||
bun run ios:dev
|
||||
```
|
||||
|
||||
Build and run the local iOS preview app:
|
||||
|
||||
```bash
|
||||
bun run ios:preview
|
||||
```
|
||||
|
||||
Inspect the resolved Expo config for a variant:
|
||||
|
||||
```bash
|
||||
bun run config:dev
|
||||
bun run config:preview
|
||||
```
|
||||
|
||||
## EAS Builds
|
||||
|
||||
Create a cloud dev-client build:
|
||||
|
||||
```bash
|
||||
bun run eas:ios:dev
|
||||
```
|
||||
|
||||
Create a persistent preview build:
|
||||
|
||||
```bash
|
||||
bun run eas:ios:preview
|
||||
```
|
||||
|
||||
Android equivalents:
|
||||
|
||||
```bash
|
||||
bun run eas:android:dev
|
||||
bun run eas:android:preview
|
||||
```
|
||||
@@ -1,130 +0,0 @@
|
||||
import type { ExpoConfig } from "expo/config";
|
||||
|
||||
type AppVariant = "development" | "preview" | "production";
|
||||
|
||||
const APP_VARIANT = resolveAppVariant(process.env.APP_VARIANT);
|
||||
|
||||
const VARIANT_CONFIG: Record<
|
||||
AppVariant,
|
||||
{
|
||||
readonly appName: string;
|
||||
readonly iosIcon: string;
|
||||
readonly iosBundleIdentifier: string;
|
||||
readonly androidPackage: string;
|
||||
}
|
||||
> = {
|
||||
development: {
|
||||
appName: "T3 Code Dev",
|
||||
iosIcon: "./assets/icon-composer-dev.icon",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.dev",
|
||||
androidPackage: "com.t3tools.t3code.dev",
|
||||
},
|
||||
preview: {
|
||||
appName: "T3 Code Preview",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
iosBundleIdentifier: "com.t3tools.t3code.preview",
|
||||
androidPackage: "com.t3tools.t3code.preview",
|
||||
},
|
||||
production: {
|
||||
appName: "T3 Code",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
iosBundleIdentifier: "com.t3tools.t3code",
|
||||
androidPackage: "com.t3tools.t3code",
|
||||
},
|
||||
};
|
||||
|
||||
function resolveAppVariant(value: string | undefined): AppVariant {
|
||||
switch (value) {
|
||||
case "development":
|
||||
case "preview":
|
||||
case "production":
|
||||
return value;
|
||||
default:
|
||||
return "production";
|
||||
}
|
||||
}
|
||||
|
||||
const variant = VARIANT_CONFIG[APP_VARIANT];
|
||||
|
||||
const config: ExpoConfig = {
|
||||
name: variant.appName,
|
||||
slug: "t3-code",
|
||||
scheme: "t3code",
|
||||
version: "0.1.0",
|
||||
runtimeVersion: {
|
||||
policy: "appVersion",
|
||||
},
|
||||
orientation: "portrait",
|
||||
icon: "./assets/icon.png",
|
||||
userInterfaceStyle: "automatic",
|
||||
updates: {
|
||||
enabled: true,
|
||||
url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
|
||||
checkAutomatically: "ON_LOAD",
|
||||
fallbackToCacheTimeout: 0,
|
||||
},
|
||||
splash: {
|
||||
image: "./assets/splash-icon.png",
|
||||
resizeMode: "contain",
|
||||
backgroundColor: "#ffffff",
|
||||
},
|
||||
ios: {
|
||||
icon: variant.iosIcon,
|
||||
supportsTablet: true,
|
||||
bundleIdentifier: variant.iosBundleIdentifier,
|
||||
infoPlist: {
|
||||
NSAppTransportSecurity: {
|
||||
NSAllowsArbitraryLoads: true,
|
||||
},
|
||||
ITSAppUsesNonExemptEncryption: false,
|
||||
},
|
||||
},
|
||||
android: {
|
||||
icon: "./assets/icon.png",
|
||||
package: variant.androidPackage,
|
||||
adaptiveIcon: {
|
||||
backgroundColor: "#E6F4FE",
|
||||
foregroundImage: "./assets/android-icon-foreground.png",
|
||||
backgroundImage: "./assets/android-icon-background.png",
|
||||
monochromeImage: "./assets/android-icon-monochrome.png",
|
||||
},
|
||||
predictiveBackGestureEnabled: false,
|
||||
},
|
||||
web: {
|
||||
favicon: "./assets/favicon.png",
|
||||
},
|
||||
plugins: [
|
||||
[
|
||||
"expo-camera",
|
||||
{
|
||||
cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
|
||||
barcodeScannerEnabled: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
image: "./assets/splash-icon.png",
|
||||
resizeMode: "contain",
|
||||
backgroundColor: "#ffffff",
|
||||
imageWidth: 220,
|
||||
dark: {
|
||||
image: "./assets/splash-icon.png",
|
||||
backgroundColor: "#0a0a0a",
|
||||
},
|
||||
},
|
||||
],
|
||||
"expo-secure-store",
|
||||
"expo-router",
|
||||
"./plugins/withAndroidCleartextTraffic.cjs",
|
||||
],
|
||||
extra: {
|
||||
appVariant: APP_VARIANT,
|
||||
eas: {
|
||||
projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
|
||||
},
|
||||
},
|
||||
owner: "pingdotgg",
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 74 KiB |
@@ -1,3 +0,0 @@
|
||||
<svg width="77" height="47" viewBox="0 0 77 47" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M14.56 45.5V8.58H1.69082e-06V-3.09944e-06H39.65V8.58H25.09V45.5H14.56ZM57.8454 46.28C54.6821 46.28 51.5404 45.8683 48.4204 45.045C45.3004 44.1783 42.6571 42.965 40.4904 41.405L44.5854 33.345C46.3188 34.6017 48.3338 35.5983 50.6304 36.335C52.9271 37.0717 55.2454 37.44 57.5854 37.44C60.2288 37.44 62.3088 36.92 63.8254 35.88C65.3421 34.84 66.1004 33.41 66.1004 31.59C66.1004 29.8567 65.4288 28.4917 64.0854 27.495C62.7421 26.4983 60.5754 26 57.5854 26H52.7754V19.045L65.4504 4.68L66.6204 8.45H42.7654V-3.09944e-06H74.6154V6.825L62.0054 21.19L56.6754 18.135H59.7304C65.3204 18.135 69.5454 19.3917 72.4054 21.905C75.2654 24.4183 76.6954 27.6467 76.6954 31.59C76.6954 34.1467 76.0238 36.5517 74.6804 38.805C73.3371 41.015 71.2788 42.8133 68.5054 44.2C65.7321 45.5867 62.1788 46.28 57.8454 46.28Z" fill="white"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 920 B |
|
Before Width: | Height: | Size: 10 MiB |
|
Before Width: | Height: | Size: 1.7 MiB |
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"fill": {
|
||||
"solid": "display-p3:0.00000,0.00000,0.00000,1.00000"
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"layers": [
|
||||
{
|
||||
"hidden": false,
|
||||
"image-name": "gpt-image-1.5-jd70szmrd03p36z4zv48ycsbax81egvr.png",
|
||||
"name": "gpt-image-1.5-jd70szmrd03p36z4zv48ycsbax81egvr",
|
||||
"position": {
|
||||
"scale": 1.1,
|
||||
"translation-in-points": [0, 0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"image-name": "T3.svg",
|
||||
"name": "T3",
|
||||
"position": {
|
||||
"scale": 10,
|
||||
"translation-in-points": [0, 0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"hidden": true,
|
||||
"image-name": "Texturelabs_Paper_381XL.jpg",
|
||||
"name": "Texturelabs_Paper_381XL"
|
||||
}
|
||||
],
|
||||
"shadow": {
|
||||
"kind": "neutral",
|
||||
"opacity": 0.5
|
||||
},
|
||||
"translucency": {
|
||||
"enabled": true,
|
||||
"value": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms": {
|
||||
"circles": ["watchOS"],
|
||||
"squares": "shared"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
<svg width="77" height="47" viewBox="0 0 77 47" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M14.56 45.5V8.58H1.69082e-06V-3.09944e-06H39.65V8.58H25.09V45.5H14.56ZM57.8454 46.28C54.6821 46.28 51.5404 45.8683 48.4204 45.045C45.3004 44.1783 42.6571 42.965 40.4904 41.405L44.5854 33.345C46.3188 34.6017 48.3338 35.5983 50.6304 36.335C52.9271 37.0717 55.2454 37.44 57.5854 37.44C60.2288 37.44 62.3088 36.92 63.8254 35.88C65.3421 34.84 66.1004 33.41 66.1004 31.59C66.1004 29.8567 65.4288 28.4917 64.0854 27.495C62.7421 26.4983 60.5754 26 57.5854 26H52.7754V19.045L65.4504 4.68L66.6204 8.45H42.7654V-3.09944e-06H74.6154V6.825L62.0054 21.19L56.6754 18.135H59.7304C65.3204 18.135 69.5454 19.3917 72.4054 21.905C75.2654 24.4183 76.6954 27.6467 76.6954 31.59C76.6954 34.1467 76.0238 36.5517 74.6804 38.805C73.3371 41.015 71.2788 42.8133 68.5054 44.2C65.7321 45.5867 62.1788 46.28 57.8454 46.28Z" fill="white"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 920 B |
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"fill": {
|
||||
"solid": "display-p3:0.00000,0.00000,0.00000,1.00000"
|
||||
},
|
||||
"groups": [
|
||||
{
|
||||
"layers": [
|
||||
{
|
||||
"image-name": "T3.svg",
|
||||
"name": "T3",
|
||||
"position": {
|
||||
"scale": 10,
|
||||
"translation-in-points": [0, 0]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow": {
|
||||
"kind": "neutral",
|
||||
"opacity": 0.5
|
||||
},
|
||||
"translucency": {
|
||||
"enabled": true,
|
||||
"value": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms": {
|
||||
"circles": ["watchOS"],
|
||||
"squares": "shared"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.0 MiB |
@@ -1,6 +0,0 @@
|
||||
module.exports = function (api) {
|
||||
api.cache(true);
|
||||
return {
|
||||
presets: [["babel-preset-expo", { unstable_transformImportMeta: true }]],
|
||||
};
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"cli": {
|
||||
"version": ">= 18.4.0",
|
||||
"appVersionSource": "remote"
|
||||
},
|
||||
"build": {
|
||||
"development": {
|
||||
"env": {
|
||||
"APP_VARIANT": "development"
|
||||
},
|
||||
"channel": "development",
|
||||
"developmentClient": true,
|
||||
"distribution": "internal"
|
||||
},
|
||||
"preview": {
|
||||
"env": {
|
||||
"APP_VARIANT": "preview"
|
||||
},
|
||||
"channel": "preview",
|
||||
"distribution": "internal"
|
||||
},
|
||||
"production": {
|
||||
"env": {
|
||||
"APP_VARIANT": "production"
|
||||
},
|
||||
"channel": "production",
|
||||
"autoIncrement": true
|
||||
}
|
||||
},
|
||||
"submit": {
|
||||
"production": {
|
||||
"ios": {
|
||||
"ascAppId": "6761315631"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
@import "tailwindcss";
|
||||
@import "uniwind";
|
||||
|
||||
/* ─── Theme tokens ──────────────────────────────────────────────────── */
|
||||
@layer theme {
|
||||
:root {
|
||||
@variant light {
|
||||
/* Page backgrounds */
|
||||
--color-screen: #f2f2f7;
|
||||
--color-sheet: rgba(242, 242, 247, 0.98);
|
||||
|
||||
/* Card / surface */
|
||||
--color-card: #ffffff;
|
||||
--color-card-alt: #f5f5f5;
|
||||
--color-card-translucent: rgba(255, 255, 255, 0.94);
|
||||
|
||||
/* Text */
|
||||
--color-foreground: #262626;
|
||||
--color-foreground-secondary: #525252;
|
||||
--color-foreground-muted: #737373;
|
||||
--color-foreground-tertiary: #a3a3a3;
|
||||
|
||||
/* Borders & separators */
|
||||
--color-border: rgba(0, 0, 0, 0.08);
|
||||
--color-border-subtle: rgba(0, 0, 0, 0.06);
|
||||
--color-separator: rgba(0, 0, 0, 0.04);
|
||||
|
||||
/* Subtle backgrounds (badges, pills, overlays) */
|
||||
--color-subtle: rgba(0, 0, 0, 0.04);
|
||||
--color-subtle-strong: rgba(0, 0, 0, 0.08);
|
||||
|
||||
/* Primary action */
|
||||
--color-primary: #262626;
|
||||
--color-primary-foreground: #ffffff;
|
||||
--color-primary-shadow: rgba(0, 0, 0, 0.18);
|
||||
|
||||
/* Secondary action */
|
||||
--color-secondary: #ffffff;
|
||||
--color-secondary-foreground: #262626;
|
||||
--color-secondary-border: rgba(0, 0, 0, 0.08);
|
||||
|
||||
/* Danger */
|
||||
--color-danger: #fef2f2;
|
||||
--color-danger-border: rgba(239, 68, 68, 0.12);
|
||||
--color-danger-foreground: #dc2626;
|
||||
|
||||
/* Inputs */
|
||||
--color-input: #ffffff;
|
||||
--color-input-border: rgba(0, 0, 0, 0.1);
|
||||
--color-placeholder: #a3a3a3;
|
||||
|
||||
/* Icons */
|
||||
--color-icon: #262626;
|
||||
--color-icon-muted: #525252;
|
||||
--color-icon-subtle: #a3a3a3;
|
||||
|
||||
/* Header / glass chrome */
|
||||
--color-header: rgba(255, 255, 255, 0.97);
|
||||
--color-header-border: rgba(0, 0, 0, 0.06);
|
||||
|
||||
/* StatusBar */
|
||||
--color-status-bar: #f2f2f7;
|
||||
|
||||
/* Markdown */
|
||||
--color-md-body: #262626;
|
||||
--color-md-strong: #171717;
|
||||
--color-md-link: #2563eb;
|
||||
--color-md-blockquote-border: rgba(0, 0, 0, 0.08);
|
||||
--color-md-blockquote-bg: rgba(0, 0, 0, 0.02);
|
||||
--color-md-code-bg: rgba(0, 0, 0, 0.04);
|
||||
--color-md-code-text: #262626;
|
||||
--color-md-user-code-bg: rgba(255, 255, 255, 0.55);
|
||||
--color-md-user-code-text: #262626;
|
||||
--color-md-user-fence-bg: rgba(0, 0, 0, 0.04);
|
||||
--color-md-user-fence-text: #1e3a5f;
|
||||
--color-md-hr: rgba(0, 0, 0, 0.08);
|
||||
|
||||
/* Drawer / modal backdrop */
|
||||
--color-backdrop: rgba(0, 0, 0, 0.22);
|
||||
--color-drawer: rgba(255, 255, 255, 0.99);
|
||||
--color-drawer-shadow: rgba(0, 0, 0, 0.12);
|
||||
|
||||
/* Misc */
|
||||
--color-dot-separator: rgba(0, 0, 0, 0.2);
|
||||
--color-wordmark: #262626;
|
||||
--color-chevron: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
@variant dark {
|
||||
/* Page backgrounds */
|
||||
--color-screen: #0a0a0a;
|
||||
--color-sheet: rgba(14, 14, 14, 0.98);
|
||||
|
||||
/* Card / surface */
|
||||
--color-card: #171717;
|
||||
--color-card-alt: #1c1c1c;
|
||||
--color-card-translucent: rgba(17, 17, 17, 0.94);
|
||||
|
||||
/* Text */
|
||||
--color-foreground: #f5f5f5;
|
||||
--color-foreground-secondary: #a3a3a3;
|
||||
--color-foreground-muted: #737373;
|
||||
--color-foreground-tertiary: #525252;
|
||||
|
||||
/* Borders & separators */
|
||||
--color-border: rgba(255, 255, 255, 0.06);
|
||||
--color-border-subtle: rgba(255, 255, 255, 0.04);
|
||||
--color-separator: rgba(255, 255, 255, 0.03);
|
||||
|
||||
/* Subtle backgrounds (badges, pills, overlays) */
|
||||
--color-subtle: rgba(255, 255, 255, 0.04);
|
||||
--color-subtle-strong: rgba(255, 255, 255, 0.08);
|
||||
|
||||
/* Primary action */
|
||||
--color-primary: #f5f5f5;
|
||||
--color-primary-foreground: #0a0a0a;
|
||||
--color-primary-shadow: rgba(0, 0, 0, 0.22);
|
||||
|
||||
/* Secondary action */
|
||||
--color-secondary: rgba(255, 255, 255, 0.04);
|
||||
--color-secondary-foreground: #f5f5f5;
|
||||
--color-secondary-border: rgba(255, 255, 255, 0.06);
|
||||
|
||||
/* Danger */
|
||||
--color-danger: rgba(239, 68, 68, 0.14);
|
||||
--color-danger-border: rgba(248, 113, 113, 0.18);
|
||||
--color-danger-foreground: #fca5a5;
|
||||
|
||||
/* Inputs */
|
||||
--color-input: #141414;
|
||||
--color-input-border: rgba(255, 255, 255, 0.08);
|
||||
--color-placeholder: #737373;
|
||||
|
||||
/* Icons */
|
||||
--color-icon: #f5f5f5;
|
||||
--color-icon-muted: #a3a3a3;
|
||||
--color-icon-subtle: #737373;
|
||||
|
||||
/* Header / glass chrome */
|
||||
--color-header: rgba(10, 10, 10, 0.97);
|
||||
--color-header-border: rgba(255, 255, 255, 0.06);
|
||||
|
||||
/* StatusBar */
|
||||
--color-status-bar: #0a0a0a;
|
||||
|
||||
/* Markdown */
|
||||
--color-md-body: #e5e5e5;
|
||||
--color-md-strong: #f5f5f5;
|
||||
--color-md-link: #60a5fa;
|
||||
--color-md-blockquote-border: rgba(255, 255, 255, 0.1);
|
||||
--color-md-blockquote-bg: rgba(255, 255, 255, 0.03);
|
||||
--color-md-code-bg: rgba(255, 255, 255, 0.06);
|
||||
--color-md-code-text: #e5e5e5;
|
||||
--color-md-user-code-bg: rgba(255, 255, 255, 0.1);
|
||||
--color-md-user-code-text: #e5e5e5;
|
||||
--color-md-user-fence-bg: rgba(255, 255, 255, 0.08);
|
||||
--color-md-user-fence-text: #e5e5e5;
|
||||
--color-md-hr: rgba(255, 255, 255, 0.08);
|
||||
|
||||
/* Drawer / modal backdrop */
|
||||
--color-backdrop: rgba(0, 0, 0, 0.48);
|
||||
--color-drawer: rgba(14, 14, 14, 0.99);
|
||||
--color-drawer-shadow: rgba(0, 0, 0, 0.32);
|
||||
|
||||
/* Misc */
|
||||
--color-dot-separator: rgba(255, 255, 255, 0.2);
|
||||
--color-wordmark: #f5f5f5;
|
||||
--color-chevron: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Font family ───────────────────────────────────────────────────── */
|
||||
@theme {
|
||||
--font-sans: "DMSans_400Regular";
|
||||
--font-medium: "DMSans_500Medium";
|
||||
--font-bold: "DMSans_700Bold";
|
||||
}
|
||||
|
||||
/* ─── Custom utilities ──────────────────────────────────────────────── */
|
||||
@utility font-t3-medium {
|
||||
font-family: "DMSans_500Medium";
|
||||
}
|
||||
|
||||
@utility font-t3-bold {
|
||||
font-family: "DMSans_700Bold";
|
||||
}
|
||||
|
||||
@utility font-t3-extrabold {
|
||||
font-family: "DMSans_700Bold";
|
||||
font-weight: 800;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
import "react-native-gesture-handler";
|
||||
import "expo-router/entry";
|
||||
@@ -1,14 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const { getDefaultConfig } = require("expo/metro-config");
|
||||
const { withUniwindConfig } = require("uniwind/metro");
|
||||
|
||||
/** @type {import("expo/metro-config").MetroConfig} */
|
||||
const config = getDefaultConfig(__dirname);
|
||||
const workspaceRoot = path.resolve(__dirname, "../..");
|
||||
|
||||
config.watchFolders = [...new Set([...(config.watchFolders ?? []), workspaceRoot])];
|
||||
|
||||
module.exports = withUniwindConfig(config, {
|
||||
cssEntryFile: "./global.css",
|
||||
polyfills: { rem: 14 },
|
||||
});
|
||||
@@ -1,88 +0,0 @@
|
||||
{
|
||||
"name": "@t3tools/mobile",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"dev": "expo start --clear",
|
||||
"dev:client": "APP_VARIANT=development expo start --dev-client --clear",
|
||||
"start": "expo start",
|
||||
"start:dev": "APP_VARIANT=development expo start",
|
||||
"start:preview": "APP_VARIANT=preview expo start",
|
||||
"start:prod": "APP_VARIANT=production expo start",
|
||||
"android": "EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && expo run:android",
|
||||
"android:dev": "APP_VARIANT=development EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && expo run:android",
|
||||
"android:preview": "APP_VARIANT=preview EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && expo run:android",
|
||||
"android:prod": "APP_VARIANT=production EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && expo run:android",
|
||||
"eas:android:dev": "eas build --profile development -p android",
|
||||
"eas:android:preview": "eas build --profile preview -p android",
|
||||
"eas:android:prod": "eas build --profile production -p android",
|
||||
"ios": "EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
|
||||
"ios:dev": "APP_VARIANT=development EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
|
||||
"ios:preview": "APP_VARIANT=preview EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
|
||||
"ios:prod": "APP_VARIANT=production EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform ios && expo run:ios",
|
||||
"eas:ios:dev": "eas build --profile development -p ios",
|
||||
"eas:ios:preview": "eas build --profile preview -p ios",
|
||||
"eas:ios:prod": "eas build --profile production -p ios",
|
||||
"eas:dev": "eas build --profile development",
|
||||
"eas:preview": "eas build --profile preview",
|
||||
"eas:prod": "eas build --profile production",
|
||||
"config:dev": "APP_VARIANT=development expo config",
|
||||
"config:preview": "APP_VARIANT=preview expo config",
|
||||
"config:prod": "APP_VARIANT=production expo config",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@callstack/liquid-glass": "^0.7.1",
|
||||
"@effect/atom-react": "catalog:",
|
||||
"@expo-google-fonts/dm-sans": "^0.4.2",
|
||||
"@legendapp/list": "3.0.0-beta.44",
|
||||
"@pierre/diffs": "^1.1.0-beta.16",
|
||||
"@react-native-menu/menu": "^2.0.0",
|
||||
"@t3tools/client-runtime": "workspace:*",
|
||||
"@t3tools/contracts": "workspace:*",
|
||||
"@t3tools/shared": "workspace:*",
|
||||
"clsx": "^2.1.1",
|
||||
"effect": "catalog:",
|
||||
"expo": "~55.0.14",
|
||||
"expo-camera": "~55.0.15",
|
||||
"expo-clipboard": "~55.0.9",
|
||||
"expo-constants": "^55.0.9",
|
||||
"expo-dev-client": "~55.0.26",
|
||||
"expo-file-system": "~55.0.16",
|
||||
"expo-font": "^55.0.4",
|
||||
"expo-glass-effect": "~55.0.8",
|
||||
"expo-haptics": "^55.0.9",
|
||||
"expo-image-picker": "~55.0.14",
|
||||
"expo-linking": "~55.0.12",
|
||||
"expo-paste-input": "^0.1.15",
|
||||
"expo-router": "~55.0.12",
|
||||
"expo-secure-store": "~55.0.9",
|
||||
"expo-splash-screen": "~55.0.13",
|
||||
"expo-symbols": "~55.0.5",
|
||||
"expo-updates": "~55.0.16",
|
||||
"punycode": "^2.3.1",
|
||||
"react": "19.2.5",
|
||||
"react-dom": "19.2.5",
|
||||
"react-native": "0.83.4",
|
||||
"react-native-gesture-handler": "~2.30.0",
|
||||
"react-native-image-viewing": "^0.2.2",
|
||||
"react-native-keyboard-controller": "1.20.7",
|
||||
"react-native-nitro-markdown": "^0.5.3",
|
||||
"react-native-nitro-modules": "^0.35.4",
|
||||
"react-native-reanimated": "4.2.1",
|
||||
"react-native-safe-area-context": "~5.6.2",
|
||||
"react-native-screens": "~4.23.0",
|
||||
"react-native-svg": "15.15.3",
|
||||
"react-native-worklets": "0.7.2",
|
||||
"shiki": "^4.0.2",
|
||||
"tailwind-merge": "^3.5.0",
|
||||
"uniwind": "^1.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "~19.2.0",
|
||||
"babel-preset-expo": "~55.0.8",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
const { withAndroidManifest } = require("expo/config-plugins");
|
||||
|
||||
module.exports = function withAndroidCleartextTraffic(config) {
|
||||
return withAndroidManifest(config, (nextConfig) => {
|
||||
const application = nextConfig.modResults.manifest.application?.[0];
|
||||
|
||||
if (application == null) {
|
||||
throw new Error(
|
||||
"AndroidManifest.xml is missing the application element required for cleartext traffic configuration.",
|
||||
);
|
||||
}
|
||||
|
||||
application.$ ??= {};
|
||||
application.$["android:usesCleartextTraffic"] = "true";
|
||||
|
||||
return nextConfig;
|
||||
});
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
import { Link } from "expo-router";
|
||||
import { Pressable, ScrollView, StyleSheet } from "react-native";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { AppText as Text } from "../components/AppText";
|
||||
|
||||
export default function NotFoundRoute() {
|
||||
const screenBgStyle = StyleSheet.flatten(useResolveClassNames("bg-screen"));
|
||||
const primaryBgStyle = StyleSheet.flatten(useResolveClassNames("bg-primary"));
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
contentContainerStyle={{
|
||||
flexGrow: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: 16,
|
||||
paddingHorizontal: 24,
|
||||
paddingVertical: 32,
|
||||
}}
|
||||
style={[{ flex: 1 }, screenBgStyle]}
|
||||
>
|
||||
<Text className="text-[28px] font-t3-bold text-foreground" selectable>
|
||||
Route not found
|
||||
</Text>
|
||||
<Link href="/" asChild>
|
||||
<Pressable
|
||||
style={[
|
||||
{
|
||||
borderRadius: 999,
|
||||
paddingHorizontal: 20,
|
||||
paddingVertical: 14,
|
||||
},
|
||||
primaryBgStyle,
|
||||
]}
|
||||
>
|
||||
<Text className="text-[16px] font-t3-bold text-primary-foreground">Return home</Text>
|
||||
</Pressable>
|
||||
</Link>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
import "../../global.css";
|
||||
import {
|
||||
DMSans_400Regular,
|
||||
DMSans_500Medium,
|
||||
DMSans_700Bold,
|
||||
useFonts,
|
||||
} from "@expo-google-fonts/dm-sans";
|
||||
import Stack from "expo-router/stack";
|
||||
import { StatusBar, useColorScheme } from "react-native";
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
import { KeyboardProvider } from "react-native-keyboard-controller";
|
||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||
import { useCSSVariable, useResolveClassNames } from "uniwind";
|
||||
|
||||
import { LoadingScreen } from "../components/LoadingScreen";
|
||||
|
||||
import {
|
||||
useRemoteEnvironmentBootstrap,
|
||||
useRemoteEnvironmentState,
|
||||
} from "../state/use-remote-environment-registry";
|
||||
import { RegistryContext } from "@effect/atom-react";
|
||||
import { appAtomRegistry } from "../state/atom-registry";
|
||||
|
||||
function AppNavigator() {
|
||||
const { isLoadingSavedConnection } = useRemoteEnvironmentState();
|
||||
const colorScheme = useColorScheme();
|
||||
const statusBarBg = useCSSVariable("--color-status-bar");
|
||||
const sheetStyle = useResolveClassNames("bg-sheet");
|
||||
|
||||
const newTaskScreenOptions = {
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.92],
|
||||
sheetGrabberVisible: true,
|
||||
};
|
||||
|
||||
const connectionSheetScreenOptions = {
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.55, 0.7],
|
||||
sheetGrabberVisible: true,
|
||||
};
|
||||
|
||||
if (isLoadingSavedConnection) {
|
||||
return <LoadingScreen message="Loading remote workspace…" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<StatusBar
|
||||
barStyle={colorScheme === "dark" ? "light-content" : "dark-content"}
|
||||
backgroundColor={statusBarBg as string}
|
||||
translucent
|
||||
/>
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerShadowVisible: false,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen name="connections" options={connectionSheetScreenOptions} />
|
||||
<Stack.Screen name="new" options={newTaskScreenOptions} />
|
||||
<Stack.Screen
|
||||
name="threads/[environmentId]/[threadId]"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
const [fontsLoaded] = useFonts({
|
||||
DMSans_400Regular,
|
||||
DMSans_500Medium,
|
||||
DMSans_700Bold,
|
||||
});
|
||||
useRemoteEnvironmentBootstrap();
|
||||
|
||||
return (
|
||||
<RegistryContext value={appAtomRegistry}>
|
||||
<GestureHandlerRootView style={{ flex: 1 }}>
|
||||
<KeyboardProvider statusBarTranslucent>
|
||||
<SafeAreaProvider>
|
||||
{fontsLoaded ? <AppNavigator /> : <LoadingScreen message="Loading remote workspace…" />}
|
||||
</SafeAreaProvider>
|
||||
</KeyboardProvider>
|
||||
</GestureHandlerRootView>
|
||||
</RegistryContext>
|
||||
);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import Stack from "expo-router/stack";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: "index",
|
||||
};
|
||||
|
||||
export default function ConnectionsLayout() {
|
||||
const contentStyle = useResolveClassNames("bg-sheet");
|
||||
const connSheetBg = String(useThemeColor("--color-sheet"));
|
||||
const headerTint = String(useThemeColor("--color-icon"));
|
||||
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={{
|
||||
contentStyle,
|
||||
headerStyle: { backgroundColor: connSheetBg },
|
||||
headerTintColor: headerTint,
|
||||
headerTitleStyle: { fontFamily: "DMSans_700Bold" },
|
||||
headerShadowVisible: false,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="index" options={{ animation: "none" }} />
|
||||
<Stack.Screen name="new" options={{ animation: "slide_from_right" }} />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
import { Link, Stack } from "expo-router";
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { ConnectionEnvironmentRow } from "../../features/connection/ConnectionEnvironmentRow";
|
||||
|
||||
export default function ConnectionsRouteScreen() {
|
||||
const {
|
||||
connectedEnvironments,
|
||||
onReconnectEnvironment,
|
||||
onRemoveEnvironmentPress,
|
||||
onUpdateEnvironment,
|
||||
} = useRemoteConnections();
|
||||
const insets = useSafeAreaInsets();
|
||||
const hasEnvironments = connectedEnvironments.length > 0;
|
||||
const [expandedId, setExpandedId] = useState<string | null>(null);
|
||||
|
||||
const primaryFg = useThemeColor("--color-primary-foreground");
|
||||
const accentColor = useThemeColor("--color-icon-muted");
|
||||
|
||||
const handleToggle = useCallback((environmentId: string) => {
|
||||
setExpandedId((prev) => (prev === environmentId ? null : environmentId));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: "Backends",
|
||||
headerRight: () => (
|
||||
<Link href="/connections/new" asChild>
|
||||
<Pressable className="h-10 w-10 items-center justify-center rounded-full bg-primary active:opacity-70">
|
||||
<SymbolView
|
||||
name="plus"
|
||||
size={18}
|
||||
tintColor={primaryFg}
|
||||
type="monochrome"
|
||||
weight="semibold"
|
||||
/>
|
||||
</Pressable>
|
||||
</Link>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={{ flex: 1 }}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: 16,
|
||||
paddingBottom: Math.max(insets.bottom, 18) + 18,
|
||||
}}
|
||||
>
|
||||
{hasEnvironments ? (
|
||||
<View collapsable={false} className="overflow-hidden rounded-[24px] bg-card">
|
||||
{connectedEnvironments.map((environment, index) => (
|
||||
<View
|
||||
key={environment.environmentId}
|
||||
collapsable={false}
|
||||
style={{
|
||||
borderTopWidth: index === 0 ? 0 : 1,
|
||||
}}
|
||||
className={cn(index !== 0 && "border-border")}
|
||||
>
|
||||
<ConnectionEnvironmentRow
|
||||
environment={environment}
|
||||
expanded={expandedId === environment.environmentId}
|
||||
onToggle={() => handleToggle(environment.environmentId)}
|
||||
onReconnect={onReconnectEnvironment}
|
||||
onRemove={onRemoveEnvironmentPress}
|
||||
onUpdate={onUpdateEnvironment}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
) : (
|
||||
<View collapsable={false} className="items-center gap-3 rounded-[24px] bg-card px-6 py-8">
|
||||
<View className="h-12 w-12 items-center justify-center rounded-[16px] bg-subtle">
|
||||
<SymbolView
|
||||
name="point.3.connected.trianglepath.dotted"
|
||||
size={20}
|
||||
tintColor={accentColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
</View>
|
||||
<Text className="text-center text-[14px] leading-[20px] text-foreground-muted">
|
||||
No backends connected yet.{"\n"}Tap{" "}
|
||||
<Text className="font-t3-bold text-foreground">+</Text> to add one.
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
import { CameraView, useCameraPermissions } from "expo-camera";
|
||||
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Alert, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { ErrorBanner } from "../../components/ErrorBanner";
|
||||
import { dismissRoute } from "../../lib/routes";
|
||||
import { ConnectionSheetButton } from "../../features/connection/ConnectionSheetButton";
|
||||
import { extractPairingUrlFromQrPayload } from "../../features/connection/pairing";
|
||||
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { buildPairingUrl, parsePairingUrl } from "../../features/connection/pairing";
|
||||
|
||||
export default function ConnectionsNewRouteScreen() {
|
||||
const {
|
||||
connectionError,
|
||||
connectionPairingUrl,
|
||||
connectionState,
|
||||
onChangeConnectionPairingUrl,
|
||||
onConnectPress,
|
||||
} = useRemoteConnections();
|
||||
const router = useRouter();
|
||||
const params = useLocalSearchParams<{ mode?: string }>();
|
||||
const insets = useSafeAreaInsets();
|
||||
const [hostInput, setHostInput] = useState("");
|
||||
const [codeInput, setCodeInput] = useState("");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [showScanner, setShowScanner] = useState(params.mode === "scan_qr");
|
||||
const [cameraPermission, requestCameraPermission] = useCameraPermissions();
|
||||
const [scannerLocked, setScannerLocked] = useState(false);
|
||||
|
||||
const textColor = useThemeColor("--color-icon");
|
||||
const placeholderColor = useThemeColor("--color-placeholder");
|
||||
|
||||
const connectDisabled =
|
||||
isSubmitting || connectionState === "connecting" || hostInput.trim().length === 0;
|
||||
|
||||
useEffect(() => {
|
||||
const { host, code } = parsePairingUrl(connectionPairingUrl);
|
||||
setHostInput(host);
|
||||
setCodeInput(code);
|
||||
}, [connectionPairingUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (connectionError) {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}, [connectionError]);
|
||||
|
||||
const handleHostChange = useCallback((value: string) => {
|
||||
setHostInput(value);
|
||||
}, []);
|
||||
|
||||
const handleCodeChange = useCallback((value: string) => {
|
||||
setCodeInput(value);
|
||||
}, []);
|
||||
|
||||
const openScanner = useCallback(async () => {
|
||||
if (cameraPermission?.granted) {
|
||||
setScannerLocked(false);
|
||||
setShowScanner(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const permission = await requestCameraPermission();
|
||||
if (permission.granted) {
|
||||
setScannerLocked(false);
|
||||
setShowScanner(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Alert.alert("Camera access needed", "Allow camera access to scan a backend pairing QR code.");
|
||||
}, [cameraPermission?.granted, requestCameraPermission]);
|
||||
|
||||
const closeScanner = useCallback(() => {
|
||||
setShowScanner(false);
|
||||
setScannerLocked(false);
|
||||
}, []);
|
||||
|
||||
const handleQrScan = useCallback(
|
||||
({ data }: { readonly data: string }) => {
|
||||
if (scannerLocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
setScannerLocked(true);
|
||||
|
||||
try {
|
||||
const pairingUrl = extractPairingUrlFromQrPayload(data);
|
||||
const { host, code } = parsePairingUrl(pairingUrl);
|
||||
setHostInput(host);
|
||||
setCodeInput(code);
|
||||
onChangeConnectionPairingUrl(pairingUrl);
|
||||
setShowScanner(false);
|
||||
} catch (error) {
|
||||
Alert.alert(
|
||||
"Invalid QR code",
|
||||
error instanceof Error ? error.message : "Scanned QR code was not recognized.",
|
||||
);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
setScannerLocked(false);
|
||||
}, 600);
|
||||
}
|
||||
},
|
||||
[onChangeConnectionPairingUrl, scannerLocked],
|
||||
);
|
||||
|
||||
const handleSubmit = useCallback(async () => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
const pairingUrl = buildPairingUrl(hostInput, codeInput);
|
||||
onChangeConnectionPairingUrl(pairingUrl);
|
||||
await onConnectPress(pairingUrl);
|
||||
dismissRoute(router);
|
||||
} catch {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}, [codeInput, hostInput, onChangeConnectionPairingUrl, onConnectPress, router]);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: showScanner ? "Scan QR Code" : "Add Backend",
|
||||
headerRight: () => (
|
||||
<Pressable
|
||||
className="h-10 w-10 items-center justify-center rounded-full border border-border bg-secondary"
|
||||
onPress={() => {
|
||||
if (showScanner) {
|
||||
closeScanner();
|
||||
} else {
|
||||
void openScanner();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SymbolView
|
||||
name={showScanner ? "xmark" : "qrcode.viewfinder"}
|
||||
size={showScanner ? 14 : 18}
|
||||
tintColor={textColor}
|
||||
type="monochrome"
|
||||
weight="semibold"
|
||||
/>
|
||||
</Pressable>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={{ flex: 1 }}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: 16,
|
||||
paddingBottom: Math.max(insets.bottom, 18) + 18,
|
||||
}}
|
||||
>
|
||||
<View collapsable={false} className="gap-5">
|
||||
{showScanner ? (
|
||||
cameraPermission?.granted ? (
|
||||
<View
|
||||
className="overflow-hidden rounded-[24px]"
|
||||
style={{ borderCurve: "continuous" }}
|
||||
>
|
||||
<CameraView
|
||||
barcodeScannerSettings={{ barcodeTypes: ["qr"] }}
|
||||
onBarcodeScanned={handleQrScan}
|
||||
style={{ aspectRatio: 1, width: "100%" }}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
className="items-center gap-3 rounded-[24px] bg-card px-5 py-8"
|
||||
style={{ borderCurve: "continuous" }}
|
||||
>
|
||||
<Text className="text-center text-[14px] leading-[20px] text-foreground-muted">
|
||||
Camera permission is required to scan a QR code.
|
||||
</Text>
|
||||
<ConnectionSheetButton
|
||||
compact
|
||||
icon="camera"
|
||||
label="Allow camera"
|
||||
tone="secondary"
|
||||
onPress={() => {
|
||||
void openScanner();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
) : (
|
||||
<View collapsable={false} className="gap-4 rounded-[24px] bg-card p-4">
|
||||
<View collapsable={false} className="gap-1.5">
|
||||
<Text
|
||||
className="text-[11px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
Host
|
||||
</Text>
|
||||
<TextInput
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
keyboardType="url"
|
||||
placeholder="192.168.1.100:8080"
|
||||
placeholderTextColor={placeholderColor}
|
||||
value={hostInput}
|
||||
onChangeText={handleHostChange}
|
||||
className="rounded-[14px] border border-input-border bg-input px-4 py-3.5 text-[15px] text-foreground"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View collapsable={false} className="gap-1.5">
|
||||
<Text
|
||||
className="text-[11px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
Pairing code
|
||||
</Text>
|
||||
<TextInput
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="abc-123-xyz"
|
||||
placeholderTextColor={placeholderColor}
|
||||
value={codeInput}
|
||||
onChangeText={handleCodeChange}
|
||||
className="rounded-[14px] border border-input-border bg-input px-4 py-3.5 text-[15px] text-foreground"
|
||||
/>
|
||||
</View>
|
||||
|
||||
{connectionError ? <ErrorBanner message={connectionError} /> : null}
|
||||
|
||||
<ConnectionSheetButton
|
||||
icon="plus"
|
||||
label={
|
||||
isSubmitting || connectionState === "connecting" ? "Pairing..." : "Add backend"
|
||||
}
|
||||
disabled={connectDisabled}
|
||||
tone="primary"
|
||||
onPress={() => {
|
||||
void handleSubmit();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
import { Stack, useRouter } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Pressable, Text as RNText, View, useColorScheme } from "react-native";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
import { buildThreadRoutePath } from "../lib/routes";
|
||||
import { ConnectionStatusDot } from "../features/connection/ConnectionStatusDot";
|
||||
import { useRemoteCatalog } from "../state/use-remote-catalog";
|
||||
import { useRemoteEnvironmentState } from "../state/use-remote-environment-registry";
|
||||
import { HomeScreen } from "../features/home/HomeScreen";
|
||||
import { EnvironmentConnectionState } from "@t3tools/client-runtime";
|
||||
|
||||
/* ─── Connection pill label ──────────────────────────────────────────── */
|
||||
|
||||
const CONNECTION_LABEL: Record<EnvironmentConnectionState, string> = {
|
||||
ready: "Connected",
|
||||
connecting: "Connecting",
|
||||
reconnecting: "Reconnecting",
|
||||
disconnected: "Offline",
|
||||
idle: "No backends",
|
||||
};
|
||||
|
||||
/* ─── Route screen ───────────────────────────────────────────────────── */
|
||||
|
||||
export default function HomeRouteScreen() {
|
||||
const { connectionState, hasRemoteActivity, projects, threads } = useRemoteCatalog();
|
||||
const { savedConnectionsById } = useRemoteEnvironmentState();
|
||||
const router = useRouter();
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
|
||||
const isDark = useColorScheme() === "dark";
|
||||
const iconColor = String(useThemeColor("--color-icon"));
|
||||
const secondaryFg = isDark ? "#a3a3a3" : "#525252";
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerShadowVisible: false,
|
||||
headerTintColor: iconColor,
|
||||
headerTitle: "",
|
||||
headerRight: () => (
|
||||
<Pressable
|
||||
onPress={() => router.push("/connections")}
|
||||
hitSlop={8}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 8,
|
||||
paddingHorizontal: 4,
|
||||
paddingVertical: 4,
|
||||
}}
|
||||
>
|
||||
<ConnectionStatusDot state={connectionState} pulse={hasRemoteActivity} size={7} />
|
||||
<RNText
|
||||
style={{
|
||||
fontFamily: "DMSans_700Bold",
|
||||
fontSize: 12,
|
||||
color: secondaryFg,
|
||||
}}
|
||||
>
|
||||
{CONNECTION_LABEL[connectionState]}
|
||||
</RNText>
|
||||
</Pressable>
|
||||
),
|
||||
headerSearchBarOptions: {
|
||||
placeholder: "Search threads",
|
||||
onChangeText: (event) => {
|
||||
setSearchQuery(event.nativeEvent.text);
|
||||
},
|
||||
allowToolbarIntegration: true,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Header left: plain text, no Liquid Glass button chrome */}
|
||||
<Stack.Toolbar placement="left">
|
||||
<Stack.Toolbar.View hidesSharedBackground>
|
||||
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
||||
<RNText
|
||||
style={{
|
||||
fontFamily: "DMSans_700Bold",
|
||||
fontSize: 17,
|
||||
color: iconColor,
|
||||
letterSpacing: -0.4,
|
||||
}}
|
||||
>
|
||||
T3 Code
|
||||
</RNText>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: isDark ? "rgba(255,255,255,0.04)" : "rgba(0,0,0,0.04)",
|
||||
borderRadius: 99,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 3,
|
||||
}}
|
||||
>
|
||||
<RNText
|
||||
style={{
|
||||
fontFamily: "DMSans_700Bold",
|
||||
fontSize: 10,
|
||||
color: "#737373",
|
||||
letterSpacing: 1.1,
|
||||
textTransform: "uppercase",
|
||||
}}
|
||||
>
|
||||
Alpha
|
||||
</RNText>
|
||||
</View>
|
||||
</View>
|
||||
</Stack.Toolbar.View>
|
||||
</Stack.Toolbar>
|
||||
|
||||
{/* Bottom toolbar: search + compose, visually split like iMessage */}
|
||||
<Stack.Toolbar placement="bottom">
|
||||
<Stack.Toolbar.SearchBarSlot />
|
||||
<Stack.Toolbar.Spacer width={8} sharesBackground={false} />
|
||||
<Stack.Toolbar.Button
|
||||
icon="square.and.pencil"
|
||||
onPress={() => router.push("/new")}
|
||||
separateBackground
|
||||
/>
|
||||
</Stack.Toolbar>
|
||||
|
||||
<HomeScreen
|
||||
projects={projects}
|
||||
threads={threads}
|
||||
savedConnectionsById={savedConnectionsById}
|
||||
searchQuery={searchQuery}
|
||||
onSelectThread={(thread) => {
|
||||
router.push(buildThreadRoutePath(thread));
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import Stack from "expo-router/stack";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { NewTaskFlowProvider } from "../../features/threads/new-task-flow-provider";
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: "index",
|
||||
};
|
||||
|
||||
export default function NewTaskLayout() {
|
||||
const sheetStyle = useResolveClassNames("bg-sheet");
|
||||
|
||||
return (
|
||||
<NewTaskFlowProvider>
|
||||
<Stack
|
||||
screenOptions={{
|
||||
contentStyle: sheetStyle,
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="index" options={{ animation: "none" }} />
|
||||
<Stack.Screen name="draft" options={{ animation: "slide_from_right" }} />
|
||||
</Stack>
|
||||
</NewTaskFlowProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { Stack, useLocalSearchParams } from "expo-router";
|
||||
|
||||
import { NewTaskDraftScreen } from "../../features/threads/NewTaskDraftScreen";
|
||||
|
||||
export default function NewTaskDraftRoute() {
|
||||
const params = useLocalSearchParams<{
|
||||
environmentId?: string | string[];
|
||||
projectId?: string | string[];
|
||||
}>();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen options={{ headerShown: false }} />
|
||||
<NewTaskDraftScreen
|
||||
initialProjectRef={{
|
||||
environmentId: Array.isArray(params.environmentId)
|
||||
? params.environmentId[0]
|
||||
: params.environmentId,
|
||||
projectId: Array.isArray(params.projectId) ? params.projectId[0] : params.projectId,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
import { Link, Stack } from "expo-router";
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useMemo } from "react";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { ProjectFavicon } from "../../components/ProjectFavicon";
|
||||
import { groupProjectsByRepository } from "../../lib/repositoryGroups";
|
||||
import { useRemoteCatalog } from "../../state/use-remote-catalog";
|
||||
import { useRemoteEnvironmentState } from "../../state/use-remote-environment-registry";
|
||||
|
||||
export default function NewTaskRoute() {
|
||||
const { projects, threads } = useRemoteCatalog();
|
||||
const { savedConnectionsById } = useRemoteEnvironmentState();
|
||||
const insets = useSafeAreaInsets();
|
||||
const chevronColor = useThemeColor("--color-chevron");
|
||||
const borderSubtleColor = useThemeColor("--color-border-subtle");
|
||||
const repositoryGroups = useMemo(
|
||||
() => groupProjectsByRepository({ projects, threads }),
|
||||
[projects, threads],
|
||||
);
|
||||
const items = useMemo(
|
||||
() =>
|
||||
repositoryGroups
|
||||
.map((group) => {
|
||||
const project = group.projects[0]?.project;
|
||||
if (!project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
environmentId: project.environmentId,
|
||||
id: project.id,
|
||||
key: group.key,
|
||||
title: project.title,
|
||||
workspaceRoot: project.workspaceRoot,
|
||||
};
|
||||
})
|
||||
.filter((entry) => entry !== null),
|
||||
[repositoryGroups],
|
||||
);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<Stack.Screen options={{ headerShown: false }} />
|
||||
|
||||
<View style={{ minHeight: 16, paddingTop: 8 }} />
|
||||
|
||||
<View className="items-center gap-1 px-5 pb-3 pt-4">
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 1 }}
|
||||
>
|
||||
New task
|
||||
</Text>
|
||||
<Text className="text-[28px] font-t3-bold">Choose project</Text>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={{ flex: 1 }}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: 8,
|
||||
paddingBottom: Math.max(insets.bottom, 18) + 18,
|
||||
}}
|
||||
>
|
||||
{items.length === 0 ? (
|
||||
<View collapsable={false} className="items-center rounded-[24px] bg-card px-6 py-8">
|
||||
<Text className="text-[16px] font-medium text-foreground-muted">
|
||||
Loading projects...
|
||||
</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View collapsable={false} className="overflow-hidden rounded-[24px] bg-card">
|
||||
{items.map((item, index) => {
|
||||
const isFirst = index === 0;
|
||||
const isLast = index === items.length - 1;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.key}
|
||||
href={{
|
||||
pathname: "/new/draft",
|
||||
params: {
|
||||
environmentId: item.environmentId,
|
||||
projectId: item.id,
|
||||
title: item.title,
|
||||
},
|
||||
}}
|
||||
asChild
|
||||
>
|
||||
<Pressable
|
||||
className="bg-card"
|
||||
style={{
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 18,
|
||||
borderTopWidth: isFirst ? 0 : 1,
|
||||
borderTopColor: borderSubtleColor,
|
||||
borderTopLeftRadius: isFirst ? 24 : 0,
|
||||
borderTopRightRadius: isFirst ? 24 : 0,
|
||||
borderBottomLeftRadius: isLast ? 24 : 0,
|
||||
borderBottomRightRadius: isLast ? 24 : 0,
|
||||
}}
|
||||
>
|
||||
<View className="flex-row items-center justify-between gap-3">
|
||||
<ProjectFavicon
|
||||
size={22}
|
||||
projectTitle={item.title}
|
||||
httpBaseUrl={savedConnectionsById[item.environmentId]?.httpBaseUrl ?? null}
|
||||
workspaceRoot={item.workspaceRoot}
|
||||
bearerToken={savedConnectionsById[item.environmentId]?.bearerToken ?? null}
|
||||
/>
|
||||
<View className="flex-1">
|
||||
<Text className="text-[18px] font-t3-bold">{item.title}</Text>
|
||||
</View>
|
||||
<SymbolView
|
||||
name="chevron.right"
|
||||
size={14}
|
||||
tintColor={chevronColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
</View>
|
||||
</Pressable>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
import Stack from "expo-router/stack";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
export default function ThreadLayout() {
|
||||
const sheetStyle = StyleSheet.flatten(useResolveClassNames("bg-sheet"));
|
||||
const headerBg = {
|
||||
backgroundColor: (sheetStyle as { backgroundColor?: string })?.backgroundColor,
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerShadowVisible: false,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="git"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.85],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="git-confirm"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.4],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
contentStyle: sheetStyle,
|
||||
headerShown: true,
|
||||
headerTitle: "Files changed",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review-comment"
|
||||
options={{
|
||||
contentStyle: sheetStyle,
|
||||
gestureEnabled: true,
|
||||
headerShown: false,
|
||||
presentation: "formSheet" as const,
|
||||
sheetAllowedDetents: [0.72, 0.92],
|
||||
sheetGrabberVisible: true,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { GitConfirmSheet } from "../../../../features/threads/git/GitConfirmSheet";
|
||||
|
||||
export default function GitConfirmRoute() {
|
||||
return <GitConfirmSheet />;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import Stack from "expo-router/stack";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: "index",
|
||||
};
|
||||
|
||||
export default function GitSheetLayout() {
|
||||
const sheetStyle = StyleSheet.flatten(useResolveClassNames("bg-sheet"));
|
||||
const headerBg = {
|
||||
backgroundColor: (sheetStyle as { backgroundColor?: string })?.backgroundColor,
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack
|
||||
screenOptions={{
|
||||
contentStyle: sheetStyle,
|
||||
headerShown: false,
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="index" options={{ animation: "none" }} />
|
||||
<Stack.Screen
|
||||
name="commit"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
headerShown: true,
|
||||
headerTitle: "Commit changes",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="branches"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
headerShown: true,
|
||||
headerTitle: "Branches & worktrees",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="review"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
headerShown: true,
|
||||
headerTitle: "Review changes",
|
||||
headerBackTitle: "",
|
||||
headerShadowVisible: false,
|
||||
headerStyle: headerBg,
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { GitBranchesSheet } from "../../../../../features/threads/git/GitBranchesSheet";
|
||||
|
||||
export default function GitBranchesRoute() {
|
||||
return <GitBranchesSheet />;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { GitCommitSheet } from "../../../../../features/threads/git/GitCommitSheet";
|
||||
|
||||
export default function GitCommitRoute() {
|
||||
return <GitCommitSheet />;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { GitOverviewSheet } from "../../../../../features/threads/git/GitOverviewSheet";
|
||||
|
||||
export default function GitRoute() {
|
||||
return <GitOverviewSheet />;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Redirect, useLocalSearchParams } from "expo-router";
|
||||
|
||||
export default function ReviewRoute() {
|
||||
const { environmentId, threadId } = useLocalSearchParams<{
|
||||
environmentId: string;
|
||||
threadId: string;
|
||||
}>();
|
||||
|
||||
return (
|
||||
<Redirect
|
||||
href={{
|
||||
pathname: "/threads/[environmentId]/[threadId]/review",
|
||||
params: { environmentId, threadId },
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { ThreadRouteScreen } from "../../../../features/threads/ThreadRouteScreen";
|
||||
|
||||
export default function ThreadRoute() {
|
||||
return <ThreadRouteScreen />;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { ReviewCommentComposerSheet } from "../../../../features/threads/review/ReviewCommentComposerSheet";
|
||||
|
||||
export default function ReviewCommentRoute() {
|
||||
return <ReviewCommentComposerSheet />;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { ReviewSheet } from "../../../../features/threads/review/ReviewSheet";
|
||||
|
||||
export default function ReviewRoute() {
|
||||
return <ReviewSheet />;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import {
|
||||
Text as RNText,
|
||||
TextInput as RNTextInput,
|
||||
type TextInputProps as RNTextInputProps,
|
||||
type TextProps as RNTextProps,
|
||||
} from "react-native";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
import { cn } from "../lib/cn";
|
||||
|
||||
export type AppTextProps = RNTextProps & { readonly className?: string };
|
||||
|
||||
/**
|
||||
* Thin wrapper around RN Text with default font-family and foreground color.
|
||||
* Uses Uniwind className — no manual style parsing.
|
||||
*/
|
||||
export function AppText({ className, ...props }: AppTextProps) {
|
||||
return <RNText className={cn("font-sans text-foreground", className)} {...props} />;
|
||||
}
|
||||
|
||||
export type AppTextInputProps = RNTextInputProps & { readonly className?: string };
|
||||
|
||||
/**
|
||||
* Thin wrapper around RN TextInput with default input styling.
|
||||
* Uses Uniwind className — no manual style parsing.
|
||||
*/
|
||||
export function AppTextInput({ className, placeholderTextColor, ...props }: AppTextInputProps) {
|
||||
const placeholderColor = useThemeColor("--color-placeholder");
|
||||
|
||||
return (
|
||||
<RNTextInput
|
||||
className={cn(
|
||||
"min-h-[54px] rounded-2xl border border-input-border bg-input px-3.5 py-3 font-sans text-[15px] text-foreground",
|
||||
className,
|
||||
)}
|
||||
placeholderTextColor={placeholderTextColor ?? placeholderColor}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { Image, View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
|
||||
const BRAND_MARK_SOURCE = require("../../../../assets/dev/blueprint-ios-1024.png");
|
||||
|
||||
export function BrandMark(props: { readonly compact?: boolean; readonly stageLabel?: string }) {
|
||||
const compact = props.compact ?? false;
|
||||
const iconSize = compact ? 32 : 44;
|
||||
const stageLabel = props.stageLabel ?? "Alpha";
|
||||
|
||||
return (
|
||||
<View className="flex-row items-center gap-3">
|
||||
<Image
|
||||
source={BRAND_MARK_SOURCE}
|
||||
accessibilityIgnoresInvertColors
|
||||
style={{
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
borderRadius: compact ? 10 : 14,
|
||||
}}
|
||||
/>
|
||||
<View className="gap-1">
|
||||
<View className="flex-row items-center gap-2">
|
||||
<Text
|
||||
className="text-[17px] font-t3-bold text-foreground"
|
||||
style={{ letterSpacing: -0.4 }}
|
||||
>
|
||||
T3 Code
|
||||
</Text>
|
||||
<View className="rounded-full bg-subtle px-2 py-1">
|
||||
<Text
|
||||
className="text-[10px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 1.1 }}
|
||||
>
|
||||
{stageLabel}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
{!compact ? (
|
||||
<Text className="text-[12px] font-medium text-foreground-muted">
|
||||
Mobile control surface for your live coding environments
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { Image, Pressable, ScrollView, View } from "react-native";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
import type { DraftComposerImageAttachment } from "../lib/composerImages";
|
||||
|
||||
export interface ComposerAttachmentStripProps {
|
||||
/** Attachment images to display. */
|
||||
readonly attachments: ReadonlyArray<DraftComposerImageAttachment>;
|
||||
/** Called when the user taps the remove button on an image. */
|
||||
readonly onRemove: (imageId: string) => void;
|
||||
/** Called when the user taps on an image thumbnail to preview it. */
|
||||
readonly onPressImage?: (previewUri: string) => void;
|
||||
/** Image thumbnail size in points. Defaults to 72. */
|
||||
readonly imageSize?: number;
|
||||
/** Border radius of each image thumbnail. Defaults to 16. */
|
||||
readonly imageBorderRadius?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A horizontally-scrollable strip of image attachment thumbnails with remove
|
||||
* buttons. Used by both the thread composer and the new-task draft screen.
|
||||
*/
|
||||
export function ComposerAttachmentStrip(props: ComposerAttachmentStripProps) {
|
||||
const subtleBg = useThemeColor("--color-subtle");
|
||||
const size = props.imageSize ?? 72;
|
||||
const radius = props.imageBorderRadius ?? 16;
|
||||
|
||||
if (props.attachments.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="always"
|
||||
style={{ flexGrow: 0 }}
|
||||
>
|
||||
<View style={{ flexDirection: "row", gap: 10 }}>
|
||||
{props.attachments.map((image) => (
|
||||
<View key={image.id} style={{ position: "relative" }}>
|
||||
<Pressable
|
||||
onPress={props.onPressImage ? () => props.onPressImage!(image.previewUri) : undefined}
|
||||
>
|
||||
<Image
|
||||
source={{ uri: image.previewUri }}
|
||||
style={{
|
||||
width: size,
|
||||
height: size,
|
||||
borderRadius: radius,
|
||||
backgroundColor: subtleBg,
|
||||
}}
|
||||
resizeMode="cover"
|
||||
/>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 4,
|
||||
right: 4,
|
||||
width: 22,
|
||||
height: 22,
|
||||
borderRadius: 11,
|
||||
backgroundColor: "rgba(0,0,0,0.55)",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
hitSlop={6}
|
||||
onPress={() => props.onRemove(image.id)}
|
||||
>
|
||||
<SymbolView
|
||||
name="xmark"
|
||||
size={9}
|
||||
tintColor="#ffffff"
|
||||
type="monochrome"
|
||||
weight="bold"
|
||||
/>
|
||||
</Pressable>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
import { Pressable, View } from "react-native";
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
import { cn } from "../lib/cn";
|
||||
import { AppText as Text } from "./AppText";
|
||||
|
||||
export function ControlPill(props: {
|
||||
readonly icon?: ComponentProps<typeof SymbolView>["name"];
|
||||
readonly iconNode?: ReactNode;
|
||||
readonly label?: string;
|
||||
readonly onPress?: () => void;
|
||||
readonly variant?: "circle" | "pill" | "primary" | "danger";
|
||||
readonly disabled?: boolean;
|
||||
}) {
|
||||
const variant = props.variant ?? "circle";
|
||||
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const iconSubtle = useThemeColor("--color-icon-subtle");
|
||||
const primaryFg = useThemeColor("--color-primary-foreground");
|
||||
const dangerFg = useThemeColor("--color-danger-foreground");
|
||||
const iconTintColor =
|
||||
variant === "primary"
|
||||
? props.disabled
|
||||
? iconSubtle
|
||||
: primaryFg
|
||||
: variant === "danger"
|
||||
? dangerFg
|
||||
: iconColor;
|
||||
|
||||
const isCircle =
|
||||
variant === "circle" || variant === "danger" || (variant === "primary" && !props.label);
|
||||
const containerClassName = cn(
|
||||
isCircle
|
||||
? "h-11 w-11 items-center justify-center rounded-full"
|
||||
: variant === "primary"
|
||||
? "h-11 flex-row items-center justify-center gap-2 rounded-full px-5"
|
||||
: "h-11 flex-row items-center justify-center gap-2 rounded-full px-3.5",
|
||||
variant === "primary"
|
||||
? props.disabled
|
||||
? "bg-subtle-strong"
|
||||
: "bg-primary"
|
||||
: variant === "danger"
|
||||
? "bg-danger"
|
||||
: "bg-subtle",
|
||||
);
|
||||
const labelClassName = cn(
|
||||
"text-center text-[12px] font-t3-bold",
|
||||
variant === "primary"
|
||||
? props.disabled
|
||||
? "text-foreground-muted"
|
||||
: "text-primary-foreground"
|
||||
: "",
|
||||
);
|
||||
|
||||
return (
|
||||
<Pressable onPress={props.onPress} disabled={props.disabled} className={containerClassName}>
|
||||
{props.iconNode ? (
|
||||
<View className="h-4 w-4 items-center justify-center">{props.iconNode}</View>
|
||||
) : props.icon ? (
|
||||
<SymbolView name={props.icon} size={16} tintColor={iconTintColor} type="monochrome" />
|
||||
) : null}
|
||||
{props.label ? <Text className={labelClassName}>{props.label}</Text> : null}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
|
||||
export function EmptyState(props: { readonly title: string; readonly detail: string }) {
|
||||
return (
|
||||
<View className="rounded-[22px] border border-border bg-card p-5">
|
||||
<Text className="font-t3-bold text-lg text-foreground">{props.title}</Text>
|
||||
<Text className="mt-2 font-sans text-sm leading-[21px] text-foreground-muted">
|
||||
{props.detail}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
export function ErrorBanner(props: { readonly message: string }) {
|
||||
return (
|
||||
<View className="rounded-2xl border border-rose-300/70 bg-rose-100/80 px-3.5 py-3 dark:border-rose-400/28 dark:bg-rose-500/12">
|
||||
<Text className="font-t3-medium text-[13px] leading-[18px] text-rose-700 dark:text-rose-300">
|
||||
{props.message}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useColorScheme, View, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { GlassSurface } from "./GlassSurface";
|
||||
|
||||
export interface GlassSafeAreaViewProps {
|
||||
readonly leftSlot?: ReactNode;
|
||||
readonly centerSlot?: ReactNode;
|
||||
readonly rightSlot?: ReactNode;
|
||||
readonly style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
export function GlassSafeAreaView({
|
||||
leftSlot,
|
||||
centerSlot,
|
||||
rightSlot,
|
||||
style,
|
||||
}: GlassSafeAreaViewProps) {
|
||||
const isDarkMode = useColorScheme() === "dark";
|
||||
const insets = useSafeAreaInsets();
|
||||
const headerPaddingTop = insets.top + 16;
|
||||
const surfaceStyle = {
|
||||
borderRadius: 0,
|
||||
backgroundColor: isDarkMode ? "rgba(10,10,10,0.97)" : "rgba(255,255,255,0.97)",
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: isDarkMode ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.06)",
|
||||
} as const;
|
||||
|
||||
return (
|
||||
<View style={[surfaceStyle, style]}>
|
||||
<GlassSurface
|
||||
chrome="none"
|
||||
glassEffectStyle="regular"
|
||||
tintColor={isDarkMode ? "rgba(15,23,42,0.24)" : "rgba(255,255,255,0.18)"}
|
||||
style={{ borderRadius: 0, backgroundColor: "transparent" }}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: headerPaddingTop,
|
||||
paddingBottom: 16,
|
||||
gap: 10,
|
||||
}}
|
||||
>
|
||||
<View style={{ alignItems: "flex-start", justifyContent: "center" }}>{leftSlot}</View>
|
||||
<View
|
||||
style={{ flex: 1, alignItems: "center", justifyContent: "center", overflow: "hidden" }}
|
||||
>
|
||||
{centerSlot}
|
||||
</View>
|
||||
<View style={{ alignItems: "flex-end", justifyContent: "center" }}>{rightSlot}</View>
|
||||
</View>
|
||||
</GlassSurface>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import { GlassView, isGlassEffectAPIAvailable } from "expo-glass-effect";
|
||||
import type { ReactNode } from "react";
|
||||
import { Platform, useColorScheme, View, type ViewProps, type ViewStyle } from "react-native";
|
||||
|
||||
export interface GlassSurfaceProps extends ViewProps {
|
||||
readonly children: ReactNode;
|
||||
readonly glassEffectStyle?: "clear" | "regular" | "none";
|
||||
readonly tintColor?: string;
|
||||
readonly chrome?: "default" | "none";
|
||||
}
|
||||
|
||||
export function GlassSurface({
|
||||
children,
|
||||
glassEffectStyle = "regular",
|
||||
chrome = "default",
|
||||
tintColor,
|
||||
style,
|
||||
...props
|
||||
}: GlassSurfaceProps) {
|
||||
const isDarkMode = useColorScheme() === "dark";
|
||||
const supportsGlass = Platform.OS === "ios" && isGlassEffectAPIAvailable();
|
||||
const surfaceStyle: ViewStyle = {
|
||||
borderRadius: 32,
|
||||
overflow: "hidden",
|
||||
borderWidth: chrome === "none" ? 0 : 1,
|
||||
borderColor:
|
||||
chrome === "none"
|
||||
? "transparent"
|
||||
: isDarkMode
|
||||
? "rgba(255,255,255,0.08)"
|
||||
: "rgba(226,232,240,0.9)",
|
||||
backgroundColor:
|
||||
chrome === "none"
|
||||
? "transparent"
|
||||
: isDarkMode
|
||||
? "rgba(15,23,42,0.78)"
|
||||
: "rgba(255,255,255,0.72)",
|
||||
shadowColor: chrome === "none" ? "transparent" : "#020617",
|
||||
shadowOpacity: chrome === "none" ? 0 : isDarkMode ? 0.22 : 0.08,
|
||||
shadowRadius: chrome === "none" ? 0 : 28,
|
||||
shadowOffset:
|
||||
chrome === "none"
|
||||
? {
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
: {
|
||||
width: 0,
|
||||
height: 14,
|
||||
},
|
||||
elevation: chrome === "none" ? 0 : 12,
|
||||
};
|
||||
|
||||
if (supportsGlass) {
|
||||
return (
|
||||
<GlassView
|
||||
{...props}
|
||||
glassEffectStyle={glassEffectStyle}
|
||||
tintColor={tintColor ?? (isDarkMode ? "rgba(15,23,42,0.18)" : "rgba(255,255,255,0.18)")}
|
||||
colorScheme={isDarkMode ? "dark" : "light"}
|
||||
style={[surfaceStyle, style]}
|
||||
>
|
||||
{children}
|
||||
</GlassView>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View {...props} style={[surfaceStyle, style]}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import { ActivityIndicator, StatusBar, View, useColorScheme } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
import { BrandMark } from "./BrandMark";
|
||||
|
||||
export function LoadingScreen(props: { readonly message: string }) {
|
||||
const colorScheme = useColorScheme();
|
||||
const screenBg = useThemeColor("--color-screen");
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-screen" style={{ paddingTop: insets.top }}>
|
||||
<StatusBar
|
||||
barStyle={colorScheme === "dark" ? "light-content" : "dark-content"}
|
||||
backgroundColor={screenBg as string}
|
||||
translucent
|
||||
/>
|
||||
<View className="flex-1 items-center justify-center gap-5 px-6">
|
||||
<BrandMark compact />
|
||||
<ActivityIndicator size="large" />
|
||||
<Text className="font-t3-bold text-lg text-foreground">{props.message}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useState } from "react";
|
||||
import { Image, View } from "react-native";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
/* ─── Favicon cache (matches web pattern) ────────────────────────────── */
|
||||
const loadedFaviconUrls = new Set<string>();
|
||||
|
||||
/* ─── Component ──────────────────────────────────────────────────────── */
|
||||
export function ProjectFavicon(props: {
|
||||
readonly size?: number;
|
||||
readonly projectTitle: string;
|
||||
readonly httpBaseUrl?: string | null;
|
||||
readonly workspaceRoot?: string | null;
|
||||
readonly bearerToken?: string | null;
|
||||
}) {
|
||||
const size = props.size ?? 42;
|
||||
const iconMuted = useThemeColor("--color-icon-subtle");
|
||||
|
||||
const faviconUrl =
|
||||
props.httpBaseUrl && props.workspaceRoot
|
||||
? `${props.httpBaseUrl}/api/project-favicon?cwd=${encodeURIComponent(props.workspaceRoot)}`
|
||||
: null;
|
||||
|
||||
const [status, setStatus] = useState<"loading" | "loaded" | "error">(() =>
|
||||
faviconUrl && loadedFaviconUrls.has(faviconUrl) ? "loaded" : "loading",
|
||||
);
|
||||
|
||||
const showImage = faviconUrl && status === "loaded";
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
width: size,
|
||||
height: size,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
{/* Folder icon fallback (matches web's FolderIcon) */}
|
||||
{!showImage ? (
|
||||
<SymbolView name="folder.fill" size={size * 0.78} tintColor={iconMuted} type="monochrome" />
|
||||
) : null}
|
||||
|
||||
{/* Favicon image (hidden until loaded) */}
|
||||
{faviconUrl ? (
|
||||
<Image
|
||||
source={{
|
||||
uri: faviconUrl,
|
||||
...(props.bearerToken
|
||||
? { headers: { Authorization: `Bearer ${props.bearerToken}` } }
|
||||
: {}),
|
||||
}}
|
||||
style={{
|
||||
width: size,
|
||||
height: size,
|
||||
borderRadius: size * 0.16,
|
||||
...(showImage ? {} : { position: "absolute" as const, opacity: 0 }),
|
||||
}}
|
||||
resizeMode="contain"
|
||||
onLoad={() => {
|
||||
if (faviconUrl) loadedFaviconUrls.add(faviconUrl);
|
||||
setStatus("loaded");
|
||||
}}
|
||||
onError={() => setStatus("error")}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { useColorScheme } from "react-native";
|
||||
import { Path, Svg } from "react-native-svg";
|
||||
|
||||
type ProviderIconProps = {
|
||||
readonly provider: string | null | undefined;
|
||||
readonly size?: number;
|
||||
};
|
||||
|
||||
export function ProviderIcon(props: ProviderIconProps) {
|
||||
const isDarkMode = useColorScheme() === "dark";
|
||||
const size = props.size ?? 16;
|
||||
|
||||
if (props.provider === "claudeAgent") {
|
||||
return (
|
||||
<Svg width={size} height={size} viewBox="0 0 256 257" fill="none">
|
||||
<Path
|
||||
fill="#D97757"
|
||||
d="m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Svg width={size} height={size} viewBox="0 0 256 260" fill="none">
|
||||
<Path
|
||||
fill={isDarkMode ? "#e2e8f0" : "#171717"}
|
||||
d="M239.184 106.203a64.716 64.716 0 0 0-5.576-53.103C219.452 28.459 191 15.784 163.213 21.74A65.586 65.586 0 0 0 52.096 45.22a64.716 64.716 0 0 0-43.23 31.36c-14.31 24.602-11.061 55.634 8.033 76.74a64.665 64.665 0 0 0 5.525 53.102c14.174 24.65 42.644 37.324 70.446 31.36a64.72 64.72 0 0 0 48.754 21.744c28.481.025 53.714-18.361 62.414-45.481a64.767 64.767 0 0 0 43.229-31.36c14.137-24.558 10.875-55.423-8.083-76.483Zm-97.56 136.338a48.397 48.397 0 0 1-31.105-11.255l1.535-.87 51.67-29.825a8.595 8.595 0 0 0 4.247-7.367v-72.85l21.845 12.636c.218.111.37.32.409.563v60.367c-.056 26.818-21.783 48.545-48.601 48.601Zm-104.466-44.61a48.345 48.345 0 0 1-5.781-32.589l1.534.921 51.722 29.826a8.339 8.339 0 0 0 8.441 0l63.181-36.425v25.221a.87.87 0 0 1-.358.665l-52.335 30.184c-23.257 13.398-52.97 5.431-66.404-17.803ZM23.549 85.38a48.499 48.499 0 0 1 25.58-21.333v61.39a8.288 8.288 0 0 0 4.195 7.316l62.874 36.272-21.845 12.636a.819.819 0 0 1-.767 0L41.353 151.53c-23.211-13.454-31.171-43.144-17.804-66.405v.256Zm179.466 41.695-63.08-36.63L161.73 77.86a.819.819 0 0 1 .768 0l52.233 30.184a48.6 48.6 0 0 1-7.316 87.635v-61.391a8.544 8.544 0 0 0-4.4-7.213Zm21.742-32.69-1.535-.922-51.619-30.081a8.39 8.39 0 0 0-8.492 0L99.98 99.808V74.587a.716.716 0 0 1 .307-.665l52.233-30.133a48.652 48.652 0 0 1 72.236 50.391v.205ZM88.061 139.097l-21.845-12.585a.87.87 0 0 1-.41-.614V65.685a48.652 48.652 0 0 1 79.757-37.346l-1.535.87-51.67 29.825a8.595 8.595 0 0 0-4.246 7.367l-.051 72.697Zm11.868-25.58 28.138-16.217 28.188 16.218v32.434l-28.086 16.218-28.188-16.218-.052-32.434Z"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import { View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
import { cn } from "../lib/cn";
|
||||
|
||||
export interface StatusTone {
|
||||
readonly label: string;
|
||||
readonly pillClassName: string;
|
||||
readonly textClassName: string;
|
||||
}
|
||||
|
||||
export function StatusPill(
|
||||
props: StatusTone & {
|
||||
readonly size?: "default" | "compact";
|
||||
},
|
||||
) {
|
||||
const size = props.size ?? "default";
|
||||
return (
|
||||
<View
|
||||
className={cn(
|
||||
"rounded-full",
|
||||
size === "compact" ? "px-2.5 py-1" : "px-3 py-1.5",
|
||||
props.pillClassName,
|
||||
)}
|
||||
>
|
||||
<Text
|
||||
className={cn(
|
||||
"font-t3-bold",
|
||||
size === "compact" ? "text-[11px]" : "text-xs",
|
||||
props.textClassName,
|
||||
)}
|
||||
>
|
||||
{props.label}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Pressable, View } from "react-native";
|
||||
import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
|
||||
import { ConnectionStatusDot } from "./ConnectionStatusDot";
|
||||
|
||||
export function ConnectionEnvironmentRow(props: {
|
||||
readonly environment: ConnectedEnvironmentSummary;
|
||||
readonly expanded: boolean;
|
||||
readonly onToggle: () => void;
|
||||
readonly onReconnect: (environmentId: string) => void;
|
||||
readonly onRemove: (environmentId: string) => void;
|
||||
readonly onUpdate: (
|
||||
environmentId: string,
|
||||
updates: { readonly label: string; readonly displayUrl: string },
|
||||
) => void;
|
||||
}) {
|
||||
const [label, setLabel] = useState(props.environment.environmentLabel);
|
||||
const [url, setUrl] = useState(props.environment.displayUrl);
|
||||
|
||||
const mutedColor = useThemeColor("--color-icon-subtle");
|
||||
const placeholderColor = useThemeColor("--color-placeholder");
|
||||
const primaryFg = useThemeColor("--color-primary-foreground");
|
||||
const dangerFg = useThemeColor("--color-danger-foreground");
|
||||
|
||||
const handleSave = useCallback(() => {
|
||||
props.onUpdate(props.environment.environmentId, {
|
||||
label: label.trim(),
|
||||
displayUrl: url.trim(),
|
||||
});
|
||||
props.onToggle();
|
||||
}, [label, url, props]);
|
||||
|
||||
return (
|
||||
<Animated.View layout={LinearTransition.duration(250)} className="bg-card">
|
||||
<Pressable
|
||||
className="flex-row items-center gap-3 px-4 py-3.5 active:opacity-70"
|
||||
onPress={props.onToggle}
|
||||
>
|
||||
<ConnectionStatusDot state={props.environment.connectionState} pulse={false} size={8} />
|
||||
|
||||
<View className="flex-1 gap-0.5">
|
||||
<Text
|
||||
className="text-[16px] font-t3-bold leading-[21px] text-foreground"
|
||||
numberOfLines={1}
|
||||
>
|
||||
{props.environment.environmentLabel}
|
||||
</Text>
|
||||
<Text className="text-[12px] leading-[16px] text-foreground-muted" numberOfLines={1}>
|
||||
{props.environment.displayUrl}
|
||||
</Text>
|
||||
{props.environment.connectionError ? (
|
||||
<Text
|
||||
className="text-[12px] leading-[16px] text-rose-500 dark:text-rose-400"
|
||||
numberOfLines={2}
|
||||
>
|
||||
{props.environment.connectionError}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<SymbolView
|
||||
name="chevron.down"
|
||||
size={12}
|
||||
tintColor={mutedColor}
|
||||
type="monochrome"
|
||||
style={{
|
||||
transform: [{ rotate: props.expanded ? "180deg" : "0deg" }],
|
||||
}}
|
||||
/>
|
||||
</Pressable>
|
||||
|
||||
{props.expanded ? (
|
||||
<Animated.View
|
||||
entering={FadeIn.duration(200)}
|
||||
exiting={FadeOut.duration(150)}
|
||||
className="gap-3 px-4 pb-4"
|
||||
>
|
||||
<View className="gap-1.5">
|
||||
<Text
|
||||
className="text-[11px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
Label
|
||||
</Text>
|
||||
<TextInput
|
||||
autoCapitalize="words"
|
||||
autoCorrect={false}
|
||||
placeholder="My MacBook"
|
||||
placeholderTextColor={placeholderColor}
|
||||
value={label}
|
||||
onChangeText={setLabel}
|
||||
className="rounded-[14px] border border-input-border bg-input px-4 py-3 text-[15px] text-foreground"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="gap-1.5">
|
||||
<Text
|
||||
className="text-[11px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
URL
|
||||
</Text>
|
||||
<TextInput
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
keyboardType="url"
|
||||
placeholder="192.168.1.100:8080"
|
||||
placeholderTextColor={placeholderColor}
|
||||
value={url}
|
||||
onChangeText={setUrl}
|
||||
className="rounded-[14px] border border-input-border bg-input px-4 py-3 text-[15px] text-foreground"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className="flex-row gap-2">
|
||||
<Pressable
|
||||
className="min-h-[42px] flex-1 flex-row items-center justify-center gap-1.5 rounded-[14px] bg-primary px-3.5 py-2.5 active:opacity-70"
|
||||
onPress={handleSave}
|
||||
>
|
||||
<SymbolView name="checkmark" size={13} tintColor={primaryFg} type="monochrome" />
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase text-primary-foreground"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
Save
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
<Pressable
|
||||
className="h-[42px] w-[42px] items-center justify-center rounded-[14px] border border-input-border bg-input active:opacity-70"
|
||||
onPress={() => props.onReconnect(props.environment.environmentId)}
|
||||
>
|
||||
<SymbolView
|
||||
name="arrow.clockwise"
|
||||
size={14}
|
||||
tintColor={mutedColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
</Pressable>
|
||||
|
||||
<Pressable
|
||||
className="h-[42px] w-[42px] items-center justify-center rounded-[14px] border border-danger-border bg-danger active:opacity-70"
|
||||
onPress={() => props.onRemove(props.environment.environmentId)}
|
||||
>
|
||||
<SymbolView name="trash" size={14} tintColor={dangerFg} type="monochrome" />
|
||||
</Pressable>
|
||||
</View>
|
||||
</Animated.View>
|
||||
) : null}
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { Platform, Pressable } from "react-native";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { cn } from "../../lib/cn";
|
||||
|
||||
const CARD_SHADOW = Platform.select({
|
||||
ios: {
|
||||
shadowColor: "rgba(23,23,23,0.08)",
|
||||
shadowOffset: { width: 0, height: 4 },
|
||||
shadowOpacity: 1,
|
||||
shadowRadius: 16,
|
||||
},
|
||||
android: { elevation: 3 },
|
||||
});
|
||||
|
||||
const CARD_SHADOW_DARK = Platform.select({
|
||||
ios: {
|
||||
shadowColor: "#000",
|
||||
shadowOffset: { width: 0, height: 2 },
|
||||
shadowOpacity: 0.18,
|
||||
shadowRadius: 8,
|
||||
},
|
||||
android: { elevation: 4 },
|
||||
});
|
||||
|
||||
export { CARD_SHADOW, CARD_SHADOW_DARK };
|
||||
|
||||
export function ConnectionSheetButton(props: {
|
||||
readonly icon: React.ComponentProps<typeof SymbolView>["name"];
|
||||
readonly label: string;
|
||||
readonly disabled?: boolean;
|
||||
readonly tone?: "primary" | "secondary" | "danger";
|
||||
readonly compact?: boolean;
|
||||
readonly onPress: () => void;
|
||||
}) {
|
||||
const tone = props.tone ?? "secondary";
|
||||
|
||||
const primaryBg = useThemeColor("--color-primary");
|
||||
const primaryFg = useThemeColor("--color-primary-foreground");
|
||||
const dangerBg = useThemeColor("--color-danger");
|
||||
const dangerBorderColor = useThemeColor("--color-danger-border");
|
||||
const dangerFg = useThemeColor("--color-danger-foreground");
|
||||
const secondaryBg = useThemeColor("--color-secondary");
|
||||
const secondaryFg = useThemeColor("--color-secondary-foreground");
|
||||
const borderColor = useThemeColor("--color-border");
|
||||
|
||||
const colors =
|
||||
tone === "primary"
|
||||
? {
|
||||
backgroundColor: primaryBg,
|
||||
borderColor: "transparent",
|
||||
textColor: primaryFg,
|
||||
}
|
||||
: tone === "danger"
|
||||
? {
|
||||
backgroundColor: dangerBg,
|
||||
borderColor: dangerBorderColor,
|
||||
textColor: dangerFg,
|
||||
}
|
||||
: {
|
||||
backgroundColor: secondaryBg,
|
||||
borderColor: borderColor,
|
||||
textColor: secondaryFg,
|
||||
};
|
||||
|
||||
const primaryShadow =
|
||||
tone === "primary"
|
||||
? Platform.select({
|
||||
ios: {
|
||||
shadowColor: "#000",
|
||||
shadowOffset: { width: 0, height: 3 },
|
||||
shadowOpacity: 0.14,
|
||||
shadowRadius: 6,
|
||||
},
|
||||
android: { elevation: 3 },
|
||||
})
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
className={cn(
|
||||
props.compact
|
||||
? "min-h-[42px] flex-row items-center justify-center gap-1.5 rounded-[14px] px-3.5 py-2.5"
|
||||
: "min-h-[48px] flex-row items-center justify-center gap-2 rounded-[16px] px-4 py-3",
|
||||
)}
|
||||
disabled={props.disabled}
|
||||
onPress={props.onPress}
|
||||
style={[
|
||||
{
|
||||
backgroundColor: colors.backgroundColor,
|
||||
borderWidth: tone === "primary" ? 0 : 1,
|
||||
borderColor: colors.borderColor,
|
||||
opacity: props.disabled ? 0.5 : 1,
|
||||
},
|
||||
primaryShadow,
|
||||
]}
|
||||
>
|
||||
<SymbolView
|
||||
name={props.icon}
|
||||
size={props.compact ? 13 : 14}
|
||||
tintColor={colors.textColor}
|
||||
type="monochrome"
|
||||
/>
|
||||
<Text
|
||||
className="text-[12px] font-t3-bold uppercase"
|
||||
style={{ color: colors.textColor, letterSpacing: 0.8 }}
|
||||
>
|
||||
{props.label}
|
||||
</Text>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
import { useEffect } from "react";
|
||||
import { View } from "react-native";
|
||||
import Animated, {
|
||||
cancelAnimation,
|
||||
Easing,
|
||||
useAnimatedStyle,
|
||||
useSharedValue,
|
||||
withRepeat,
|
||||
withTiming,
|
||||
} from "react-native-reanimated";
|
||||
|
||||
import type { RemoteClientConnectionState } from "../../lib/connection";
|
||||
|
||||
function statusDotTone(state: RemoteClientConnectionState): {
|
||||
readonly dotColor: string;
|
||||
readonly haloColor: string;
|
||||
} {
|
||||
switch (state) {
|
||||
case "ready":
|
||||
return {
|
||||
dotColor: "#34d399",
|
||||
haloColor: "rgba(52,211,153,0.48)",
|
||||
};
|
||||
case "connecting":
|
||||
case "reconnecting":
|
||||
return {
|
||||
dotColor: "#f59e0b",
|
||||
haloColor: "rgba(245,158,11,0.5)",
|
||||
};
|
||||
case "idle":
|
||||
case "disconnected":
|
||||
return {
|
||||
dotColor: "#ef4444",
|
||||
haloColor: "rgba(239,68,68,0.48)",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function usePulseAnimation(pulse: boolean) {
|
||||
const pulseProgress = useSharedValue(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (pulse) {
|
||||
pulseProgress.value = withRepeat(
|
||||
withTiming(1, {
|
||||
duration: 1100,
|
||||
easing: Easing.out(Easing.cubic),
|
||||
}),
|
||||
-1,
|
||||
false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
cancelAnimation(pulseProgress);
|
||||
pulseProgress.value = withTiming(0, {
|
||||
duration: 180,
|
||||
easing: Easing.out(Easing.quad),
|
||||
});
|
||||
}, [pulse, pulseProgress]);
|
||||
|
||||
return pulseProgress;
|
||||
}
|
||||
|
||||
export function ConnectionStatusDot(props: {
|
||||
readonly state: RemoteClientConnectionState;
|
||||
readonly pulse: boolean;
|
||||
readonly size?: number;
|
||||
}) {
|
||||
const pulseProgress = usePulseAnimation(props.pulse);
|
||||
const tone = statusDotTone(props.state);
|
||||
const dotSize = props.size ?? 10;
|
||||
const haloSize = dotSize + 4;
|
||||
const containerSize = haloSize + 4;
|
||||
|
||||
const haloStyle = useAnimatedStyle(() => ({
|
||||
opacity: props.pulse ? 0.14 + (1 - pulseProgress.value) * 0.3 : 0,
|
||||
transform: [{ scale: 0.78 + pulseProgress.value * 1.16 }],
|
||||
}));
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
width: containerSize,
|
||||
height: containerSize,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Animated.View
|
||||
style={[
|
||||
haloStyle,
|
||||
{
|
||||
position: "absolute",
|
||||
width: haloSize,
|
||||
height: haloSize,
|
||||
borderRadius: haloSize / 2,
|
||||
backgroundColor: tone.haloColor,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<View
|
||||
style={{
|
||||
width: dotSize,
|
||||
height: dotSize,
|
||||
borderRadius: dotSize / 2,
|
||||
backgroundColor: tone.dotColor,
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
import { CameraView, useCameraPermissions } from "expo-camera";
|
||||
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { SymbolView } from "expo-symbols";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Alert, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { ErrorBanner } from "../../components/ErrorBanner";
|
||||
import { dismissRoute } from "../../lib/routes";
|
||||
import { ConnectionSheetButton } from "./ConnectionSheetButton";
|
||||
import { extractPairingUrlFromQrPayload } from "./pairing";
|
||||
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { buildPairingUrl, parsePairingUrl } from "./pairing";
|
||||
|
||||
export function NewConnectionRouteScreen() {
|
||||
const {
|
||||
connectionError,
|
||||
connectionPairingUrl,
|
||||
connectionState,
|
||||
onChangeConnectionPairingUrl,
|
||||
onConnectPress,
|
||||
} = useRemoteConnections();
|
||||
const router = useRouter();
|
||||
const params = useLocalSearchParams<{ mode?: string }>();
|
||||
const insets = useSafeAreaInsets();
|
||||
const [hostInput, setHostInput] = useState("");
|
||||
const [codeInput, setCodeInput] = useState("");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [showScanner, setShowScanner] = useState(params.mode === "scan_qr");
|
||||
const [cameraPermission, requestCameraPermission] = useCameraPermissions();
|
||||
const [scannerLocked, setScannerLocked] = useState(false);
|
||||
|
||||
const textColor = useThemeColor("--color-icon");
|
||||
const placeholderColor = useThemeColor("--color-placeholder");
|
||||
|
||||
const connectDisabled =
|
||||
isSubmitting || connectionState === "connecting" || hostInput.trim().length === 0;
|
||||
|
||||
useEffect(() => {
|
||||
const { host, code } = parsePairingUrl(connectionPairingUrl);
|
||||
setHostInput(host);
|
||||
setCodeInput(code);
|
||||
}, [connectionPairingUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (connectionError) {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}, [connectionError]);
|
||||
|
||||
const handleHostChange = useCallback((value: string) => {
|
||||
setHostInput(value);
|
||||
}, []);
|
||||
|
||||
const handleCodeChange = useCallback((value: string) => {
|
||||
setCodeInput(value);
|
||||
}, []);
|
||||
|
||||
const openScanner = useCallback(async () => {
|
||||
if (cameraPermission?.granted) {
|
||||
setScannerLocked(false);
|
||||
setShowScanner(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const permission = await requestCameraPermission();
|
||||
if (permission.granted) {
|
||||
setScannerLocked(false);
|
||||
setShowScanner(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Alert.alert("Camera access needed", "Allow camera access to scan a backend pairing QR code.");
|
||||
}, [cameraPermission?.granted, requestCameraPermission]);
|
||||
|
||||
const closeScanner = useCallback(() => {
|
||||
setShowScanner(false);
|
||||
setScannerLocked(false);
|
||||
}, []);
|
||||
|
||||
const handleQrScan = useCallback(
|
||||
({ data }: { readonly data: string }) => {
|
||||
if (scannerLocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
setScannerLocked(true);
|
||||
|
||||
try {
|
||||
const pairingUrl = extractPairingUrlFromQrPayload(data);
|
||||
const { host, code } = parsePairingUrl(pairingUrl);
|
||||
setHostInput(host);
|
||||
setCodeInput(code);
|
||||
onChangeConnectionPairingUrl(pairingUrl);
|
||||
setShowScanner(false);
|
||||
} catch (error) {
|
||||
Alert.alert(
|
||||
"Invalid QR code",
|
||||
error instanceof Error ? error.message : "Scanned QR code was not recognized.",
|
||||
);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
setScannerLocked(false);
|
||||
}, 600);
|
||||
}
|
||||
},
|
||||
[onChangeConnectionPairingUrl, scannerLocked],
|
||||
);
|
||||
|
||||
const handleSubmit = useCallback(async () => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
const pairingUrl = buildPairingUrl(hostInput, codeInput);
|
||||
onChangeConnectionPairingUrl(pairingUrl);
|
||||
await onConnectPress(pairingUrl);
|
||||
dismissRoute(router);
|
||||
} catch {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}, [codeInput, hostInput, onChangeConnectionPairingUrl, onConnectPress, router]);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: showScanner ? "Scan QR Code" : "Add Backend",
|
||||
headerRight: () => (
|
||||
<Pressable
|
||||
className="h-10 w-10 items-center justify-center rounded-full border border-border bg-secondary"
|
||||
onPress={() => {
|
||||
if (showScanner) {
|
||||
closeScanner();
|
||||
} else {
|
||||
void openScanner();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SymbolView
|
||||
name={showScanner ? "xmark" : "qrcode.viewfinder"}
|
||||
size={showScanner ? 14 : 18}
|
||||
tintColor={textColor}
|
||||
type="monochrome"
|
||||
weight="semibold"
|
||||
/>
|
||||
</Pressable>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={{ flex: 1 }}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: 16,
|
||||
paddingBottom: Math.max(insets.bottom, 18) + 18,
|
||||
}}
|
||||
>
|
||||
<View collapsable={false} className="gap-5">
|
||||
{showScanner ? (
|
||||
cameraPermission?.granted ? (
|
||||
<View
|
||||
className="overflow-hidden rounded-[24px]"
|
||||
style={{ borderCurve: "continuous" }}
|
||||
>
|
||||
<CameraView
|
||||
barcodeScannerSettings={{ barcodeTypes: ["qr"] }}
|
||||
onBarcodeScanned={handleQrScan}
|
||||
style={{ aspectRatio: 1, width: "100%" }}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
className="items-center gap-3 rounded-[24px] bg-card px-5 py-8"
|
||||
style={{ borderCurve: "continuous" }}
|
||||
>
|
||||
<Text className="text-center text-[14px] leading-[20px] text-foreground-muted">
|
||||
Camera permission is required to scan a QR code.
|
||||
</Text>
|
||||
<ConnectionSheetButton
|
||||
compact
|
||||
icon="camera"
|
||||
label="Allow camera"
|
||||
tone="secondary"
|
||||
onPress={() => {
|
||||
void openScanner();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
) : (
|
||||
<View collapsable={false} className="gap-4 rounded-[24px] bg-card p-4">
|
||||
<View collapsable={false} className="gap-1.5">
|
||||
<Text
|
||||
className="text-[11px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
Host
|
||||
</Text>
|
||||
<TextInput
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
keyboardType="url"
|
||||
placeholder="192.168.1.100:8080"
|
||||
placeholderTextColor={placeholderColor}
|
||||
value={hostInput}
|
||||
onChangeText={handleHostChange}
|
||||
className="rounded-[14px] border border-input-border bg-input px-4 py-3.5 text-[15px] text-foreground"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View collapsable={false} className="gap-1.5">
|
||||
<Text
|
||||
className="text-[11px] font-t3-bold uppercase text-foreground-muted"
|
||||
style={{ letterSpacing: 0.8 }}
|
||||
>
|
||||
Pairing code
|
||||
</Text>
|
||||
<TextInput
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="abc-123-xyz"
|
||||
placeholderTextColor={placeholderColor}
|
||||
value={codeInput}
|
||||
onChangeText={handleCodeChange}
|
||||
className="rounded-[14px] border border-input-border bg-input px-4 py-3.5 text-[15px] text-foreground"
|
||||
/>
|
||||
</View>
|
||||
|
||||
{connectionError ? <ErrorBanner message={connectionError} /> : null}
|
||||
|
||||
<ConnectionSheetButton
|
||||
icon="plus"
|
||||
label={
|
||||
isSubmitting || connectionState === "connecting" ? "Pairing..." : "Add backend"
|
||||
}
|
||||
disabled={connectDisabled}
|
||||
tone="primary"
|
||||
onPress={() => {
|
||||
void handleSubmit();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import type { StatusTone } from "../../components/StatusPill";
|
||||
import type { RemoteClientConnectionState } from "../../lib/connection";
|
||||
|
||||
export function connectionTone(state: RemoteClientConnectionState): StatusTone {
|
||||
switch (state) {
|
||||
case "ready":
|
||||
return {
|
||||
label: "Connected",
|
||||
pillClassName: "bg-emerald-500/12 dark:bg-emerald-500/16",
|
||||
textClassName: "text-emerald-700 dark:text-emerald-300",
|
||||
};
|
||||
case "reconnecting":
|
||||
return {
|
||||
label: "Reconnecting",
|
||||
pillClassName: "bg-amber-500/12 dark:bg-amber-500/16",
|
||||
textClassName: "text-amber-700 dark:text-amber-300",
|
||||
};
|
||||
case "connecting":
|
||||
return {
|
||||
label: "Connecting",
|
||||
pillClassName: "bg-sky-500/12 dark:bg-sky-500/16",
|
||||
textClassName: "text-sky-700 dark:text-sky-300",
|
||||
};
|
||||
case "disconnected":
|
||||
return {
|
||||
label: "Disconnected",
|
||||
pillClassName: "bg-rose-500/12 dark:bg-rose-500/16",
|
||||
textClassName: "text-rose-700 dark:text-rose-300",
|
||||
};
|
||||
case "idle":
|
||||
return {
|
||||
label: "Idle",
|
||||
pillClassName: "bg-neutral-500/10 dark:bg-neutral-500/16",
|
||||
textClassName: "text-neutral-600 dark:text-neutral-300",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { extractPairingUrlFromQrPayload } from "./pairing";
|
||||
|
||||
describe("extractPairingUrlFromQrPayload", () => {
|
||||
it("trims raw pairing urls from qr payloads", () => {
|
||||
expect(
|
||||
extractPairingUrlFromQrPayload(" https://remote.example.com/pair#token=pairing-token "),
|
||||
).toBe("https://remote.example.com/pair#token=pairing-token");
|
||||
});
|
||||
|
||||
it("unwraps mobile deep links that carry an encoded pairing url", () => {
|
||||
expect(
|
||||
extractPairingUrlFromQrPayload(
|
||||
"t3code://pair?pairingUrl=https%3A%2F%2Fremote.example.com%2Fpair%23token%3Dpairing-token",
|
||||
),
|
||||
).toBe("https://remote.example.com/pair#token=pairing-token");
|
||||
});
|
||||
|
||||
it("rejects empty qr payloads", () => {
|
||||
expect(() => extractPairingUrlFromQrPayload(" ")).toThrow(
|
||||
"Scanned QR code did not contain a pairing URL.",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
const MOBILE_PAIRING_URL_PARAM = "pairingUrl";
|
||||
|
||||
export function buildPairingUrl(host: string, code: string): string {
|
||||
const h = host.trim();
|
||||
const c = code.trim();
|
||||
if (!h) return "";
|
||||
if (!c) return h;
|
||||
|
||||
try {
|
||||
const url = new URL(h.includes("://") ? h : `https://${h}`);
|
||||
url.hash = new URLSearchParams([["token", c]]).toString();
|
||||
return url.toString();
|
||||
} catch {
|
||||
return `${h}#token=${c}`;
|
||||
}
|
||||
}
|
||||
|
||||
export function parsePairingUrl(url: string): { host: string; code: string } {
|
||||
const trimmed = url.trim();
|
||||
if (!trimmed) return { host: "", code: "" };
|
||||
|
||||
try {
|
||||
const parsed = new URL(trimmed);
|
||||
const hashParams = new URLSearchParams(parsed.hash.slice(1));
|
||||
const hashToken = hashParams.get("token");
|
||||
const queryToken = parsed.searchParams.get("token");
|
||||
const code = hashToken || queryToken || "";
|
||||
|
||||
parsed.hash = "";
|
||||
parsed.search = "";
|
||||
parsed.pathname = "/";
|
||||
return { host: parsed.toString().replace(/\/$/, ""), code };
|
||||
} catch {
|
||||
return { host: trimmed, code: "" };
|
||||
}
|
||||
}
|
||||
|
||||
export function extractPairingUrlFromQrPayload(payload: string): string {
|
||||
const trimmed = payload.trim();
|
||||
if (!trimmed) {
|
||||
throw new Error("Scanned QR code did not contain a pairing URL.");
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(trimmed);
|
||||
if (url.protocol === "t3code:") {
|
||||
const pairingUrl = url.searchParams.get(MOBILE_PAIRING_URL_PARAM)?.trim() ?? "";
|
||||
if (pairingUrl.length > 0) {
|
||||
return pairingUrl;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Treat non-URL payloads as raw pairing-url text so the normal input validation can decide.
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
}
|
||||