Skip to content

Conversation

@renuka-fernando
Copy link
Contributor

@renuka-fernando renuka-fernando commented Jan 26, 2026

Purpose

Fix #805

Summary by CodeRabbit

  • New Features

    • Added real-time scrolling terminal display for build command output, showing recent logs that automatically clear after successful completion.
    • Improved terminal output handling with TTY detection and ANSI-based formatting for cleaner visual presentation during builds.
  • Tests

    • Added comprehensive unit tests for terminal logging and TTY utilities.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

Adds a real-time scrolling log display for gateway build progress by introducing a new terminal package with TTY detection and a ScrollingLogger that displays the last N lines while preserving complete logs to disk. Integrates the logger into docker build command execution.

Changes

Cohort / File(s) Summary
Gateway Docker Build Integration
cli/src/internal/gateway/docker_build.go
Replaces direct logFile usage with terminal.NewScrollingLogger across gateway-builder, buildx build, docker build, and push steps. Logger is started before command execution and stopped after. Adds ClearDisplay() calls after successful completions. Maintains existing error handling and control flow with same observable outcomes but via scroller-based output capture. Step message refined from "Running gateway-builder container..." to "Running gateway-builder...".
Terminal Utilities
cli/src/internal/terminal/terminal.go
New module providing Terminal struct with TTY detection (via golang.org/x/term), runtime-detected dimensions (fallback to 80x24), and ANSI-based terminal controls. Exports IsTTY(), Width(), Height() accessors and methods for cursor visibility (HideCursor/ShowCursor) and line clearing (ClearLines). No-ops for non-TTY environments.
Scrolling Logger
cli/src/internal/terminal/scroller.go
New ScrollingLogger implementing io.Writer with ring buffer of configurable max lines (clamped to 5–50, default 12). Writes complete output to log file while displaying scrolling window in terminal when attached to TTY. Features line buffering with partial line assembly, carriage return handling, line truncation to terminal width with ellipsis, and synchronized redraw logic with gray ANSI coloring. Provides Start/Stop hooks for cursor control and ClearDisplay() cleanup. Silently falls back to file-only logging for non-TTY.
Scrolling Logger Tests
cli/src/internal/terminal/scroller_test.go
Comprehensive unit tests covering: maxLines constraints and defaults, file I/O and data integrity, ring buffer behavior, line buffering and partial line assembly, carriage return handling, concurrent writes, Start/Stop lifecycle, empty output handling, nil log file scenarios, prefix configuration, and terminal utility initialization and behavior in TTY and non-TTY modes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A scrolling log hops into sight,
Real-time progress, terminal bright!
Lines cascade like fresh morning dew,
While disk logs capture every clue.
Building, building—let's see the view! 🏗️✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. It only references the linked issue without addressing any of the template sections (Goals, Approach, User stories, Documentation, Automation tests, Security checks, etc.). Expand the description to cover Goals, Approach, testing details, and documentation impact following the provided template structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: displaying gateway build progress in CLI output, which aligns with the primary objective.
Linked Issues check ✅ Passed The PR fully implements all coding requirements from issue #805: scrolling logger with ring buffer, TTY detection, terminal controls, integration into docker_build.go, comprehensive unit tests, and graceful fallback for non-TTY environments.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #805: new terminal package (terminal.go, scroller.go) and tests, docker_build.go integration, and no extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@piyumaldk
Copy link
Contributor

Are we printing the full Docker logs in the terminal, or just high level steps?

My view is that since this is a CLI and users already have access to detailed log files, it is better to keep the terminal output to a high level summary with progress indicators. If users want the full output, they can enable a debug or verbose mode. This keeps the default output readable and free from unnecessary noise.

@renuka-fernando
Copy link
Contributor Author

Yeah. I also felt the same. We won't meed this one.

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.

Display gateway build progress in the cli output

2 participants