Skip to content

fix(taints): keep the effect field visible in the add-row - #564

Merged
janosmiko merged 3 commits into
mainfrom
fix/taint-editor-addrow-effect
Jul 27, 2026
Merged

fix(taints): keep the effect field visible in the add-row#564
janosmiko merged 3 commits into
mainfrom
fix/taint-editor-addrow-effect

Conversation

@janosmiko

Copy link
Copy Markdown
Owner

Typing a long taint key pushed the effect selector off the right edge of the node taint editor, where it rendered as eff~:

add: key [node.kubernetes.io/very-long-taint]  value [true]  eff~

The effect is a cycling control with no scroll of its own, so a truncated one leaves you unable to see which effect you are about to stage — on a change that reshapes scheduling for the whole node.

Root cause

Two compounding causes:

  1. The overlay box was sized by ui.OverlayListWidth over the taint list rows only, so the add-row never influenced the box width.
  2. renderTaintEditorAddRow joined the three fields into one line and truncated the result as a unit — and the effect sits last, so it was always what got cut.

Changes

  • The add-row's natural width now joins the box measurement while an input is focused, so the box grows to fit it (still capped by the screen).
  • When the fields still cannot share one line, they stack onto separate lines instead of the row truncating as a unit.
  • Each input's value is fitted to its own budget, so the field label survives. The focused value truncates from the front, keeping the caret end — what you are typing right now — visible.

Two new internal/ui primitives:

Primitive Purpose
OverlayContentWidth Extracted from OverlayListWidth so any overlay can size itself against content the list does not include. OverlayListWidth now delegates to it — no behavior change.
TruncateStart Mirror of Truncate, keeping the tail with a leading ~.

Test plan

  • internal/app/taint_editor_addrow_test.go — 4 tests: long key keeps the effect, an extreme key still shows it without overflowing the box, the focused field keeps its caret end, and the box widens for a fitting add-row
  • internal/ui/explorer_test.goTestTruncateStart
  • go test -race ./... — all packages pass
  • golangci-lint run ./... — 0 issues

Typing a long taint key pushed the effect selector off the right edge,
where it rendered as "eff~". The effect is a cycling control with no
scroll of its own, so a truncated one leaves the user unable to see
which effect they are about to stage -- on a change that reshapes
scheduling for the whole node.

Two causes. The overlay box was sized by OverlayListWidth over the taint
LIST rows only, so the add-row never influenced the box width. The
add-row was then joined into one line and truncated as a unit, and the
effect sits last.

Size the box against the add-row as well while an input is focused, and
stack the fields onto separate lines when they cannot share one instead
of truncating the row as a unit. Each input's value is fitted to its own
budget, so the field label survives; the focused value truncates from
the front so the caret end -- what the user is typing right now -- stays
visible.

Adds two ui primitives: OverlayContentWidth, extracted from
OverlayListWidth so any overlay can size itself against content the list
does not include, and TruncateStart, the mirror of Truncate for text
whose end matters more than its start.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eb176407-ed5b-4e9d-99c1-afc05946f5f4

📥 Commits

Reviewing files that changed from the base of the PR and between fdb53fb and a29bc16.

📒 Files selected for processing (2)
  • internal/app/taint_editor_addrow_test.go
  • internal/app/view_overlay_taint_editor.go

Summary by CodeRabbit

  • Bug Fixes
    • Improved the taint editor overlay layout for long keys and narrow terminal widths.
    • Keeps effect selectors and focused-field caret indicators visible during editing.
    • Prevents add-row content from being cut off or overflowing the overlay.
    • Automatically adjusts overlay sizing and stacks fields when horizontal space is limited.

Walkthrough

Adds width-aware left truncation and extracts overlay content width calculation. Refactors taint editor add-row rendering to size fields individually, preserve the focused field’s tail, widen the overlay when needed, and stack fields when horizontal space is insufficient. Adds tests for long and extreme keys, caret visibility, overlay sizing, effect visibility, and Unicode-aware truncation.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main user-facing fix to keep the effect field visible.
Description check ✅ Passed The description covers the summary, root cause, changes, and testing, though several template sections are unfilled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/app/view_overlay_taint_editor.go (1)

161-166: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant recomputation of taintAddRowFields.

fields := taintAddRowFields(p, -1) is computed here, then taintAddRowNaturalWidth(p) immediately recomputes the same taintAddRowFields(p, -1) internally to measure width. Consider having taintAddRowNaturalWidth accept the already-built fields slice (or a width helper operating on fields) to avoid building the field strings twice per render.

♻️ Proposed refactor
-func taintAddRowNaturalWidth(p taintEditorState) int {
-	fields := taintAddRowFields(p, -1)
-	w := len(taintAddRowSep) * (len(fields) - 1)
+func taintAddRowFieldsWidth(fields []string) int {
+	w := lipgloss.Width(taintAddRowSep) * (len(fields) - 1)
 	for _, f := range fields {
 		w += lipgloss.Width(f)
 	}
 	return w
 }
+
+func taintAddRowNaturalWidth(p taintEditorState) int {
+	return taintAddRowFieldsWidth(taintAddRowFields(p, -1))
+}
 	fields := taintAddRowFields(p, -1)
 	sep := taintAddRowSep
-	if taintAddRowNaturalWidth(p) > innerW {
+	if taintAddRowFieldsWidth(fields) > innerW {
 		fields = taintAddRowFields(p, innerW)
 		sep = "\n"
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/app/view_overlay_taint_editor.go` around lines 161 - 166, Refactor
the add-row rendering flow around taintAddRowFields and taintAddRowNaturalWidth
to reuse the already-built fields slice when measuring natural width. Update
taintAddRowNaturalWidth or introduce a fields-based width helper, then use it in
place of recomputing taintAddRowFields(p, -1), while preserving the existing
wrapping and separator behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/app/view_overlay_taint_editor.go`:
- Around line 152-171: Update renderTaintEditorAddRow’s final field truncation
to preserve the focused field’s caret: use the start-preserving truncation path
for the focused field and the existing right-side truncation for other fields,
matching taintAddRowFields’ behavior when the field still exceeds innerW.

---

Nitpick comments:
In `@internal/app/view_overlay_taint_editor.go`:
- Around line 161-166: Refactor the add-row rendering flow around
taintAddRowFields and taintAddRowNaturalWidth to reuse the already-built fields
slice when measuring natural width. Update taintAddRowNaturalWidth or introduce
a fields-based width helper, then use it in place of recomputing
taintAddRowFields(p, -1), while preserving the existing wrapping and separator
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 62bf6dae-3b4f-4851-9cf5-e840461b68de

📥 Commits

Reviewing files that changed from the base of the PR and between c8c4eea and fdb53fb.

📒 Files selected for processing (5)
  • internal/app/taint_editor_addrow_test.go
  • internal/app/view_overlay_taint_editor.go
  • internal/ui/explorer_format.go
  • internal/ui/explorer_test.go
  • internal/ui/overlay_list.go

Comment thread internal/app/view_overlay_taint_editor.go
The per-field budget floors at one column, so on a terminal narrow
enough that a field's label alone outgrows the line, taintAddRowFields
returns a field wider than innerW and the final truncation runs. That
cut was unconditional and right-side, which strips exactly the caret the
front-truncation had just preserved -- undoing the fix at narrow widths.

Pick the truncation direction by focus there too.

The test helper anchored on the "add:" label to find the block; at these
widths the label is itself truncated away, so it now anchors on the
blank line the renderer joins the block with.
@janosmiko
janosmiko merged commit a12df04 into main Jul 27, 2026
7 of 8 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