Skip to content

Fleet UI: Cap policy/report name input at 255 + truncate long names with tooltip on details pages#48154

Merged
RachelElysia merged 3 commits into
mainfrom
46978-46981-long-user-input
Jun 24, 2026
Merged

Fleet UI: Cap policy/report name input at 255 + truncate long names with tooltip on details pages#48154
RachelElysia merged 3 commits into
mainfrom
46978-46981-long-user-input

Conversation

@RachelElysia

@RachelElysia RachelElysia commented Jun 24, 2026

Copy link
Copy Markdown
Member

Issue

Closes #46978
Closes #46981

Description

  • Bug fix (root cause): policy/report name InputFields had no client-side maxLength, so a user could type past the backend varchar(255) and hit a 422/500 on save. Capped all four entry points (SaveNewPolicyModal, PolicyForm edit mode, SaveNewQueryModal, EditQueryForm edit mode) at 255 via inputOptions={{ maxLength: NAME_MAX_LENGTH }}.
  • UX (details pages): long policy/report names overflowed the title bar and pushed the action buttons. Wrapped query-details-page__query-name and policy-details-page__policy-name in <TooltipTruncatedText /> with the necessary flex: 1; min-width: 0 / overflow: hidden plumbing so the name ellipsizes and shows the full value on hover. Critical-policy icon stays as a sibling.
  • Rule: added a short Forms section to .claude/rules/fleet-frontend.md so future free-text inputs match the backend column length instead of guessing.

Screenshots

Screenshot 2026-06-23 at 11 16 43 PM Screenshot 2026-06-23 at 11 16 52 PM Screenshot 2026-06-23 at 11 23 02 PM

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Long query, policy, and host query report names now display with tooltips when truncated in headers.
    • Added a 255-character maximum length to name fields for policies and queries (including edit and creation modals).
  • Style & Layout Updates

    • Improved header layout for better truncation/overflow handling and more consistent spacing/alignment.
  • Tests

    • Added/updated tests to verify the 255-character maxlength is enforced on the relevant “Name” inputs.

@RachelElysia RachelElysia marked this pull request as ready for review June 24, 2026 03:23
@RachelElysia RachelElysia requested a review from a team as a code owner June 24, 2026 03:23
Copilot AI review requested due to automatic review settings June 24, 2026 03:23

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.32%. Comparing base (e0fc1e0) to head (2019018).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #48154    +/-   ##
========================================
  Coverage   67.32%   67.32%            
========================================
  Files        3657     3657            
  Lines      231233   231237     +4     
  Branches    12206    12062   -144     
========================================
+ Hits       155676   155680     +4     
  Misses      61590    61590            
  Partials    13967    13967            
Flag Coverage Δ
frontend 58.41% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents policy/report names from exceeding the backend varchar(255) constraint in Fleet’s UI and improves details-page header rendering for long (but valid) names by truncating with a tooltip.

Changes:

  • Added maxLength={255} (via inputOptions) to policy/report name InputFields across create + edit entry points.
  • Updated policy/report details page headings (and Host Query Report header) to use <TooltipTruncatedText /> and adjusted flex/overflow styles so long names ellipsize instead of pushing actions off-screen.
  • Documented the “cap free-text inputs to backend column length” rule in .claude/rules/fleet-frontend.md.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx Adds NAME_MAX_LENGTH and applies maxLength to the report name input in the save modal.
frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tsx Applies maxLength to the report name input in edit mode.
frontend/pages/queries/details/QueryDetailsPage/QueryDetailsPage.tsx Replaces the report title text with TooltipTruncatedText for truncation + hover reveal.
frontend/pages/queries/details/QueryDetailsPage/_styles.scss Adds flex/min-width plumbing for title truncation and constrains overflow in the header.
frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx Applies maxLength to the policy name input in the save modal.
frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx Applies maxLength to the policy name input in edit mode.
frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx Wraps the policy name in TooltipTruncatedText while keeping the critical icon sibling.
frontend/pages/policies/details/PolicyDetailsPage/_styles.scss Adds flex/min-width/overflow rules so policy name truncates without pushing header actions.
frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx Uses TooltipTruncatedText for the report name in the host report header.
frontend/pages/hosts/details/HostQueryReport/HQRTable/_styles.scss Adds flex/min-width/overflow rules for truncation in the host report header layout.
.claude/rules/fleet-frontend.md Adds a forms rule to cap free-text input lengths to backend schema column sizes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx
Comment thread frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 48a47927-9456-408e-a2c1-4408de03cb16

📥 Commits

Reviewing files that changed from the base of the PR and between fa56b64 and 2019018.

📒 Files selected for processing (7)
  • frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx
  • frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx
  • frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tests.tsx
  • frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tests.tsx
  • frontend/pages/queries/details/QueryDetailsPage/QueryDetailsPage.tsx
  • frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tests.tsx
  • frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tests.tsx
✅ Files skipped from review due to trivial changes (1)
  • frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tests.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx
  • frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx
  • frontend/pages/queries/details/QueryDetailsPage/QueryDetailsPage.tsx

