Skip to content

Improve container engine error#72

Merged
silv-io merged 3 commits intomainfrom
george/improve-container-engine-error
Mar 5, 2026
Merged

Improve container engine error#72
silv-io merged 3 commits intomainfrom
george/improve-container-engine-error

Conversation

@gtsiolis
Copy link
Member

@gtsiolis gtsiolis commented Mar 3, 2026

See DES-152 for more context.

BEFORE AFTER
Screenshot 2026-03-04 at 01 50 01 Screenshot 2026-03-04 at 01 48 36

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9b675b18-53bf-4d0c-9a60-1c33073ab3b3

📥 Commits

Reviewing files that changed from the base of the PR and between 46f368e and 9723f80.

📒 Files selected for processing (2)
  • internal/ui/wrap/wrap.go
  • internal/ui/wrap/wrap_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/ui/wrap/wrap.go

📝 Walkthrough

Walkthrough

Replaces ad-hoc hard-wrap logic with a new internal/ui/wrap package (HardWrap/SoftWrap), updates rendering to use those wrappers, changes ErrorDisplay.View() to View(maxWidth int) (using SoftWrap), updates callers/tests, and adds unit tests for wrapping utilities.

Changes

Cohort / File(s) Summary
Wrapping utilities
internal/ui/wrap/wrap.go, internal/ui/wrap/wrap_test.go
Adds HardWrap(s, maxWidth) and SoftWrap(text, maxWidth) with comprehensive tests covering rune-handling, word-boundary wrapping, edge cases, and line-length guarantees.
ErrorDisplay component
internal/ui/components/error_display.go, internal/ui/components/error_display_test.go
Changes ErrorDisplay.View()View(maxWidth int); Summary now soft-wrapped into multiple lines with aligned prefix; supports multiple actions rendering; tests updated to pass width argument.
UI app and rendering
internal/ui/app.go, internal/ui/app_test.go
Replaces local hardWrap with wrap.HardWrap(...); passes contentWidth into errorDisplay.View(contentWidth); removes legacy hard-wrap UTF‑8 unit test.
Misc / small edits
internal/ui/...
Multiple call sites updated to use wrap.HardWrap for highlight/secondary/default text; adjusted newline handling when rendering error views.

Sequence Diagram(s)

sequenceDiagram
    participant App as App (renderer)
    participant Error as ErrorDisplay
    participant Wrap as wrap

    App->>Error: errorDisplay.View(contentWidth)
    Error->>Wrap: SoftWrap(summary, contentWidth - prefixLen)
    Wrap-->>Error: []lines
    Error-->>App: rendered error block (multi-line, styled)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'Improve container engine error' is vague and does not clearly convey what specific improvements were made; it lacks specificity about whether the focus is on error handling, display, wrapping, or messaging. Consider a more specific title that describes the primary change, such as 'Add text wrapping to container engine error messages' or 'Improve container engine error message formatting'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description references DES-152 for context and includes before/after screenshots showing improved error message display with full error text visibility, which aligns with the changeset focused on text wrapping functionality.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch george/improve-container-engine-error

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/ui/components/error_display_test.go (1)

35-50: Add a narrow-width regression test for wrapping behavior.

These assertions validate content presence, but they don’t guard the new width-constrained behavior (especially long-token wrapping). A focused test for small widths would prevent regressions in this PR’s core behavior.

Suggested test addition
+func TestSoftWrap_HardBreaksLongWord(t *testing.T) {
+	t.Parallel()
+
+	lines := softWrap("unix:///var/run/docker.sock", 8)
+	for _, line := range lines {
+		if len(line) > 8 {
+			t.Fatalf("expected hard-wrapped segment length <= 8, got %q", line)
+		}
+	}
+}

Based on learnings: “Ensure tests verify the separate rendering paths and avoid unintended coupling to the plain-output formatting.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/ui/components/error_display_test.go` around lines 35 - 50, Add a
focused unit test in error_display_test.go that constructs the same error
display (the existing e variable/instance) but calls View with a small width
(e.g., 20 or similar) and asserts that the output preserves the title, summary
and detail while also verifying long-token wrapping behavior (e.g., a very long
word is broken across lines) and that action lines (labels like "Start Docker:"
and values like "open -a Docker") render on separate lines or wrap as expected;
target the View(width int) method and the same title/summary/detail/action
strings to ensure the width-constrained rendering path is exercised separately
from the plain-output formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/ui/components/error_display.go`:
- Around line 91-104: The softWrap loop currently appends overlong tokens
(variable word) directly and can exceed maxWidth; update the logic in the
softWrap routine (the for _, word := range words loop using current, maxWidth,
lines) to detect when len(word) > maxWidth and instead split that token into
chunks that fit maxWidth (using rune-aware slicing) appending each chunk as its
own line (flushing current first if non-empty), and when a chunk exactly fills a
line start a new line; ensure remaining partial chunk is written into current
rather than appended raw so no produced line exceeds maxWidth.

