@makerbi/remodex 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makerbi/remodex",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "Local bridge between Codex and the Remodex mobile app. Run `remodex up` to start.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/bridge.js CHANGED
@@ -55,6 +55,7 @@ const { createBridgeSecureTransport } = require("./secure-transport");
55
55
  const { createRolloutLiveMirrorController } = require("./rollout-live-mirror");
56
56
  const {
57
57
  isContextualUserText,
58
+ isThreadTurnStateProbeRequest,
58
59
  isUserRoleItem,
59
60
  readUserItemText,
60
61
  sanitizeUserRoleItem,
@@ -577,6 +578,33 @@ function threadTurnsListHandoffDescriptor(cursor) {
577
578
  return { anchorTurnId, token };
578
579
  }
579
580
 
581
+ // The bounded canonical page can read a busy mirrored run as closed for a
582
+ // beat, which used to flap the phone's running state. When the rollout mirror
583
+ // is actively tailing a real turn, ride its id along on the turn-state probe
584
+ // as an advisory field; history pages stay untouched.
585
+ function annotateTurnStateProbeWithMirrorActiveTurn(request, response, getMirrorActiveTurnId) {
586
+ if (!isThreadTurnStateProbeRequest(request)) {
587
+ return response;
588
+ }
589
+ const params = request?.params || {};
590
+ const threadId = normalizeNonEmptyString(params.threadId)
591
+ || normalizeNonEmptyString(params.thread_id);
592
+ const mirrorActiveTurnId = threadId ? getMirrorActiveTurnId?.(threadId) : null;
593
+ const result = response?.result;
594
+ if (!mirrorActiveTurnId || !result || typeof result !== "object" || Array.isArray(result)) {
595
+ return response;
596
+ }
597
+ // Page responses can come from the fast-page cache: never mutate a shared
598
+ // object, or the annotation would outlive the mirror on later replays.
599
+ return {
600
+ ...response,
601
+ result: {
602
+ ...result,
603
+ remodexMirrorActiveTurnId: mirrorActiveTurnId,
604
+ },
605
+ };
606
+ }
607
+
580
608
  function canonicalThreadTurnsListRequest(request) {
581
609
  const params = { ...(request?.params || {}) };
582
610
  delete params.remodexRequireCanonical;
@@ -1433,6 +1461,11 @@ function startBridge({
1433
1461
  function sendBridgeManagedThreadTurnsListResponse(request, response, sendResponse, {
1434
1462
  skipJsonlArtifactAugmentation = false,
1435
1463
  } = {}) {
1464
+ response = annotateTurnStateProbeWithMirrorActiveTurn(
1465
+ request,
1466
+ response,
1467
+ (threadId) => rolloutLiveMirror?.getActiveTurnId(threadId) || null
1468
+ );
1436
1469
  const finalSanitizeContext = buildThreadTurnsListRelaySanitizeContext(request, {
1437
1470
  skipJsonlArtifactAugmentation,
1438
1471
  });
@@ -5109,6 +5142,7 @@ function shouldSuppressRolloutMirrorForThread(
5109
5142
  }
5110
5143
 
5111
5144
  module.exports = {
5145
+ annotateTurnStateProbeWithMirrorActiveTurn,
5112
5146
  buildThreadTurnsListRelaySanitizeContext,
5113
5147
  buildHeartbeatBridgeStatus,
5114
5148
  buildRelayAccessTokenHeaders,