Walkthrough

The PR adds a 255-character maxLength to policy and query name inputs in both save and edit forms, with tests covering the maxlength attribute. It also changes policy, query, and host query report detail headings to render names through TooltipTruncatedText, along with SCSS updates that constrain flex sizing and hide overflow.

Possibly related PRs

  • fleetdm/fleet#47767: Refactored PolicyDetailsPage and QueryDetailsPage to render from storedPolicy/storedQuery directly, which is the same data source now wrapped with TooltipTruncatedText in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main fixes: 255-char caps and tooltip truncation on details pages.
Description check ✅ Passed The description covers the issue links, change summary, screenshots, and testing, matching the template closely enough.
Linked Issues check ✅ Passed The code adds 255-char limits to all four name inputs and truncates policy and report details headings with tooltip support.
Out of Scope Changes check ✅ Passed All changed files are directly related to the linked input-limit and truncation fixes, including the added tests and styling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 46978-46981-long-user-input

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx (1)

67-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Centralize NAME_MAX_LENGTH in a shared frontend constant.

255 is now duplicated across multiple policy/report form components. A shared constant (e.g., form/query-policy constants) would prevent drift if backend constraints ever change.

🤖 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 `@frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx` around
lines 67 - 68, The NAME_MAX_LENGTH constant is duplicated across multiple policy
and report form components. Move the NAME_MAX_LENGTH constant definition to a
centralized shared constants file (such as a form constants or query-policy
constants module), then update all references in PolicyForm and other components
that use this constant to import it from the new shared location instead of
defining it locally. This ensures a single source of truth and prevents drift if
backend constraints change.
🤖 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 `@frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx`:
- Around line 178-180: The TooltipTruncatedText component rendering the
queryName value in the h2 element needs to use fixed positioning for its tooltip
to prevent overflow-related placement issues. Add the fixedPositionStrategy prop
to the TooltipTruncatedText component to ensure the tooltip is positioned
correctly even when the query name is truncated and may cause the default
tooltip placement to overflow.

In `@frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx`:
- Line 371: Add the fixedPositionStrategy prop to the TooltipTruncatedText
component that displays the policy name (storedPolicy?.name) to enable fixed
positioning of the tooltip. This will prevent the tooltip from being clipped or
misaligned when the heading or container uses overflow-based truncation. Set the
prop value appropriately to match the tooltip positioning strategy used
elsewhere in the codebase.

In `@frontend/pages/queries/details/QueryDetailsPage/QueryDetailsPage.tsx`:
- Around line 251-253: The TooltipTruncatedText component rendered inside the
heading with the baseClass__query-name class needs the fixedPositionStrategy
prop to be added. This is necessary because the heading now participates in
overflow-based truncation, and without fixed positioning strategy, the tooltip
will be clipped or misaligned by the overflow-hidden ancestors. Add the
fixedPositionStrategy prop to the TooltipTruncatedText component to ensure the
tooltip is positioned correctly and not constrained by the parent's overflow
behavior.

---

Nitpick comments:
In `@frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx`:
- Around line 67-68: The NAME_MAX_LENGTH constant is duplicated across multiple
policy and report form components. Move the NAME_MAX_LENGTH constant definition
to a centralized shared constants file (such as a form constants or query-policy
constants module), then update all references in PolicyForm and other components
that use this constant to import it from the new shared location instead of
defining it locally. This ensures a single source of truth and prevents drift if
backend constraints change.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 33f936d8-c4fb-4950-a1a6-d0ffe249cddd

📥 Commits

Reviewing files that changed from the base of the PR and between e0fc1e0 and fa56b64.

⛔ Files ignored due to path filters (1)
  • .claude/rules/fleet-frontend.md is excluded by !**/*.md
📒 Files selected for processing (10)
  • frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx
  • frontend/pages/hosts/details/HostQueryReport/HQRTable/_styles.scss
  • frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx
  • frontend/pages/policies/details/PolicyDetailsPage/_styles.scss
  • frontend/pages/policies/edit/components/PolicyForm/PolicyForm.tsx
  • frontend/pages/policies/edit/components/SaveNewPolicyModal/SaveNewPolicyModal.tsx
  • frontend/pages/queries/details/QueryDetailsPage/QueryDetailsPage.tsx
  • frontend/pages/queries/details/QueryDetailsPage/_styles.scss
  • frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tsx
  • frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx

Comment thread frontend/pages/hosts/details/HostQueryReport/HQRTable/HQRTable.tsx
Comment thread frontend/pages/policies/details/PolicyDetailsPage/PolicyDetailsPage.tsx Outdated
@RachelElysia RachelElysia marked this pull request as ready for review June 24, 2026 11:15
@RachelElysia RachelElysia merged commit 0c4e7e6 into main Jun 24, 2026
28 of 29 checks passed
@RachelElysia RachelElysia deleted the 46978-46981-long-user-input branch June 24, 2026 14:20
JordanMontgomery pushed a commit that referenced this pull request Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants