Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/inline-name-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@hyperdx/app': patch
---

feat: rename dashboards and saved searches by clicking the title instead of a
pencil button

The name is now edited in place: Enter or clicking away saves, Escape reverts.
41 changes: 41 additions & 0 deletions .claude/skills/naming-objects/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: naming-objects
description:
Name user-created objects (dashboards, saved searches, tiles, alerts) with the
shared InlineNameInput. Use when adding or changing the place where a user
names or renames something, building an editor or page header that shows an
object's name, or when tempted to add a pencil edit button, a "Name" field in
a save modal, or a bordered name TextInput.
---

# Naming objects

Read **`agent_docs/naming_objects.md`** before changing how something is named.
It is the source of truth; this skill is the short version.

## Quick rules

1. Use `InlineNameInput` / `InlineNameInputControlled` from
`@/components/InlineNameInput/InlineNameInput`. Never build a separate
click-to-edit title, pencil button, or "Save name" button.
2. **Saved object shown on its page** → `InlineNameInput` with `onCommit`. Enter
or blur saves immediately; Escape and empty names revert.
3. **Draft in an editor** → `InlineNameInputControlled` with the form's
`control`. The name saves with the editor's save button.
4. Sizes are `xs`, `sm`, `md` only. Page titles use `size="md"` with
`headingLevel={3}`. Editor headers use `size="sm"` (default). Compact rows
use `size="xs"`.
5. Always set `aria-label` ("Dashboard name") and an "Untitled …" placeholder in
sentence case ("Untitled tile").
6. Don't ask for a name inside a save modal. Name inline, then save.
7. In tests, assert the name with `toHaveValue`. In E2E, `fill()` then press
Enter.

## Workflow

1. Read `agent_docs/naming_objects.md`.
2. Look at the reference usages: `DBDashboardPage.tsx` (dashboard name) and
`DBSearchPage.tsx` (saved search name).
3. Check the stories in Storybook under **Components/InlineNameInput**.
4. Update E2E page objects that read the name as text.
5. Run `yarn lint:fix` in the repo root.
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ directory:
`useConfirm` for confirmation dialogs, `EmptyState`, and where shared code
already lives), so copying the conventions of the component you are editing is
not sufficient.
- `agent_docs/naming_objects.md` - How users name and rename objects
(`InlineNameInput`). Read before adding or changing any name field
- `agent_docs/observability.md` - Instrumentation standards (tracing, metrics,
context) and the shared helpers (read when adding or changing a feature)

Expand Down
1 change: 1 addition & 0 deletions agent_docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Instead of stuffing all instructions into `AGENTS.md` (which goes into every con
- **`development.md`** - Development workflows, testing strategy, common tasks, debugging
- **`code_style.md`** - Code patterns and best practices. Read before adding a type, Zod schema, helper, or component in any package (grep-first rule, plus a map of what already lives in `common-utils`), and before any `packages/app` UI change.
- **`page_layout.md`** - PageHeader, PageLayout, and consistent page chrome (titles, actions, tool pages)
- **`naming_objects.md`** - How users name and rename objects (dashboards, saved searches, tiles) with `InlineNameInput`. Read before adding or changing any place where something gets a name.
- **`data_viz_colors.md`** - Chart, heatmap, and semantic status colors. Read before adding or changing any color in a chart, sparkline, heatmap, legend, or status pill.
- **`themes.md`** - How the brand theme system (HyperDX vs ClickStack) and color mode (light/dark/system) work. Read before changing anything in `packages/app/src/theme/`, adding semantic CSS variables, or touching brand-conditional UI.
- **`observability.md`** - Instrumentation standards (tracing, metrics, context) and the shared helpers. Read when adding or changing a feature.
Expand Down
8 changes: 8 additions & 0 deletions agent_docs/code_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ the copy). Exercise the real dialog in E2E instead.

**Title copy**: Treat `title` as a short headline (like `Title` in the UI). Do **not** end it with a period. Use `description` for full sentences, which should use normal punctuation including a trailing period when appropriate. Match listing pages (e.g. dashboards and saved searches use parallel phrasing such as “No matching … yet” / “No … yet” without dots).

### Object names: use `InlineNameInput` (REQUIRED)

