# feat\(web,mobile\): @\-mention a machine as a context chip · PR \#17130 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/17130)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: t3code/peer/environment-chips

Target branch: t3code/peer/agent-link

Head commit: a0c623abd846b5bfc99a23234dda490b7b949862

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/17130)

[Commits](https://git.cafe/pingdotgg/t3code/pull/17130/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/17130/diffs?format=markdown)

## Description

---

Part of cross-environment orchestration. A user can type `@` and part of a machine's name, as in "hand off work to my @box", and the composer inserts a chip for that T3 Code environment. The agent learns exactly which machine is meant, so it can delegate there straight away, or ask to link it with the card from the previous PR.

**How it works**
- **Contracts.** New context kind `environment` with `EnvironmentContextRecord {environmentId, label}`, beside the `thread` chip. Only identity travels, never an address.
- **What the agent sees** (`formatComposerContextProviderPayload`): the label, the `environmentId`, and one sentence: this is a T3 Code environment the user means; if it isn't linked here, call `t3_environment_link` with this id, then pass the id to `delegate_task`, `t3_thread_launch` and the other tools.
- **Web.**
  - The `@` menu offers the user's other environments, with their machine icon and a "Machine" label, beside threads and files. Like threads, they appear once you type part of a name; a bare `@` stays the file picker.
  - Picking one inserts a chip with the icon and label.
  - Mentioned machines live in an `environmentContexts` draft slice next to thread contexts: persisted, restored on undo, failed sends and plan follow-ups, imported on paste, and rendered in the composer and in sent messages.
- **Mobile.** The `@` popover offers the same machines (shared matcher `matchComposerEnvironmentItems`), inserts a chip, and lists it in the context sheet. Sent messages draw it natively. The record doesn't carry the machine kind, so every machine chip in message text uses one server glyph. iOS uses the system symbol; Android has a hand-drawn glyph that needs a native build.
- Every switch over context kinds now has a decision for `environment`.

**Verification**
- Shared `composerContextReferences.test.ts`: the provider payload for a machine chip carries label, id and the instruction, and no address.
- Web `composerDraftStore.test.ts`: a machine chip round-trips through the draft store (persist, restore, send). The removal and restore paths were mutation-checked.
- Client-runtime `composerThreadItems.test.ts`: matching machines by name. Contracts `composerContext.test.ts`: the new kind decodes and encodes. Mobile `nativeMarkdownText.test.ts`: the native chip payload.
- Per-layer check of the whole stack: this layer typechecks clean, and 380 server tests pass. Contracts, shared, client-runtime, web and mobile typecheck clean. The client tests touched here pass (282).

**Real client** (web, laptop and box dev servers, Codex GPT 6.0 Astra):

Typing `@bo` lists box as a machine beside matching threads:

![The @ menu shows three threads and "box · Machine" with the server icon](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/7510995f9efa41dc/7-mention-menu.png)

![The composer reads "Hand off work to my [box chip] and add a SHIPPING_FEE = 5 export to pricing.ts there."](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/4533bc5641db839a/8-chip.png)

**Box already linked:** the agent calls `t3_environment_link` with the chip's `environmentId`, gets `linked` back at once with no card, delegates, and the export lands on the box:

![The sent message shows the box chip; the agent reports "Completed on box", and Lineage shows the task on box · Done](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/b259a5c8679d1080/9-chip-delegated.png)

**Box not linked yet:** the same chip makes the agent ask for that machine. The card skips the machine list and opens on box. After the user picks the access, the agent is woken, delegates, and `MIN_ORDER` lands on the box:

![The card "Link a machine to this environment" with Review link…](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/831ef8edbc611c11/12-chip-card.png)

![The dialog titled "Link box" goes straight to the access levels](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/c350dcfc451e2c49/13-chip-modal.png)

![Linked box · Auto-accept edits, then the notification turn delegates and reports the task finished on box](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/2744769218efbc3e/14-chip-linked-delegated.png)

Not verified on mobile in a real client here; the mobile code typechecks and its tests pass.

Opus 5.5 via Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/pingdotgg/t3code/pull/17130" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
