Skip to content

fix: remove redundant hardwrap in preview panel causing extra newlines - #7

Merged
MartianGreed merged 1 commit into
mainfrom
fix/preview-newlines
Feb 2, 2026
Merged

MartianGreed merged 1 commit into
mainfrom
fix/preview-newlines

Conversation

@MartianGreed

Copy link
Copy Markdown
Owner

No description provided.

@greptile-apps

greptile-apps Bot commented Feb 2, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR includes multiple changes beyond the preview fix mentioned in the title:

Main Fix (Preview Panel)

  • Removed ansi.Hardwrap call that was wrapping long lines and creating extra newlines
  • Replaced with ansi.Truncate to properly truncate lines to fit the preview width
  • Added ANSI reset (\x1b[0m) to ensure proper color handling

Feature Additions

  • Daily cost tracking: Monitors session usage costs and accumulates them in the database
  • Clipboard paste support: Added ctrl+v keybinding to paste clipboard content in prompt mode (supports macOS via pbpaste and Linux via xclip)
  • Enhanced urgent detection: Added pattern for "Ready to submit your answers"

Database Changes

  • New migration 005_daily_cost.sql adds daily_cost column to daily_stats table
  • New AddToDailyCost() method to incrementally track costs throughout the day

The changes are well-structured and follow Go conventions. The cost tracking implementation correctly calculates deltas to avoid double-counting.

Confidence Score: 5/5

  • Safe to merge - well-tested features with clean implementation
  • All changes follow Go best practices, use proper error handling, and maintain backward compatibility through database migration. The preview fix directly addresses the issue in the PR title, and additional features are properly integrated.
  • No files require special attention

Important Files Changed

Filename Overview
internal/daemon/monitor.go Added daily cost tracking with delta calculation - implementation looks correct, handles cleanup on session close
internal/store/sqlite.go Added DailyCost field and AddToDailyCost method with proper COALESCE handling in queries
internal/tui/model.go Added clipboard paste support (ctrl+v) and daily cost polling - clean implementation
internal/tui/view.go Fixed preview panel line wrapping by removing hardwrap and using Truncate instead - resolves the issue in PR title

Sequence Diagram

sequenceDiagram
    participant User
    participant TUI
    participant Monitor
    participant Store
    participant Usage

    Note over TUI,Monitor: Preview Fix (main change)
    User->>TUI: View session preview
    TUI->>TUI: Capture pane content
    TUI->>TUI: Truncate lines instead of hardwrap
    TUI->>User: Display preview without extra newlines

    Note over Monitor,Store: Daily Cost Tracking (feature addition)
    loop Every 5 poll cycles
        Monitor->>Usage: GetSessionByID(workingDir, sessionID)
        Usage-->>Monitor: SessionUsage with EstimatedCost
        Monitor->>Monitor: Calculate cost delta
        alt delta > 0
            Monitor->>Store: AddToDailyCost(delta)
            Store->>Store: UPDATE daily_stats SET daily_cost += delta
        end
        Monitor->>Monitor: Update lastCosts map
    end

    Note over TUI,Store: Daily Cost Display
    loop Every 25 ticks
        TUI->>Store: GetTodayStats()
        Store-->>TUI: DailyStats with DailyCost
        TUI->>TUI: Update dailyCost display
        TUI->>User: Show COST in header
    end

    Note over User,TUI: Clipboard Paste (feature addition)
    User->>TUI: Press ctrl+v in prompt mode
    TUI->>TUI: readClipboard() (pbpaste/xclip)
    TUI->>TUI: InsertString(clip)
    TUI->>User: Pasted content in prompt
Loading

@MartianGreed
MartianGreed merged commit 7bfe445 into main Feb 2, 2026
4 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.

1 participant