---

Nitpick comments:
In `@internal/ui/components/error_display_test.go`:
- Around line 35-50: Add a focused unit test in error_display_test.go that
constructs the same error display (the existing e variable/instance) but calls
View with a small width (e.g., 20 or similar) and asserts that the output
preserves the title, summary and detail while also verifying long-token wrapping
behavior (e.g., a very long word is broken across lines) and that action lines
(labels like "Start Docker:" and values like "open -a Docker") render on
separate lines or wrap as expected; target the View(width int) method and the
same title/summary/detail/action strings to ensure the width-constrained
rendering path is exercised separately from the plain-output formatting.

ℹ️ Review info

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8adc60 and c840618.

📒 Files selected for processing (3)
  • internal/ui/app.go
  • internal/ui/components/error_display.go
  • internal/ui/components/error_display_test.go

}

// softWrap breaks text into lines at word boundaries, falling back to hard
// breaks for words longer than maxWidth.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

falling back to hard breaks for words longer than maxWidth.

issue: Is this really implemented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it should work, added in 46f368e. 😅

@gtsiolis gtsiolis force-pushed the george/improve-container-engine-error branch from c840618 to 46f368e Compare March 4, 2026 20:42
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/ui/wrap/wrap_test.go (1)

83-94: Add a UTF-8 multi-word regression case for SoftWrap.

Current UTF-8 coverage only exercises single-token splitting. Please add a spaced UTF-8 case to lock in rune-aware behavior on the current + space + word path.

✅ Suggested test addition
 	{
 		name:     "utf8 rune aware split",
 		input:    "🙂🙂🙂🙂🙂",
 		width:    2,
 		expected: []string{"🙂🙂", "🙂🙂", "🙂"},
 	},
+	{
+		name:     "utf8 multi-word keeps rune width",
+		input:    "🙂 🙂",
+		width:    3,
+		expected: []string{"🙂 🙂"},
+	},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/ui/wrap/wrap_test.go` around lines 83 - 94, Add a regression test
case to the existing table in wrap_test.go that ensures SoftWrap handles
multi-word UTF-8 strings (rune-aware on the "current + space + word" path): add
an entry with name like "utf8 multi-word rune aware split", input containing
spaced emoji or other multi-byte runes (e.g., "🙂 🙂 🙂"), a small width that
forces splitting across a space boundary, and the expected slices showing
correct split positions; locate the test table used by the SoftWrap tests in
internal/ui/wrap/wrap_test.go and append this case next to the existing utf8
cases so the SoftWrap behavior is locked in.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/ui/wrap/wrap.go`:
- Around line 62-67: SoftWrap currently mixes byte counts (current.Len(),
len(s)) with rune-based maxWidth causing incorrect wrapping for multi-byte UTF-8
characters; add a rune-count tracker (e.g., currentRunes int) to track the
number of runes in the current line and use rune counts everywhere instead of
current.Len(): update the early-exit check to compare utf8.RuneCountInString(s)
against maxWidth, replace uses of current.Len() in SoftWrap with currentRunes
when deciding to append or break, and increment/decrement currentRunes by the
rune length of appended words (use utf8.RuneCountInString(word) or len(runes)
from the existing rune slice) so all comparisons (the checks at the sites
indicated by current.Len() usage) are rune-consistent.

---

Nitpick comments:
In `@internal/ui/wrap/wrap_test.go`:
- Around line 83-94: Add a regression test case to the existing table in
wrap_test.go that ensures SoftWrap handles multi-word UTF-8 strings (rune-aware
on the "current + space + word" path): add an entry with name like "utf8
multi-word rune aware split", input containing spaced emoji or other multi-byte
runes (e.g., "🙂 🙂 🙂"), a small width that forces splitting across a space
boundary, and the expected slices showing correct split positions; locate the
test table used by the SoftWrap tests in internal/ui/wrap/wrap_test.go and
append this case next to the existing utf8 cases so the SoftWrap behavior is
locked in.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9f4a80fa-d63f-4b61-894f-7851b3261f8a

📥 Commits

Reviewing files that changed from the base of the PR and between c840618 and 46f368e.

📒 Files selected for processing (6)
  • internal/ui/app.go
  • internal/ui/app_test.go
  • internal/ui/components/error_display.go
  • internal/ui/components/error_display_test.go
  • internal/ui/wrap/wrap.go
  • internal/ui/wrap/wrap_test.go
💤 Files with no reviewable changes (1)
  • internal/ui/app_test.go

@silv-io silv-io merged commit ce7f6f5 into main Mar 5, 2026
8 checks passed
@silv-io silv-io deleted the george/improve-container-engine-error branch March 5, 2026 09:14
@gtsiolis
Copy link
Member Author

gtsiolis commented Mar 5, 2026

Thanks @carole-lavillonniere for taking another look, and @silv-io for merging! 🏀

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.

3 participants