Skip to content

tree load: end a turn by its turnId, not by whichever start is oldest #696

Closed

Description

@Birfy

Summary

The tree's load tracker cannot tell two open turns apart, so turn.end ends the oldest start. That is the one case where the number is supposed to help: a Bot with two turns open, the newer one finishing first, now reports the newer turn's age as "how long this Bot has been open" — the stall the tracker exists to surface (#624) reads as recent.

Where

plugins/tree/index.js:36-37 passes only the Bot id:

fb.onFeed('turn.start', e => { tree.noteTurnStart(e?.botId); refreshParentPrompt(e?.botId) }),
fb.onFeed('turn.end',   e => { tree.noteTurnEnd(e?.botId);   refreshParentPrompt(e?.botId) }),

The feed event itself carries turnId (core/src/client/flybot-feed.js, the turn.start / turn.end payloads), and plugins/tree/src/load.js keeps one start time per open turn with end(id) dropping the oldest — the shift is deliberate (a turn id is not passed in), but it means an out-of-order finish resets openFor() to the wrong start.

Change

  • load.js: start(id, turnId) / end(id, turnId) store the id with the start time; end removes the matching turn when the id is known, and keeps the current shift-oldest behaviour when it is missing or does not match (unmatched fallback — old clients, a dropped turn.start).
  • plugins/tree/index.js: pass e?.turnId on both feeds. openFor(id, now) and everything list_children returns keep their current shape.

Acceptance

  • Two turns open (t1 at 00:00, t2 at 00:30), end(id, 't2') → openFor still reports the age of t1 (the older start), and of(id) is 1.
  • end(id, 'nope') (unknown id) and end(id) (no id) each remove exactly one turn and leave the older start standing.
  • Revert the id pairing (keep only the shift) → the first case goes red; node --test plugins/tree/test/ green at the tip.
  • The openForMs / stalled wording from A Bot session stops reading its queue while still reporting load: 1 (Dev: 11 unread, zero progress) #624 is unchanged, including its documented "time-based hint" limit.

Tier: plugins/tree/** → T2 (PASS at the tip, then the queue).

Activity

  1. added
    bugSomething isn't working
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    area:automationScheduled tasks and automation
    on Oct 22, 2026
  2. Birfy commented on Oct 22, 2026

    @Birfy
    CollaboratorAuthor

    Claiming this one. Branch fix/696-load-pairs-by-turn-id.

    feed already carries turnId, and #624 threw it away: load.js kept only start times, so end() dropped the oldest open turn no matter which one actually ended. Two turns open with the later one ending first, and openFor reports the newer turn's age — exactly the state #624 exists to expose. The tracker will key each open turn by turnId when it has one, with the oldest-first drop left as the fallback for an end without a matching id, so an unknown or missing id still only decrements by one.

    (The first version of this comment lost its inline code to a shell expansion; this is the same text with the identifiers intact.)

  3. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    and removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Oct 22, 2026
  4. self-assigned this
    on Oct 22, 2026
  5. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:automationScheduled tasks and automationbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions