[PR #999] [MERGED] Fix: failed to open session #9777

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

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/999
Author: @rekram1-node
Created: 7/15/2025
Status: Merged
Merged: 7/15/2025
Merged by: @adamdotdevin

Base: devHead: fix/failed-to-open-session


📝 Commits (1)

  • 24b57d2 fix: failed to open session

📊 Changes

2 files changed (+8 additions, -2 deletions)

View changed files

📝 packages/tui/internal/app/app.go (+5 -2)
📝 packages/tui/internal/tui/tui.go (+3 -0)

📄 Description

Fixes: #732

Explanation of the issue:

In packages/tui/internal/app/app.go we have SendChatMessage. In the event of a session being new it will create one, then it added a append(cmds, util.CmdHandler(SessionSelectedMsg)).

Due to the ordering of the tea.Batch the SessionSelectedMsg event is emitted and in some cases handled, before any messages are saved in the backend. Thus the messages, err := a.app.ListMessages(context.Background(), msg.ID) would return an error since no messages have been sent.

It seems like this issue also could have applied to /init. So the easy fix here was just making a separate event/msg for when we create a session and that allows us to not list messages for a session that doesn't have any yet!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/999 **Author:** [@rekram1-node](https://github.com/rekram1-node) **Created:** 7/15/2025 **Status:** ✅ Merged **Merged:** 7/15/2025 **Merged by:** [@adamdotdevin](https://github.com/adamdotdevin) **Base:** `dev` ← **Head:** `fix/failed-to-open-session` --- ### 📝 Commits (1) - [`24b57d2`](https://github.com/anomalyco/opencode/commit/24b57d25f585ffc7b7c196e6fc79c9f12337346c) fix: failed to open session ### 📊 Changes **2 files changed** (+8 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/tui/internal/app/app.go` (+5 -2) 📝 `packages/tui/internal/tui/tui.go` (+3 -0) </details> ### 📄 Description Fixes: #732 Explanation of the issue: In `packages/tui/internal/app/app.go` we have SendChatMessage. In the event of a session being new it will create one, then it added a `append(cmds, util.CmdHandler(SessionSelectedMsg))`. Due to the ordering of the tea.Batch the SessionSelectedMsg event is emitted and in some cases handled, before any messages are saved in the backend. Thus the `messages, err := a.app.ListMessages(context.Background(), msg.ID)` would return an error since no messages have been sent. It seems like this issue also could have applied to /init. So the easy fix here was just making a separate event/msg for when we create a session and that allows us to not list messages for a session that doesn't have any yet! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:09 -05:00
yindo closed this issue 2026-02-16 18:14:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9777