Skip to content

feat(desktop): expose task submission readiness - #2501

Closed
liugddx wants to merge 2 commits into
apache:mainfrom
liugddx:feat/desktop-task-readiness-ipc
Closed

liugddx wants to merge 2 commits into
apache:mainfrom
liugddx:feat/desktop-task-readiness-ipc

Conversation

@liugddx

@liugddx liugddx commented Aug 8, 2026

Copy link
Copy Markdown
Member

English

Summary

Second delivery slice of #2497, building on the Core projection merged in #2498. This PR adds the Desktop Main/Runtime Host adapter and a typed preload IPC surface for task-submission readiness.

The adapter:

  • resolves the requested or default connection/model from Main-owned stores;
  • checks credential presence through the existing read-only authority, without refreshing tokens as a side effect;
  • inspects the actual requested cwd (or Desktop workspace root) as a directory;
  • projects embedded runtime as ready after boot;
  • tracks Runtime Host connection closure and reports it as unavailable;
  • keeps credential/store uncertainty as unknown instead of inventing a repair failure;
  • validates renderer input before reading stores;
  • exposes window.maka.taskReadiness.getSnapshot(...) through the typed bridge.

Both embedded and Runtime Host Desktop owners register the same IPC contract.

Refs #2497
Refs #2469

Verification

  • npm --workspace @maka/core run build — passed
  • npm --workspace @maka/desktop run build:main — passed
  • npm --workspace @maka/desktop run build:preload — passed
  • targeted adapter and Runtime Host client tests — 5/5 passed
  • npm --workspace @maka/desktop run typecheck — passed
  • npx biome check on all changed files — passed
  • git diff --check — passed

Scope

This PR exposes authoritative baseline readiness only. It does not yet render or enforce the snapshot in the Composer, and it does not yet adapt task-requested optional capabilities.

中文

概要

这是 #2497 的第二个交付切片,基于 #2498 已合并的 Core 投影。本 PR 增加 Desktop Main / Runtime Host adapter,并通过类型化 preload IPC 暴露任务提交 readiness。

Adapter 会:

  • 从 Main 权威存储解析请求指定或默认的连接/模型;
  • 通过现有只读凭据权威检查凭据,不因读取 readiness 而刷新 token;
  • 检查实际请求的 cwd,未指定时检查 Desktop workspace root;
  • embedded runtime 在完成启动后投影为 ready;
  • 跟踪 Runtime Host 连接关闭,并投影为 unavailable;
  • 凭据或存储读取不确定时保持 unknown,不虚构修复错误;
  • 在读取存储前严格验证 Renderer 输入;
  • 通过类型化 bridge 暴露 window.maka.taskReadiness.getSnapshot(...)。

embedded 与 Runtime Host 两种 Desktop owner 注册同一份 IPC 契约。

关联 #2497
关联 #2469

验证

  • npm --workspace @maka/core run build——通过
  • npm --workspace @maka/desktop run build:main——通过
  • npm --workspace @maka/desktop run build:preload——通过
  • adapter 与 Runtime Host client 针对性测试——5/5 通过
  • npm --workspace @maka/desktop run typecheck——通过
  • 对全部改动文件运行 npx biome check——通过
  • git diff --check——通过

范围

本 PR 只暴露基础权威 readiness;尚未在 Composer 中展示或执行这份 snapshot,也尚未适配任务按需请求的可选能力。

@Astro-Han

Copy link
Copy Markdown
Contributor

Thanks for laying down this readiness boundary. Reusing the Core projection, keeping credential checks read-only, and exposing one typed contract from both Desktop owners are all good choices. I found two correctness gaps to address before later Composer work builds on this snapshot.

P2 — Model-target facts are assembled from separate, fallible authority reads.

listConnections, getDefaultSlug, and hasCredential can observe different catalog revisions. A concurrent connection update can therefore combine a connection from one revision, a default from another, and credential identity from a third, producing a false repair result. Catalog/default failure also rejects the whole IPC request, so a closed Runtime Host never reaches the advertised runtime_unavailable / model unknown snapshot. An explicit connectionSlug still reads the default unnecessarily and can be blocked by that unrelated failure.

Could the owner expose one resolveModelTarget(requestedSlug?) operation from a single catalog snapshot, returning a discriminated result such as resolved, missing_default, connection_missing, or unknown? This would keep the Core projection from guessing the reason from connection?:.

P2 — Task readiness does not apply the Codex normalization used by the send path.

Existing send/readiness paths normalize openai-codex connections and legacy requested models before calling isConnectionReady. This projection passes the raw connection/model directly, so a legacy gpt-5-codex request can report repair_required even though the actual send path normalizes it to the current model and is ready.

Please reuse normalizeOpenAiCodexConnection and normalizeRequestedModelForReadiness in the Core projection, rather than recreating that policy in the Desktop adapter.

Focused regressions for a closed Runtime Host with catalog rejection, one-snapshot revision consistency, an explicit unknown slug, and legacy Codex model normalization should cover the gaps. The overall direction looks good; these are foundation-level semantic fixes rather than a request to redesign the surface.

@liugddx

liugddx commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

Addressed both correctness gaps in 6ef5a9ac.

  • Replaced the separate connection/default/credential reads at the service boundary with one discriminated resolveModelTarget(requestedSlug?) operation.
  • Added ConnectionStore.getSnapshot() so embedded Desktop resolves default + connection from one file revision.
  • Runtime Host now resolves both from one loadConnectionCatalog() snapshot; an explicit slug does not consult the default.
  • Catalog/resolver rejection is folded into model unknown, so a closed Runtime Host still returns runtime_unavailable instead of rejecting the IPC.
  • Core now owns resolved | missing_default | connection_missing | unknown model-target semantics instead of inferring every absence from connection?:.
  • Core applies normalizeOpenAiCodexConnection and normalizeRequestedModelForReadiness before isConnectionReady, matching the send path.

Added focused regressions for closed Runtime Host + catalog rejection, one-snapshot resolution, explicit unknown slug, and legacy Codex model normalization. Relevant Core/Desktop tests are 14/14 passing; Desktop typecheck, Main/Preload builds, Biome, and diff checks pass.

@jackwener

Copy link
Copy Markdown
Member

Review decision

Direction is right for slice 2 of #2497: pure core projection + thin Main/RH adapter + typed IPC, no premature Composer coupling.

Must-land adjustments:

  1. main deleted embedded boot.ts (M5) — wiring only on Runtime Host path
  2. absent cwd should be workspace_missing / repair_required, not unavailable (ENOENT is user-repairable)

Landing via rebased maintainer PR.

@jackwener

Copy link
Copy Markdown
Member

Landing via rebased PR (Runtime Host only after M5 cutover). Thanks @liugddx!

@jackwener jackwener closed this Aug 8, 2026
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.

3 participants