Skip to content

Conversation

@shuv1337
Copy link
Collaborator

@shuv1337 shuv1337 commented Jan 4, 2026

Summary

Merge shuvcode-dev into integration with fixes for default agent configuration and TUI improvements.

Changes

Fixes

Features

  • Display message timestamps on assistant messages when showTimestamps preference is enabled

Tests

  • Add 3 new test cases for default_agent configuration:
    • Verify config sets default:true on specified agent
    • Verify fallback to build agent when invalid agent specified
    • Verify default to build agent when no config present

Documentation

Breaking Changes

None

Testing

Existing tests cover changes. All 8 agent tests pass.

Greptile Summary

This PR fixes the default agent configuration not being respected in the TUI, adds timestamp display for assistant messages, and includes comprehensive test coverage for the default agent feature. The core fix is a single-line change that properly respects the default property set by Agent.state() when initializing the current agent in the TUI context, aligning with upstream opencode behavior and the server-side Agent.defaultAgent() function.

Key Changes:

  • Fixed default agent initialization in TUI by checking for the default property instead of always using the first agent
  • Added timestamp display capability for assistant messages when showTimestamps preference is enabled
  • Added 3 new test cases covering: custom default agent configuration, fallback to build agent when invalid agent specified, and default behavior when no config present
  • Included comprehensive planning documentation for issue Default agent does not apply in shuvcode #255

All changes are minimal, focused, and follow existing code patterns. Tests validate the default agent logic at both the configuration level and the public API level.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The PR introduces minimal, targeted changes that directly address a well-documented bug. The single-line fix in local.tsx uses a safe optional chaining pattern that gracefully falls back to the original behavior if no default agent is found. The timestamp display uses existing utility methods and follows established conditional rendering patterns. All three new test cases are properly structured, use consistent test patterns, and provide clear validation of the fixed functionality. No type errors, no breaking changes, and the fix aligns with upstream opencode implementation.
  • No files require special attention

Important Files Changed

Filename Overview
packages/opencode/src/cli/cmd/tui/context/local.tsx Fixed default agent initialization in TUI. Changed from always selecting first agent to properly respecting the default property set by Agent.state() when default_agent config is present. Falls back to first agent if no default is found. This aligns with the server-side Agent.defaultAgent() function.
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx Added timestamp display feature for assistant messages when showTimestamps preference is enabled. Uses existing Locale.todayTimeOrDateTime() utility method to format timestamps. Follows existing pattern for conditional display with Show component and proper muted text styling.
packages/opencode/test/agent/agent.test.ts Added 3 comprehensive test cases for default_agent configuration: (1) verifies default property is set on specified custom agent and respected by defaultAgent(), (2) verifies fallback to build agent when invalid agent specified, (3) verifies build agent is default when no config present. Tests properly use tmpdir fixture and Instance.provide pattern consistent with existing tests.

Sequence Diagram

sequenceDiagram
    participant User
    participant Config as opencode.json
    participant Agent as Agent.state()
    participant TUI as TUI Context
    participant LocalContext as local.tsx

    User->>Config: Set default_agent: "orchestrator"
    Config->>Agent: Load configuration
    Agent->>Agent: Mark orchestrator with default: true
    Agent->>TUI: Emit agent list with default property
    TUI->>LocalContext: Initialize agent store
    LocalContext->>LocalContext: Find agent with default: true
    LocalContext->>LocalContext: Use orchestrator as current agent
    LocalContext->>TUI: Display orchestrator as selected agent
    TUI->>User: Show TUI with orchestrator selected
    
    Note over LocalContext: Fallback: If no default found, use agents()[0]
Loading

Look for agent with default:true instead of always using first agent.
This aligns with upstream fix (anomalyco#5843).

Fixes #255
Show message creation timestamp next to duration when showTimestamps
preference is enabled.
Tests verify:
- default_agent config sets default:true on specified agent
- Invalid default_agent falls back to build agent
- No default_agent configured defaults to build agent
@shuv1337 shuv1337 merged commit 5c21cac into integration Jan 4, 2026
3 checks passed
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.

Default agent does not apply in shuvcode

2 participants