**Name or rename a dashboard, saved search, tile, or any other user-created
object with `InlineNameInput` (`@/components/InlineNameInput/InlineNameInput`).**
Do not build a pencil-button edit mode, a bordered name `TextInput` in a
header, or a "Name" field inside a save modal. See
[naming_objects.md](naming_objects.md) for which variant to use.

### Code snippets (REQUIRED)

**Do not render raw `<pre>`, ad-hoc `Paper` + monospace text, or unstyled `<code>`.** Use the existing Mantine/product components so snippets match Terraform export, onboarding, and Storybook guidelines.
Expand Down
91 changes: 91 additions & 0 deletions agent_docs/naming_objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Naming objects

Every user-named object (dashboard, saved search, dashboard tile, alert, and so
on) gets its name through one control: `InlineNameInput`. It looks like plain
title text until you hover or click it, then edits in place. There is no pencil
button, no double-click, no separate "Save name" button, and no naming step
inside a save modal.

```tsx
import {
InlineNameInput,
InlineNameInputControlled,
} from '@/components/InlineNameInput/InlineNameInput';
```

## Pick the variant by how the object is saved

| The object is... | Use | When the name is saved |
| ------------------------------------------------------------------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Already saved, and the page shows it (dashboard page, saved search page) | `InlineNameInput` with `onCommit` | Enter or blur commits. The typed name stays until `value` updates. Return a rejected promise from `onCommit` to revert it. Escape reverts, and an empty or unchanged name reverts. |
| A draft in an editor (tile editor, new chart, new saved search) | `InlineNameInputControlled` with the form's `control` | With the rest of the form, when the user presses the editor's save button. |

A rename on a saved object is an arrangement change, like moving a tile, so it
saves without a confirmation. A name on a draft is part of the draft's content,
so it waits for the explicit save.

## Size and placement

Sizes go from `xs` to `md`. Don't add larger ones.

- `size="md"`: the page title, top-left of the page body under the breadcrumbs.
Pass `headingLevel` so the name is still the page heading for screen readers
and `getByRole('heading')`. Use `headingLevel={3}` to match the existing
dashboard and saved search pages.
- `size="sm"` (default): editor headers, next to the close button and before the
editor's actions.
- `size="xs"`: compact rows, such as a name inside a dense form or list.

## Copy

- `aria-label` is required because there is no visible label: "Dashboard name",
"Saved search name", "Tile name".
- The placeholder is "Untitled" plus the object type in sentence case: "Untitled
dashboard", "Untitled search", "Untitled tile". Don't use "Name".
- Don't add a "Name" label or helper text next to the field.

## Examples

Saved object, saves on commit:

```tsx
<InlineNameInput
value={dashboard.name}
onCommit={name => setDashboard({ ...dashboard, name })}
placeholder="Untitled dashboard"
aria-label="Dashboard name"
size="md"
headingLevel={3}
data-testid="dashboard-name-input"
/>
```

Draft, saves with the form:

```tsx
<InlineNameInputControlled
control={control}
name="name"
size="sm"
placeholder="Untitled tile"
aria-label="Tile name"
data-testid="chart-name-input"
/>
```

## Don't

- Don't build a click-to-edit title with a pencil `ActionIcon` and an edit mode.
That was `EditablePageName`, which this replaces.
- Don't use a bordered `TextInput` for an object's own name in a page or editor
header.
- Don't ask for the name in a modal before saving. Name inline, then save.
- Don't show a success toast for a rename. Show an error toast if the save
fails.

## Testing

