Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(pane): read maybeSubmitted from the magmux reply

Jack Rudenko2b03645c0990
diff --git a/packages/cli/src/pane/input-gate.ts b/packages/cli/src/pane/input-gate.ts
index 7130fb95..528909c7 100644
--- a/packages/cli/src/pane/input-gate.ts
+++ b/packages/cli/src/pane/input-gate.ts
@@ -161,8 +161,9 @@ export type RetypeCause = "terminal_reset" | "never_drawn";
/**
* The phrase both "it is unknown whether the text was submitted" `text_mismatch` details
- * carry (inputgate_send.go:884 leftBox, :893 convMoved). There is no machine field for it
- * (asked as M11), so this prose is the contract; F14b makes the pinned binary emit it.
+ * carry (inputgate_send.go:884 leftBox, :893 convMoved). magmux 0.17.0 answers M11 with the
+ * machine field `maybeSubmitted: true` on both; this prose is read only for a reply that
+ * lacks the field.
*/
export const MAYBE_SUBMITTED_MARKER = "check the conversation before sending";
@@ -288,7 +289,9 @@ function notAcceptedOutcome(r: Extract<MagmuxReply, { ok: false }>): SendOutcome
return {
kind: "not_accepted",
reason: "text_mismatch",
- maybeSubmitted: r.error.includes(MAYBE_SUBMITTED_MARKER),
+ // The field is the contract (magmux 0.17.0, M11). The text match is a fallback for a
+ // reply without the field, so a magmux that predates it is not read as "not submitted".
+ maybeSubmitted: r.maybeSubmitted === true || r.error.includes(MAYBE_SUBMITTED_MARKER),
typed,
detail: r.error,
};
diff --git a/packages/cli/src/pane/magmux-client.ts b/packages/cli/src/pane/magmux-client.ts
index 28bf8585..0d9af6c7 100644
--- a/packages/cli/src/pane/magmux-client.ts
+++ b/packages/cli/src/pane/magmux-client.ts
@@ -18,18 +18,29 @@ import { Socket } from "node:net";
/**
* A failure may carry `reason`, magmux's machine-readable sub-code (`busy` → `starting`,
* `dialog:permission`, …; `not_accepted` → `still_in_box`, …), and `typed: true`, which
- * says bytes of this request reached the pane before it failed. magmux omits both when they
- * do not apply (README "Request/response"), and so does this type: a failure without them
- * is the reply it always was. `input-gate.ts` reads them; `code` alone still decides
- * everything else.
+ * says bytes of this request reached the pane before it failed. Since 0.17.0 a
+ * `text_mismatch` may also carry `maybeSubmitted: true`: the text may already have been
+ * submitted without magmux's Enter. magmux omits all three when they do not apply (README
+ * "Request/response"), and so does this type: a failure without them is the reply it
+ * always was. `input-gate.ts` reads them; `code` alone still decides everything else.
*/
export type MagmuxReply<T = Record<string, unknown>> =
| { ok: true; result: T }
- | { ok: false; code: string; error: string; reason?: string; typed?: boolean };
+ | {
+ ok: false;
+ code: string;
+ error: string;
+ reason?: string;
+ typed?: boolean;
+ maybeSubmitted?: boolean;
+ };
type MagmuxFailure = Extract<MagmuxReply, { ok: false }>;
-/** A wire failure line → the reply, keeping `reason` and `typed` only when magmux sent them. */
+/**
+ * A wire failure line → the reply, keeping `reason`, `typed` and `maybeSubmitted` only
+ * when magmux sent them.
+ */
function failureOf(m: Record<string, unknown>): MagmuxFailure {
const out: MagmuxFailure = {
ok: false,
@@ -38,6 +49,7 @@ function failureOf(m: Record<string, unknown>): MagmuxFailure {
};
if (typeof m.reason === "string" && m.reason) out.reason = m.reason;
if (m.typed === true) out.typed = true;
+ if (m.maybeSubmitted === true) out.maybeSubmitted = true;
return out;
}