Skip to content

Add opt-in Codex Desktop context with provenance and live chat routing - #2

Open
alexey-belkin wants to merge 1 commit into
anton-belkin:agent-layerfrom
alexey-belkin:codex/desktop-chat-routing
Open

alexey-belkin wants to merge 1 commit into
anton-belkin:agent-layerfrom
alexey-belkin:codex/desktop-chat-routing

Conversation

@alexey-belkin

Copy link
Copy Markdown

Problem and behavior

A GridCraft workbook served by Codex still showed Claude setup/Waiting, and it could not show which actual Desktop chat would receive its questions. This adds an opt-in Codex context with live connection status, saved creator-chat provenance and a runtime working-chat route displayed in Agent.

The companion bridge, shared App Server launcher, workbook links, global experimental skill and installation guide are in anton-belkin/aitocraft#1. This PR intentionally targets agent-layer; the native changes are Rust only.

Changes

  • GRIDCRAFT_AGENT_PROVIDER=codex scopes the runtime to one launched instance, skips Claude setup and avoids persisting its preferences into global defaults. Explicit Off remains respected.
  • Optional creator-chat fields round-trip with the existing workbook agent metadata and are cleared from inherited defaults for new workbooks. Creator metadata cannot be rewritten by an answering agent.
  • agent.codexRoute maintains an expiring runtime-only route. Agent shows the actual chat, missing/other-chat states and an Open Chat action. A stale answered ping cannot make Codex Ready; a recent Desktop bridge listener is required.
  • Connect Codex starts the configured external question worker for this GUI instance. AItoCraft discovery can use an isolated AITOCRAFT_REGISTRY_DIR.
  • Native command/environment contract and companion installation, architecture and reboot guide.

The working chat chosen by a link is separate from creator provenance. Unavailable targets use a visibly different real Desktop chat rather than importing history into a CLI session. Existing proposal acceptance/rejection commands remain person actions. No global Claude configuration changes are required.

Validation

  • cargo xtask ci: all 8 steps passed — fmt, Clippy -D warnings, 1686 workspace tests, assets, layers, WASM, parity and keytips. This includes 58 agent-layer and 14 Agent UI tests. The first sandboxed run refused a local TCP bind in an existing MCP test; the full rerun with loopback access passed.
  • Companion AItoCraft: 19 library + 1 stdio tests passed, 11 Python tests passed, Node syntax checks, native Swift compile, skill validation and isolated installer verification passed.

The companion live test delivered five unique questions into the same actual Desktop chat: formula explanation; draft 60→70 (profit 40→30); draft 70→90 (profit 10), rejection comment; and a question after saving/reopening. Acceptance/rejection, formula, answers, decisions and provenance survived save/reopen. The final pass used native person-action commands corresponding to the buttons, without claiming fresh UI clicks while Desktop UI automation was unavailable.

Scope and compatibility

The companion macOS example was exercised on Desktop 26.1007.30912 / bundled App Server 0.162.0-alpha.17.2. Its shared-transport override is version-sensitive and experimental. Existing files without the new fields still read; older GridCraft versions that do not recognize kind=codex are not supported readers of that new context metadata. No real chat IDs, tickets, user workbooks or private paths are included.

@anton-belkin

Copy link
Copy Markdown
Owner

Thanks for this! A Codex context is welcome, and the fork rules are respected: only fork files are
touched, the fork:agent markers are unchanged, and rebase.sh --check is green on the current
agent-layer. A few changes are needed before we merge.

Please change

  1. Make it really opt-in. The Codex row shows in everyone's Context menu even without
    GRIDCRAFT_AGENT_PROVIDER=codex (crates/agent-ui/src/ribbon.rs:477). Picking it saves the new
    kind, and Connect Codex then fails. Show the row only when the mode is enabled.
  2. English UI text. Russian strings are hard-coded in crates/agent-ui/src/context.rs:264-300 and
    crates/agent-ui/src/ribbon.rs:520-536. The rest of the UI is English.
  3. The Ready lamp must not depend on a label. It turns on only for a listener whose label starts
    with "Codex desktop bridge ·" (crates/agent-ui/src/context.rs:241). The rule in PROTOCOL.md
    §7 is simply a listener for this document seen recently. Please use that, so any client works.
  4. Smaller:
    • don't hard-code /usr/bin/python3 (crates/agent/src/context.rs:565): find python on PATH or
      make it configurable;
    • move docs/codex-desktop.md out of upstream's docs/ into agent-layer/, and drop the links
      to personal branches.

Please discuss before coding

  1. Generic fields instead of Codex-specific ones. "Creator chat" and "current chat route" are
    useful for any client and any app (WordCraft and DeckCraft too). Let's describe them in
    PROTOCOL.md as generic, optional fields (for example origin: {client, chat, url?} on the
    document and route on the listener) and store them in that form. See the aitocraft#1 reply for
    the bigger picture.

On our side

  • An older build that meets an unknown value such as "kind":"codex" currently drops the whole
    agent layer. That's our bug, not yours, and we're fixing it in agent-layer (unknown values are
    kept, never wiped). No change needed in this PR.

When 1–4 are done (and 5 agreed), we'll merge.

anton-belkin pushed a commit that referenced this pull request Oct 22, 2026
Japanese Excel's B4/B5/B6 are the JIS sizes (257×364, 182×257 and 128×182 mm),
but Page Setup's `b4`/`b5` were the ISO ones (250×353, 176×250): a Japanese B5
worksheet printed 8 mm narrow. `known_paper` now reads `B4`/`B5`/`B6` as JIS and
keeps the ISO sizes reachable as `B4 (ISO)`/`B5 (ISO)`/`B6 (ISO)`. This also
fixes the XLSX round-trip, whose `paperSize` ids 12/13 are the JIS sizes.

Adds the Japanese papers Page Setup lacked: Japanese Postcard (はがき,
100×148 mm), Japanese Double Postcard (往復はがき, 148×200 mm), Japanese
Envelope #3/storytold#4 (長形3号/4号, 120×235 and 90×225 mm), Japanese Envelope Kaku
#2/#3 (角形2号/3号, 240×332 and 216×277 mm), A6, and aliases such as
`postcard`, `chou #3`, `kaku #2`; the xlsx paper table gains ids 42 (ISO B4) and
43/69–74/88 so these names survive save and reopen (the ISO B5/B6 names have no
ECMA-376 paper id and stay engine-side).

The pageSetup/pageLayout.size parameter docs list the names, the Page Layout
Size menu lists them, and tests pin the point sizes, the PDF MediaBox for A4
(unchanged), B5, postcard, double postcard and kaku #2, landscape and
fit-to-page, the unknown-name Letter fallback, and the XLSX round-trip.

Docs: docs/target-app-parity.md print row + revision history, and ROADMAP.md
progress log, dated 2026-10-21.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants