Skip to content

runtime: clear the steer foreground marker on the mismatch path and keep the borrow's regression case in the repository #3482

Backlog

Description

@Birfy

Follow-up to the review of PR #3474 (head 77a2eb132ac8c2a53b579b960667bed94ce1188e, merged as b333cd019287129e85dd5690ae3003168070a2c9). Both items were found during review and recorded in that PR's body instead of being fixed there, because another commit would have voided the CI evidence on that head.

1. The steerForeground marker is not cleared on the mismatch path

runtime/flybot-workspace-web/lib/native-chat.js writes a marker into bot.flybotWorkspace.steerForeground when the bridge lends the bot's foreground to a private chat for a steer handoff. The restore path deletes it only on the path that actually restores. Where ownsPrivateChatPart says the part is not ours, or where chatOf(bot.id) no longer matches, the code continues without deleting the marker.

Effect: the flag stays on the bot record and is written back to disk on every subsequent state save (the record is part of state.bots). It never touches bot.sessionId and is never read as a session id, so it cannot re-point a foreground — this is hygiene, not a correctness bug that changes behaviour today. It becomes a real problem the moment anything starts reading the flag as "a borrow is currently active".

Expected: every exit path of the restore leaves no marker behind, including the mismatch and not-ours cases.

2. The borrow's regression case is not in the repository

The six-case local harness that covers the borrow (the value written to the record, the exact restore, a host write inside the window not being overwritten, five self-heal cases, teardown) lives in a scratch file outside the tree. Nothing in tests/ or runtime/flybot-workspace-web/test/ covers the borrow, so a future change to native-chat.js or the bridge can break it with CI green.

Expected: the case lives next to the other native-chat cases, runs in the normal suite, and fails if the marker is left behind.

Scope

  • runtime/flybot-workspace-web/lib/native-chat.js (marker clearing)
  • runtime/flybot-workspace-web/test/native-chat-threads.test.js (or a new test file next to it) for the regression case

One reviewable slice, both items, because the test is what pins the fix. Do not fold in the borrow window's breadth (the foreground is held for a whole replacement turn) — that is a design note recorded in #3474, not a defect.

Acceptance

  • A case that drives the mismatch path and the not-ours path asserts no steerForeground key remains on the record afterwards.
  • The borrow's happy path is covered in-tree: the value is on the record while the handoff is in flight, the previous value is restored exactly afterwards, and a host write inside the window is not overwritten.
  • Local suite green, with the command and the counts in the PR body; CI green is read separately from the check runs.

Related #3474

Activity

  1. added
    agent-ready
    agent-working
    on Dec 1, 2026
  2. Birfy commented on Dec 1, 2026

    @Birfy
    CollaboratorAuthor

    Claimed. Branch: dev/3482-steer-foreground-reset, cut from main at b333cd019287129e85dd5690ae3003168070a2c9 (tree 37b11b9981c6d283762d9c8e9d6330eae147bcb6).

    Assignee: Runtime Dev. The two items are one slice because the in-tree regression case is what pins the marker fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyagent-working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions