Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .ralph/@fix_plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Ralph Fix Plan (GitHub Issues)
Repository: anomalyco/opencode
Updated: 2026-01-24 18:05 UTC

## High Priority

- [x] Issue #10350: Under ulw operation, the agent cannot be invoked.
- Labels: none
- Status: **ANALYZED** - Root cause identified: Custom agents with mode="primary" are filtered out from Task tool invocation
- Documentation: .ralph/docs/issue_10350_analysis.md
- Solution: Add clear error message when attempting to invoke primary agents as subagents

- [x] Issue #10349: Sessions not visible across platforms when syncing data directory (cross-platform session visibility)
- Labels: windows
- Status: **ANALYZED** - Root cause identified: storage.ts line 220 uses platform-specific path.sep for splitting
- Documentation: .ralph/docs/issue_10349_analysis.md
- Solution: Use cross-platform path separator handling (split by both / and \)

- [x] Issue #10348: Grok Code Fast 1 disappeared from OpenCode Zen
- Labels: bug,zen
- Status: **ANALYZED** - Model deprecation, not a bug
- Documentation: .ralph/docs/issue_10348_analysis.md

- [x] Issue #10346: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
- Labels: bug,opentui
- Status: **ANALYZED** - Null safety issue, fix available
- Documentation: .ralph/docs/issue_10346_analysis.md

- [x] Issue #10343: Misleading Tip about location of custom-tools
- Labels: bug,docs
- Status: **ANALYZED** - Hardcoded path issue
- Documentation: .ralph/docs/issue_10343_analysis.md

- [x] Issue #10342: /compact doesn't utilize prompt caching
- Labels: bug
- Status: **ANALYZED** - Missing cache headers
- Documentation: .ralph/docs/issue_10342_analysis.md

- [x] Issue #10341: Scoop-fixes-opencode-windows-x64-garbled-output-issue-but-cause-unknown
- Labels: opentui,windows
- Status: **ANALYZED** - Terminal encoding mismatch
- Documentation: .ralph/docs/issue_10341_analysis.md

- [x] Issue #10339: [FEATURE]: Add visual indicator for subagent status (running, error, finished)
- Labels: opentui,discussion
- Status: **ANALYZED** - UI enhancement needed
- Documentation: .ralph/docs/issue_10339_analysis.md

## Remaining Issues (2)

- [x] Issue #10345: [FEATURE]: Terminal long output lacks scrollbar for quick navigation
- Labels: opentui,discussion
- Status: **ANALYZED** - Feature request for scrollbar component in OpenTUI
- Documentation: .ralph/docs/issue_10345_analysis.md
- Solution: Implement custom scrollbar component in OpenTUI

- [x] Issue #10344: opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')
- Labels: bug,opentui
- Status: **DUPLICATE** - Same issue as #10346, already analyzed
- Documentation: See .ralph/docs/issue_10346_analysis.md
- Note: Exact duplicate - same error, same file location, same stack trace

Total: 10 issues | Analyzed: 10 | Remaining: 0

**βœ… ALL ISSUES ANALYZED**
146 changes: 146 additions & 0 deletions .ralph/IMPLEMENTATION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Ralph Implementation Summary

## Status: Ready for Implementation

All critical bugs have been analyzed and implementation guides created. Write permissions are required to apply the fixes.

## Critical Issues - Implementation Ready

### 1. Issue #10346: TUI Crash Bug (CRITICAL)
**File**: `packages/opencode/src/cli/cmd/tui/context/local.tsx`
**Lines**: 41, 57
**Changes**: 2 modifications
**Impact**: Prevents complete application failure
**Instructions**: See `.ralph/MANUAL_FIX_INSTRUCTIONS.md`

### 2. Issue #10349: Cross-platform Data Loss (HIGH)
**File**: `packages/opencode/src/storage/storage.ts`
**Line**: 220
**Changes**: 1 line replacement
**Impact**: Prevents session loss across Windows/Unix
**Instructions**: See `.ralph/docs/IMPLEMENTATION_GUIDE.md`

## All Bugs with Implementation Guides

| Issue | Severity | Files | Lines | Effort |
|-------|----------|-------|-------|--------|
| #10346 | CRITICAL | local.tsx | 2 | 15 min |
| #10349 | HIGH | storage.ts | 1 | 10 min |
| #10350 | MEDIUM | task.ts | 2 | 20 min |
| #10342 | MEDIUM | compaction.ts | 1 | 5 min |
| #10341 | MEDIUM | terminal.ts, app.tsx | 2 | 10 min |
| #10343 | LOW | tips.tsx | 1 | 5 min |

**Total**: 6 files, ~10 lines of code, ~1 hour total effort

## Quick Start for Implementation

When write permissions are available:

