Skip to content

Conversation

@ciefa
Copy link
Owner

@ciefa ciefa commented Jan 4, 2026

First iteration of the GUI terminal

ciefa added 7 commits January 4, 2026 12:20
Implemented a vanilla Minecraft GUI-based terminal interface for OpenCode
with autumn color theme and real-time SSE streaming support.

Features:
- Terminal-style GUI with ASCII borders and autumn color scheme
- Load and display full session message history
- Real-time streaming of AI responses via SSE events
- Scrollable message history with mouse wheel and arrow keys
- Word wrapping for long messages
- Auto-scroll to bottom for new messages
- Session validation before sending messages

Changes:
- Add OpenCodeGuiScreen: Terminal GUI implementation
- Add /oc gui command to open terminal interface
- Add getSessionMessages() to fetch message history from server
- Add GUI message listeners for real-time delta streaming
- Add GUI response complete listener for proper message spacing
- Remove AI text output from game chat (keep status messages only)
- Update .gitignore to exclude libs/ and *.log files

Technical details:
- Uses vanilla Minecraft Screen, GuiGraphics, and EditBox APIs
- Integrates with existing SSE event system for live updates
- Autumn theme colors from i3 config (orange borders, cream text, dark brown background)
- Message history loaded from /session/{id}/message endpoint
- Listener pattern for GUI updates from background SSE thread
Improved updateLastMessage method to more reliably find and update
the last assistant message during real-time streaming:

- Remove premature addMessage call that caused duplicate prefixes
- Search backwards for [OPENCODE] prefix explicitly
- Better edge case handling for empty messages
- More robust message boundary detection
Implemented full markdown parser with rich text rendering for better
readability of AI responses, code examples, and technical content.

New Features:
- Code blocks with borders and syntax labels (triple backticks)
- Inline code formatting with distinct color
- Bold text rendering with brightened color
- Header formatting with enhanced styling
- List formatting (bullets and numbered)
- Link text parsing and styling
- Multi-segment per-line rendering for mixed formatting

Implementation:
- Created markdown parser package with TextSegment, FormattedLine, MarkdownParser
- TextSegment: Stores styled text with color and formatting flags
- FormattedLine: Represents a line with multiple styled segments and indentation
- MarkdownParser: Parses markdown syntax into formatted structures
- Updated OpenCodeGuiScreen to render formatted lines with multiple colors
- Extended autumn color palette for different content types

Color Scheme:
- Regular text: Cream (#f4e8d0)
- Bold/Headers: Bright orange (#e67700)
- Inline code: Tan (#d4a574)
- Code blocks: Light tan (#c9b896)
- Links: Goldenrod (#daa520)

Technical Details:
- Regex-based parsing for inline formatting
- Support for bold (**text**), code (`code`), links ([text](url))
- Code block detection and preservation
- Automatic color brightening for bold/header text
- Indentation support for code blocks and lists
Replaced hardcoded MAX_VISIBLE_LINES (20) with dynamic calculation
based on actual available screen height. Terminal now uses full
available space to display messages instead of being artificially
limited to 20 lines.

Changes:
- Removed MAX_VISIBLE_LINES constant
- Calculate maxVisibleLines dynamically in render method
- Updated scroll handlers to use dynamic line calculation
- Terminal now adapts to any screen size/resolution

The terminal will now fill the entire available space between the
title bar and input field, significantly improving readability.
Replaced muted brown tones with a richer, more varied autumn palette
featuring reds, burnt oranges, golden yellows, and copper tones.

New Color Scheme (Option 2 - Expanded Autumn):
- Background: Warm dark brown (#1a1210)
- Borders/Prompt: Burnt orange (#ff8c42)
- Regular text: Warm white/cornsilk (#fff8dc)
- Bold/Headers: Rust red (#b7410e)
- Inline code: Golden yellow (#ffd700)
- Code blocks: Copper (#d2691e)
- Links: Burgundy (#800020)
- User messages: Light salmon (#ffa07a)
- System messages: Amber (#ffbf00)
- Assistant messages: Dark orange (#ff8c00)
- Error messages: Crimson red (#dc143c)
- Input box border: Darker copper (#4a2f1e)

The new palette provides much better contrast and visual interest
while maintaining the cozy autumn aesthetic. Colors are significantly
more vibrant and varied compared to the previous muted brown theme.
Replaced Unicode character borders (┌─┐│└┘) with clean graphical
rectangular borders using fill() for better appearance and alignment.
Added proper text clipping to prevent overflow beyond terminal bounds.

Border Improvements:
- Replaced text-based borders with solid 2px graphical rectangles
- Clean, professional appearance with perfect alignment
- No more misalignment issues from font rendering
- Better performance (no text rendering for borders)
- Simplified title (removed decorative characters)

Text Overflow Fixes:
- Added scissor/clipping region to message area
- Text is truncated with "..." if too long for available width
- Code blocks wrap at 120 characters per line
- Proper margin calculations inside borders (8px padding)
- Boundary checking in renderFormattedLine method

Layout Adjustments:
- Border thickness: 2px
- Message area margins: 8px inside borders
- Title positioned at y+8 from top border
- Scroll indicator positioned inside bottom-right corner
- All text now properly contained within terminal bounds
Reverted terminal dimensions to balanced 40px margins after previous
adjustment caused scroll indicator to appear outside borders.

Changes:
- Restored terminal margins to 40px (balanced layout)
- Fixed scroll indicator position to Y-40 (above input field)
- Scroll text now properly positioned inside terminal borders
- Input field has proper spacing from bottom border

The scroll indicator now appears above the input field in the
bottom-right corner, well within the terminal boundaries.
@ciefa ciefa merged commit 1c5dea5 into main Jan 4, 2026
2 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.

2 participants