- The field is a textbox, so assert with `toHaveValue`, not `toHaveText`.
- To rename in E2E: `fill()` the input, then press Enter. See
`DashboardPage.renameDashboard` in `packages/app/tests/e2e/page-objects/`.
- Storybook: **Components/InlineNameInput** shows both variants and sizes.
25 changes: 15 additions & 10 deletions packages/app/src/DBDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import { DBTimeChart } from '@/components/DBTimeChart';
import { FavoriteButton } from '@/components/FavoriteButton';
import FullscreenPanelModal from '@/components/FullscreenPanelModal';
import ResourceTerraformPopover from '@/components/Iac/ResourceTerraformPopover';
import { InlineNameInput } from '@/components/InlineNameInput/InlineNameInput';
import { PageHeader } from '@/components/PageHeader';
import { PageLayout } from '@/components/PageLayout';
import { SqlVariablesProvider } from '@/components/SQLEditor/variableCompletions';
Expand Down Expand Up @@ -198,7 +199,6 @@ import {
import { useConnections } from './connection';
import { useDashboard } from './dashboard';
import DashboardFilters from './DashboardFilters';
import { EditablePageName } from './EditablePageName';
import {
GranularityPicker,
GranularityPickerControlled,
Expand Down Expand Up @@ -2906,16 +2906,21 @@ function DBDashboardPage({
);

const dashboardName = (
<EditablePageName
<InlineNameInput
key={`${dashboardHash}`}
name={dashboard?.name ?? ''}
onSave={editedName => {
if (dashboard != null) {
setDashboard({
...dashboard,
name: editedName,
});
}
value={dashboard?.name ?? ''}
placeholder="Untitled dashboard"
aria-label="Dashboard name"
size="md"
headingLevel={3}
data-testid="dashboard-name-input"
onCommit={editedName => {

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.

🔵 minor — Renaming before the dashboard loads leaves a name on screen that was never saved

When dashboard is still undefined (loading, or the id is not found), onCommit returns undefined. InlineNameInput then keeps pending set to the typed name until value changes, so the title shows a name that was never saved. This is the opposite of the 'visibly reverts' behaviour the component promises. Return Promise.reject(new Error('Dashboard not loaded')) here, or make the input readOnly until dashboard exists.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

if (dashboard == null) return;
return new Promise<void>((resolve, reject) => {
setDashboard({ ...dashboard, name: editedName }, resolve, () =>
reject(new Error('Unable to save dashboard')),
);
});
}}
/>
);
Expand Down
41 changes: 28 additions & 13 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import EmptyState from '@/components/EmptyState';
import { ErrorBoundary } from '@/components/Error/ErrorBoundary';
import { FavoriteButton } from '@/components/FavoriteButton';
import ResourceTerraformPopover from '@/components/Iac/ResourceTerraformPopover';
import { InlineNameInput } from '@/components/InlineNameInput/InlineNameInput';
import { InputControlled } from '@/components/InputControlled';
import OnboardingModal from '@/components/OnboardingModal';
import SearchWhereInput, {
Expand Down Expand Up @@ -169,7 +170,6 @@ import {
} from './utils/queryParsers';
import { LOCAL_STORE_CONNECTIONS_KEY } from './connection';
import { DBSearchPageAlertModal } from './DBSearchPageAlertModal';
import { EditablePageName } from './EditablePageName';
import { SearchConfig } from './types';
import { FormatTime } from './useFormatTime';

Expand Down Expand Up @@ -2229,7 +2229,7 @@ function DBSearchPageContent() {
)}
<OnboardingModal />
{savedSearch && (
<Stack mt="lg" mx="xs">
<Stack mt="xs" mx="xs" gap="xs">
<Group justify="space-between">
<Breadcrumbs fz="sm">
<Anchor component={Link} href="/search/list" fz="sm" c="dimmed">
Expand All @@ -2239,7 +2239,7 @@ function DBSearchPageContent() {
{savedSearch.name}
</Text>
</Breadcrumbs>
<Text size="xs" c="dimmed" lh={1}>
<Text size="xs" c="dimmed">
{savedSearch.createdBy && (
<span>
Created by{' '}
Expand All @@ -2266,18 +2266,33 @@ function DBSearchPageContent() {
</Text>
</Group>
<Group justify="space-between" align="flex-end">
<div data-testid="saved-search-name">
<EditablePageName
key={savedSearch.id}
name={savedSearch?.name ?? 'Untitled Search'}
onSave={editedName => {
updateSavedSearch.mutate({
<InlineNameInput
key={savedSearch.id}
value={savedSearch.name ?? ''}
placeholder="Untitled search"
aria-label="Saved search name"
size="md"
headingLevel={3}
data-testid="saved-search-name"
onCommit={editedName =>
updateSavedSearch
.mutateAsync({
id: savedSearch.id,
name: editedName,
});
}}
/>
</div>
})
.catch(error => {
notifications.show({
color: 'red',
title: 'Unable to save search',
message:
error instanceof Error
? error.message.slice(0, 100)
: 'An error occurred while renaming your saved search.',
});
throw error;
})
}
/>

<Group gap="xs">
<FavoriteButton
Expand Down
92 changes: 0 additions & 92 deletions packages/app/src/EditablePageName.tsx

This file was deleted.

Loading
Loading