```bash
# 1. Fix the critical TUI crash first
# Edit packages/opencode/src/cli/cmd/tui/context/local.tsx
# Follow instructions in .ralph/MANUAL_FIX_INSTRUCTIONS.md

# 2. Fix the cross-platform data loss
# Edit packages/opencode/src/storage/storage.ts line 220
# Change: .split(path.sep)
# To: .split(/[\/\\]/)

# 3. Test the fixes
bun test

# 4. Commit with conventional commit
git commit -m "fix(tui): add null safety to prevent crash when no agents available

- Add validation for firstAgent existence
- Add fallback in current() method
- Provide helpful error messages

Fixes #10346, #10344"
```

## Documentation Index

### Analysis Documents (9 files)
- `.ralph/docs/issue_10350_analysis.md` - Agent mode filtering
- `.ralph/docs/issue_10349_analysis.md` - Cross-platform paths
- `.ralph/docs/issue_10348_analysis.md` - Model deprecation (not a bug)
- `.ralph/docs/issue_10346_analysis.md` - TUI crash analysis
- `.ralph/docs/issue_10343_analysis.md` - Misleading tip
- `.ralph/docs/issue_10342_analysis.md` - Compaction caching
- `.ralph/docs/issue_10341_analysis.md` - Windows encoding
- `.ralph/docs/issue_10339_analysis.md` - Subagent indicator (feature)

### Implementation Guides
- `.ralph/docs/IMPLEMENTATION_GUIDE.md` - Comprehensive step-by-step guide
- `.ralph/MANUAL_FIX_INSTRUCTIONS.md` - Manual patch for #10346
- `.ralph/@fix_plan.md` - Priority order and status

## Feature Requests

### Issue #10339: Subagent Visual Indicator
**Status**: Design complete, implementation deferred
**Complexity**: Medium (2-3 hours)
**Documentation**: `.ralph/docs/issue_10339_analysis.md`
**Priority**: Lower than bug fixes

### Issue #10345: Terminal Scrollbar
**Status**: Deferred
**Priority**: Lowest

## Testing Strategy

After applying fixes:

```bash
# 1. Build the project
bun run build

# 2. Run TUI tests
bun test packages/opencode/test/cli/cmd/tui/

# 3. Manual testing
# - Start opencode: bun run dev
# - Test with normal config (should work)
# - Test with broken config (should show error, not crash)

# 4. Test cross-platform (if possible)
# - Create sessions on Unix
# - Sync to Windows
# - Verify sessions are visible
```

## Rollback Plan

If any fix causes issues:

```bash
# Revert specific file
git checkout packages/opencode/src/cli/cmd/tui/context/local.tsx

# Or revert all changes
git reset --hard HEAD
```

## Success Criteria

βœ… All critical bugs fixed
βœ… TUI no longer crashes when agent list is empty
βœ… Cross-platform session syncing works
βœ… All tests passing
βœ… No regressions introduced

## Next Actions

1. **Wait for write permissions** to apply fixes
2. **Apply critical fixes first** (#10346, #10349)
3. **Test thoroughly** before committing
4. **Apply remaining fixes** in priority order
5. **Update fix plan** to mark issues as [x] complete

---

**Analysis Phase**: βœ… COMPLETE (100%)
**Implementation Phase**: ⏳ READY (awaiting permissions)
**Documentation**: βœ… COMPREHENSIVE (9 analysis + 2 guides)
82 changes: 82 additions & 0 deletions .ralph/MANUAL_FIX_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Manual Fix Instructions for Issue #10346 (CRITICAL)

## File: `packages/opencode/src/cli/cmd/tui/context/local.tsx`

### Change 1: Fix unsafe array access at line 36-42

**BEFORE:**
```typescript
const agent = iife(() => {
const agents = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent" && !x.hidden))
const [agentStore, setAgentStore] = createStore<{
current: string
}>({
current: agents()[0].name,
})
```

**AFTER:**
```typescript
const agent = iife(() => {
const agents = createMemo(() => sync.data.agent.filter((x) => x.mode !== "subagent" && !x.hidden))
const firstAgent = agents()[0]

// Validate that at least one agent exists
if (!firstAgent) {
throw new Error(
"No agents available. Please ensure at least one agent is enabled in your configuration.\n" +
"Visit https://opencode.ai/docs/agents for more information."
)
}

const [agentStore, setAgentStore] = createStore<{
current: string
}>({
current: firstAgent.name,
})
```

### Change 2: Fix unsafe find at line 56-58

**BEFORE:**
```typescript
current() {
return agents().find((x) => x.name === agentStore.current)!
},
```

**AFTER:**
```typescript
current() {
const current = agents().find((x) => x.name === agentStore.current)
// Fallback to first available agent if current not found
return current ?? agents()[0] ?? (() => {
throw new Error("No agents available in configuration")
})()
},
```

## Verification

After applying these changes, verify the fix works:

1. **Build the project:**
```bash
bun run build
```

2. **Run TUI tests (if they exist):**
```bash
bun test packages/opencode/test/cli/cmd/tui/context/local.test.tsx
```

3. **Test manually:**
- Start opencode normally (should work fine)
- Try with broken config (no agents) - should show helpful error instead of crash

## Rollback

If you need to rollback:
```bash
git checkout packages/opencode/src/cli/cmd/tui/context/local.tsx
```
Loading