opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Add session position indicator in header and refactor sibling logic

Open terakael opened this issue 1 month ago • 5 comments

I often get lost when switching between subagents. This just adds a simple indicator so that we can see at a glance where we're at.

  • Add [current/total] indicator in session header to show position among parent/siblings
  • Extract duplicate sibling-finding logic into sync.session.siblings() helper
  • Update header.tsx to display position indicator for sessions with siblings
  • Refactor moveChild() in index.tsx to use centralized siblings() method
  • Improves navigation awareness when working with multiple subagent sessions
image

terakael avatar Dec 10 '25 05:12 terakael

@rekram1-node any chance of a review on this? Relatively minor change for a pretty convenient feature

terakael avatar Dec 11 '25 05:12 terakael

/review

rekram1-node avatar Dec 18 '25 06:12 rekram1-node

lgtm

github-actions[bot] avatar Dec 18 '25 06:12 github-actions[bot]

Hmm this PR merged last night has slightly modified the logic: https://github.com/sst/opencode/pull/5680

The PR changed the ordering to be backwards and I'm trying to understand why - it felt fine to me previously. But the merge has made it so the parent node is now N/N instead of 1/N. I can modify the logic of this PR to reflect the ordering change, but I want to get a better understanding of why it changed before I do that.

Until then I don't think this is ready to merge

terakael avatar Dec 18 '25 06:12 terakael

@rekram1-node

On my quick investigation:

PR #5680 changed subagent navigation from chronological (oldest→newest) to reverse-chronological (newest→oldest).

Before the merge:

  • Array sorted descending by ID: [main, sub1, sub2] (oldest first)
  • Pressing "Next" from main → goes to sub1, then sub2
  • Position indicator would show: main=1/3, sub1=2/3, sub2=3/3

Now:

  • Subagent IDs use descending timestamps (newer session = smaller ID)
  • Array sorted ascending by ID: [sub2, sub1, main] (newest first)
  • Pressing "Next" from main → jumps to sub2 (newest)
  • Position indicator shows: main=3/3, sub1=2/3, sub2=1/3

I understand the idea of switching from main directly to the newest agent by pressing right, as it's likely the most relevant.

It sort of breaks my mental model of having a list of agents though where right moves forward in time - maybe it's personal preferene.

Which navigation order provides better UX I wonder? Personally I prefer the previous logic.

terakael avatar Dec 18 '25 06:12 terakael