Skip to content

Conversation

@35C4n0r
Copy link
Collaborator

@35C4n0r 35C4n0r commented Nov 12, 2025

Example - Opencode agent:

running -> stable (we send initial prompt on first stable) -> running (this is the part where it finally shows the splash screen and the agent is ready to accept input).

The PR tries to fix this by taking into account whether the input box is visible or not.

@35C4n0r 35C4n0r self-assigned this Nov 12, 2025
@35C4n0r 35C4n0r marked this pull request as draft November 12, 2025 03:42
@35C4n0r 35C4n0r marked this pull request as ready for review November 12, 2025 13:25
@github-actions
Copy link

✅ Preview binaries are ready!

To test with modules: agentapi_version = "agentapi_142" or download from: https://github.com/coder/agentapi/releases/tag/agentapi_142

@35C4n0r 35C4n0r requested review from johnstcn and matifali November 12, 2025 13:48
Copy link
Collaborator

@hugodutka hugodutka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test in conversation_test.go to check if the new logic behaves correctly.

@35C4n0r
Copy link
Collaborator Author

35C4n0r commented Nov 18, 2025

resolved all the comments.

func TestInitialPromptReadiness(t *testing.T) {
now := time.Now()
changing := st.ConversationStatusChanging
stable := st.ConversationStatusStable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO these add indirection and make it harder to read the tests. I'd suggest inlining the original values instead.

// Agent becomes ready
c.AddSnapshot("ready")
c.AddSnapshot("ready")
c.AddSnapshot("ready")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to test snapshot interval/stability length in all of these tests? I imagine we could simplify by changing the config and only add a single snapshot.

Note: Since we're never testing the opposite (assert.False(..., c.Status())), testing snapshot/stability this way doesn't actually add any value.

// Screen changes should cause changing status
c.AddSnapshot("changing")
assert.Equal(t, changing, c.Status())
assert.True(t, c.AgentReadyForInitialPrompt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If screen is changing, can we really assume ready for initial prompt is true?


if !c.InitialPromptSent && !c.AgentReadyForInitialPrompt {
if len(snapshots) > 0 && c.cfg.IsAgentReadyForInitialPrompt(snapshots[len(snapshots)-1].screen) {
c.AgentReadyForInitialPrompt = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Consider resetting this after initial prompt is sent.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants