[PR #8430] fix(desktop): "load more" button behavior in desktop sidebar #12743

Closed
opened 2026-02-16 18:17:38 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8430

State: closed
Merged: Yes


What does this PR do?

Fixes #8426

This is what seemed to be happening:

When the client fetched sessions for a given project, it used the /session endpoint. This endpoint did not filter by project/directory, so it was returning sessions that were not a part of the project connected to a given "load more" button. Then, this createMemo used the length of that list of sessions to determine pagination. So, even if a project only had one session, it could receive dozens of other sessions (from other projects).

Another issue was that the frontend was filtering out non-root/child sessions here. Because the backend did not differentiate between root/child sessions, when the frontend received them, there were sometimes child sessions that counted toward the pagination limit, but then got filtered out, resulting in what looked like a no-op when clicking the load more button.

This PR checks a project's directory when pulling in its sessions and also filters out child sessions in the backend to make pagination calculations line up with actually-rendered sessions.

I feel that there are probably better long-term solutions for this, but this is a pretty small change and has been working fine for me. Would love to hear the team's perspective/ideas.

Before fix:

https://github.com/user-attachments/assets/faaca941-0070-436a-ac31-b061ce6dc0dd

After fix:

https://github.com/user-attachments/assets/3e053820-979c-4672-970b-54c535058672

How did you verify your code works?

Ran tests and manually verified that projects in different states (e.g. fresh vs. old/complex ones) worked as expected

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8430 **State:** closed **Merged:** Yes --- ### What does this PR do? Fixes #8426 This is what seemed to be happening: When the client fetched sessions for a given project, it used [the `/session` endpoint.](https://github.com/anomalyco/opencode/blob/76b10d85eea11a3bac51248b84daae034dec2c3a/packages/opencode/src/server/server.ts#L707-L747) This endpoint did not filter by project/directory, so it was returning sessions that were not a part of the project connected to a given "load more" button. Then, [this createMemo](https://github.com/anomalyco/opencode/blob/76b10d85eea11a3bac51248b84daae034dec2c3a/packages/app/src/pages/layout.tsx#L947) used the length of that list of sessions to determine pagination. So, even if a project only had one session, it could receive dozens of other sessions (from other projects). Another issue was that the frontend was filtering out non-root/child sessions [here](https://github.com/anomalyco/opencode/blob/76b10d85eea11a3bac51248b84daae034dec2c3a/packages/app/src/pages/layout.tsx#L946). Because the backend did not differentiate between root/child sessions, when the frontend received them, there were sometimes child sessions that counted toward the pagination limit, but then got filtered out, resulting in what looked like a no-op when clicking the load more button. This PR checks a project's directory when pulling in its sessions and also filters out child sessions in the backend to make pagination calculations line up with actually-rendered sessions. I feel that there are probably better long-term solutions for this, but this is a pretty small change and has been working fine for me. Would love to hear the team's perspective/ideas. ### Before fix: https://github.com/user-attachments/assets/faaca941-0070-436a-ac31-b061ce6dc0dd ### After fix: https://github.com/user-attachments/assets/3e053820-979c-4672-970b-54c535058672 ### How did you verify your code works? Ran tests and manually verified that projects in different states (e.g. fresh vs. old/complex ones) worked as expected
yindo added the pull-request label 2026-02-16 18:17:38 -05:00
yindo closed this issue 2026-02-16 18:17:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12743