Skip to content

Commit d6ca3b2

Browse files
committed
chore(webapp): tighten the side menu code comments
Shorten the explanatory comments added across the resizable side menu and org menu work to the essentials. Comment-only, no behaviour change.
1 parent d012cc9 commit d6ca3b2

14 files changed

Lines changed: 131 additions & 258 deletions

File tree

apps/webapp/app/assets/icons/LeftSideMenuIcon.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ export function LeftSideMenuIcon({
66
hovered: controlledHovered,
77
}: {
88
className?: string;
9-
/**
10-
* When provided, the shape animation is driven by this prop (e.g. from a
11-
* parent button's hover). When omitted, the icon animates on its own hover.
12-
*/
9+
/** Drives the animation when provided (e.g. parent hover); otherwise the icon uses its own hover. */
1310
hovered?: boolean;
1411
}) {
1512
const [internalHovered, setInternalHovered] = useState(false);
@@ -28,10 +25,8 @@ export function LeftSideMenuIcon({
2825
onMouseLeave={isControlled ? undefined : () => setInternalHovered(false)}
2926
>
3027
<rect x="4" y="4" width="16" height="16" rx="2" stroke="currentColor" strokeWidth="2" />
31-
{/* Animate a transform (scaleX) rather than the SVG `width` attribute:
32-
framer snaps the first animation of an SVG geometry attribute after it
33-
has been idle, whereas transforms animate reliably. Anchoring the origin
34-
to the left edge collapses the panel from right to left. */}
28+
{/* Animate a transform (scaleX), not the SVG `width` attr — framer snaps the first animation
29+
of an idle SVG geometry attribute. Left origin collapses the panel right-to-left. */}
3530
<motion.rect
3631
x="6"
3732
y="6"

apps/webapp/app/components/AskAI.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ function useAskAIState() {
7777
}
7878

7979
/**
80-
* Hosts Ask AI for a menu that renders its own trigger (the side menu's Help & Feedback popover):
81-
* the Kapa provider, the global ⌘I shortcut, and the dialog all live here, and `children`
82-
* receives the open function to render a trigger with. Wrap this around the popover rather than
83-
* inside its content so the dialog and shortcut survive the popover closing. `children` receives
84-
* undefined when Ask AI is unavailable (self-hosted, no Kapa website id, or during SSR).
80+
* Hosts Ask AI (Kapa provider, ⌘I shortcut, dialog) for a menu that renders its own trigger. Wrap
81+
* it around the popover, not inside, so the dialog and shortcut survive the popover closing.
82+
* `children` receives the open function, or undefined when Ask AI is unavailable (self-hosted, no
83+
* Kapa website id, or SSR).
8584
*/
8685
export function AskAIRoot({
8786
children,

apps/webapp/app/components/GlobalShortcuts.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { useEffect } from "react";
33
import { useOptionalUser } from "~/hooks/useUser";
44
import { adminPath } from "~/utils/pathBuilder";
55

6-
/**
7-
* App-wide keyboard shortcuts, mounted once at the root so they work on every page regardless of
8-
* which side menu (if any) is rendered. Renders nothing.
9-
*/
6+
/** App-wide keyboard shortcuts, mounted once at the root so they work everywhere. Renders nothing. */
107
export function GlobalShortcuts() {
118
const user = useOptionalUser();
129
const navigate = useNavigate();
@@ -19,15 +16,10 @@ export function GlobalShortcuts() {
1916
if (!isAdmin) return;
2017

2118
const onKeyDown = (event: KeyboardEvent) => {
22-
// Admin-only escape hatch: Cmd+Option+A (Ctrl+Alt+A on Windows) opens the admin dashboard, or
23-
// stops impersonating while impersonating. Two modifiers keep it clear of every user-facing
24-
// shortcut, and it deliberately avoids Escape (Chrome/macOS never delivers a keydown for
25-
// Escape while a modifier is held, which is why the old Cmd+Esc did nothing).
26-
//
27-
// Matched on `event.code` (the physical key) rather than `event.key`, because holding Option
28-
// on macOS makes the "A" key report an alternate character ("å"); the physical code stays
29-
// `KeyA` regardless. This is why it's a raw listener and not the `useShortcutKeys` hook, which
30-
// matches on `event.key`.
19+
// Admin escape hatch: Cmd+Option+A (Ctrl+Alt+A on Windows) opens the admin dashboard, or stops
20+
// impersonating. Avoids Escape — Chrome/macOS never delivers a keydown for Escape+modifier (why
21+
// the old Cmd+Esc did nothing). Matched on `event.code`, not `event.key`, because Option makes
22+
// "A" report "å" (so a raw listener, not the `event.key`-based useShortcutKeys hook).
3123
if (event.code !== "KeyA" || !event.altKey || !(event.metaKey || event.ctrlKey)) {
3224
return;
3325
}

apps/webapp/app/components/environments/EnvironmentLabel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ export function EnvironmentLabel({
8888
tooltipSideOffset?: number;
8989
tooltipSide?: "top" | "right" | "bottom" | "left";
9090
disableTooltip?: boolean;
91-
/** When false, the label clips without an ellipsis (used by the resizable side menu so the label
92-
* fades out in place while dragging instead of truncating). Defaults to true everywhere else. */
91+
/** When false, the label clips without an ellipsis (side menu fades it in place). Defaults true. */
9392
truncate?: boolean;
9493
}) {
9594
const spanRef = useRef<HTMLSpanElement>(null);

apps/webapp/app/components/navigation/EnvironmentSelector.tsx

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ import { V4Badge } from "../V4Badge";
3535
import { type SideMenuEnvironment, type SideMenuProject } from "./SideMenu";
3636
import { Badge } from "../primitives/Badge";
3737

38-
// Size this Env popover's items to match the Project popover menu items
39-
// (SIDE_MENU_POPOVER_ITEM_* in SideMenu.tsx). Applied only at these call sites so the
40-
// shared EnvironmentLabel/EnvironmentCombo defaults used elsewhere in the app stay unchanged.
38+
// Size this Env popover's items to match the Project popover (SIDE_MENU_POPOVER_ITEM_* in
39+
// SideMenu.tsx). Only at these call sites, so shared EnvironmentLabel/EnvironmentCombo defaults stay.
4140
const ENV_POPOVER_ITEM_ICON = "size-5";
4241
const ENV_POPOVER_ITEM_LABEL = "text-[0.90625rem] font-medium tracking-[-0.01em]";
4342

@@ -83,23 +82,17 @@ export function EnvironmentSelector({
8382
<PopoverTrigger
8483
className={cn(
8584
"group flex h-8 items-center rounded pl-1.75 hover:bg-background-hover focus-custom",
86-
// The expanded row arrangement applies while dragging too — the resting classes only
87-
// flip on release, and the label reveal mid-drag needs the expanded layout.
85+
// Expanded arrangement also applies mid-drag (resting classes flip only on release).
8886
isDragging || !isCollapsed ? "justify-between pr-1" : "justify-center pr-0.5",
8987
className
9088
)}
9189
>
9290
<span className="flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden">
9391
<EnvironmentIcon environment={environment} className="size-5 shrink-0" />
9492
{/*
95-
Opacity is driven by the resizable SideMenu's `--sm-label-opacity` variable so the
96-
label fades frame-by-frame in both directions (gating on isCollapsed, which only flips
97-
on release, made the label pop in after a drag-open). The max-width cap is generous
98-
(far wider than any env name) so the visible fade is driven purely by opacity — the
99-
text stays full and fades out in place instead of truncating as the row narrows —
100-
while still reaching 0 as the label finishes fading so it never holds layout width.
101-
Unset in the other places this selector is used (blank-state panels, Limits page)
102-
→ falls back to fully visible.
93+
Opacity follows --sm-label-opacity to fade both directions without popping in on
94+
drag-open; the generous max-width cap fades the text in place (not truncated) but
95+
scales to 0 so it never holds width. Unset elsewhere → fully visible.
10396
*/}
10497
<span
10598
className="flex min-w-0 items-center overflow-hidden"
@@ -117,9 +110,8 @@ export function EnvironmentSelector({
117110
</span>
118111
</span>
119112
{/*
120-
The chevron's 16px of width follows the SideMenu drag variable (falls back to full
121-
width elsewhere): an invisible span that holds its width mid-drag pushes the row's
122-
clip edge into the environment icon.
113+
Chevron's 16px width follows --sm-label-opacity so an invisible span never holds width
114+
mid-drag and pushes the row's clip edge into the icon.
123115
*/}
124116
<span
125117
className="overflow-hidden opacity-0 group-hover:opacity-100"
@@ -132,9 +124,8 @@ export function EnvironmentSelector({
132124
content={`${environmentFullTitle(environment)} environment`}
133125
side="right"
134126
sideOffset={8}
135-
// Only surface the tooltip on the collapsed rail (instant), matching the Org and Project
136-
// selectors: when expanded the label is already visible, and this selector is also reused
137-
// outside the side menu (blank-state panels, Limits page) where a hover tooltip is unwanted.
127+
// Tooltip only on the collapsed rail (expanded shows the label; this selector is also reused
128+
// outside the side menu, where a hover tooltip is unwanted).
138129
hidden={!isCollapsed}
139130
delayDuration={0}
140131
buttonClassName="h-8!"
@@ -316,9 +307,8 @@ function Branches({
316307
}
317308

318309
/**
319-
* The inner content of the branches popover (branch list, empty states, and the
320-
* "Manage branches" footer). Shared by the dropdown's hover submenu (`Branches`)
321-
* and the side-menu segmented control's Preview popover.
310+
* Inner content of the branches popover (list, empty states, "Manage branches" footer). Shared by
311+
* the `Branches` hover submenu and the side-menu Preview popover.
322312
*/
323313
export function BranchesPopoverContent({
324314
parentEnvironment,
@@ -342,10 +332,8 @@ export function BranchesPopoverContent({
342332
? "no-active-branches"
343333
: "has-branches";
344334

345-
// Only surface the active environment's archived-branch item in the submenu it
346-
// actually belongs to. Both Development and Preview render this component, so
347-
// without the parent check an archived dev branch would leak into the Preview
348-
// submenu (and vice-versa).
335+
// Show the archived-branch item only in the submenu it belongs to: both Development and Preview
336+
// render this, so without the parent check an archived dev branch leaks into Preview (and vice-versa).
349337
const currentBranchIsArchived =
350338
environment.archivedAt !== null && environment.parentEnvironmentId === parentEnvironment.id;
351339

apps/webapp/app/components/navigation/HelpAndFeedbackPopover.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ export function HelpAndFeedback({
5353
transition={{ duration: 0.2, ease: "easeInOut" }}
5454
className={isCollapsed ? undefined : "min-w-0 flex-1"}
5555
>
56-
{/*
57-
AskAIRoot hosts the Ask AI dialog and its ⌘I shortcut outside the popover content, so
58-
both keep working when the popover closes; the popover just renders the trigger item.
59-
*/}
56+
{/* AskAIRoot hosts the Ask AI dialog + ⌘I shortcut outside the popover, so both survive the
57+
popover closing; the popover just renders the trigger. */}
6058
<AskAIRoot>
6159
{(openAskAI) => (
6260
<Popover open={isHelpMenuOpen} onOpenChange={setHelpMenuOpen}>
@@ -71,12 +69,9 @@ export function HelpAndFeedback({
7169
<span className="flex min-w-0 items-center gap-1.5 overflow-hidden">
7270
<QuestionMarkIcon className="size-5 min-w-5 shrink-0 text-success" />
7371
{/*
74-
Width and opacity follow the resizable side menu's `--sm-label-opacity` variable
75-
(falls back to fully visible when unset) so the label tracks a drag frame-by-frame
76-
in both directions, matching the nav items — gating the width on isCollapsed,
77-
which only flips on release, made the label pop in after a drag-open. No CSS
78-
transitions: they would lag the per-frame variable writes.
79-
*/}
72+
Width + opacity follow --sm-label-opacity so the label tracks a drag both
73+
directions (no CSS transition — it would lag the per-frame writes).
74+
*/}
8075
<span
8176
className="min-w-0 overflow-hidden whitespace-nowrap text-[0.90625rem] font-medium tracking-[-0.01em] text-text-dimmed group-hover:text-text-bright"
8277
style={{
@@ -88,11 +83,8 @@ export function HelpAndFeedback({
8883
</span>
8984
</span>
9085
{/*
91-
Up/down chevron revealed on hover, matching the Project menu button. Only
92-
rendered when expanded (it is a hover affordance that has no meaning
93-
collapsed), and its 16px of width follows the SideMenu drag variable so an
94-
invisible chevron can never hold width mid-drag and push the row's clip edge
95-
into the help icon.
86+
Hover chevron, only when expanded. Its 16px width follows --sm-label-opacity so
87+
an invisible chevron never holds width mid-drag and clips the help icon.
9688
*/}
9789
{!isCollapsed && (
9890
<span

0 commit comments

Comments
 (0)