Maestro icon indicating copy to clipboard operation
Maestro copied to clipboard

feat: tab description editing in overlay menu

Open felipeggv opened this issue 9 months ago • 8 comments

Summary

  • Adds description field to AITab type
  • Implements handleUpdateTabDescription handler in useTabHandlers
  • Adds description display/edit UI in tab hover overlay
  • Saves draft on overlay close, returns focus to description button after save/cancel
  • Gated behind encoreFeatures.tabDescription flag
  • Full test coverage for handler and UI

Test plan

  • [ ] npm run lint passes (zero errors)
  • [ ] npm run lint:eslint passes (zero warnings)
  • [ ] npm run test passes (21,026 tests pass; 3 pre-existing CodexSessionStorage timeout flakes)
  • [ ] Description section visible in overlay when feature enabled
  • [ ] Edit mode: Enter saves, Escape cancels, blur saves
  • [ ] Draft saved when overlay closes during edit
  • [ ] No description UI when feature disabled

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Tab descriptions are now editable. Users can add or edit descriptions for tabs, saving changes with Enter and canceling with Escape. Descriptions are automatically trimmed of whitespace.
  • Tests

    • Added comprehensive test coverage for tab description editing features, including state management, input validation, and keyboard event handling.

felipeggv avatar Feb 27 '26 14:02 felipeggv

@coderabbitai review

felipeggv avatar Feb 27 '26 14:02 felipeggv

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Feb 27 '26 14:02 coderabbitai[bot]

📝 Walkthrough

Walkthrough

This PR introduces a feature for editing and persisting per-tab descriptions. It adds type definitions for the description field on tabs, a feature flag to control availability, a new handler to update descriptions, UI components for inline editing with keyboard controls, prop threading through the component hierarchy, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Type Definitions & Feature Flags
src/renderer/types/index.ts, src/renderer/stores/settingsStore.ts
Adds optional description field to AITab type and introduces tabDescription boolean flag to EncoreFeatureFlags with default value false.
Hook Logic
src/renderer/hooks/tabs/useTabHandlers.ts, src/renderer/hooks/props/useMainPanelProps.ts
Adds handleUpdateTabDescription handler that trims and updates description on active session's tab; threads handler through props dependencies and memoization.
Component Layer
src/renderer/components/MainPanel.tsx, src/renderer/components/TabBar.tsx
Adds onUpdateTabDescription callback prop to MainPanel and TabBar; implements description editing UI with textarea, draft state management, Enter/Escape keyboard controls, and focus restoration logic in TabBar.
App Wiring
src/renderer/App.tsx
Wires handleUpdateTabDescription from modal actions hook and threads it to MaestroConsoleInner; conditionally provides handler based on encoreFeatures.tabDescription flag.
Tests
src/__tests__/renderer/components/TabBar.test.tsx, src/__tests__/renderer/hooks/useTabHandlers.test.ts
Adds comprehensive test suites for description UI rendering, edit mode interactions, keyboard handling, trimming behavior, and session/tab isolation scoping.

Sequence Diagram

sequenceDiagram
    actor User
    participant TabBar as TabBar<br/>(Component)
    participant useTabHandlers as useTabHandlers<br/>(Hook)
    participant AITab as AITab<br/>(State)
    
    User->>TabBar: Click description area
    activate TabBar
    TabBar->>TabBar: Enter edit mode<br/>(isEditingDescription=true)
    TabBar->>TabBar: Show textarea with<br/>current description
    deactivate TabBar
    
    User->>TabBar: Type description + Enter
    activate TabBar
    TabBar->>TabBar: Trim description
    TabBar->>useTabHandlers: onUpdateTabDescription(tabId,<br/>trimmedDescription)
    deactivate TabBar
    
    activate useTabHandlers
    useTabHandlers->>AITab: Update description on<br/>active session's tab
    deactivate useTabHandlers
    
    activate TabBar
    TabBar->>TabBar: Sync draft with<br/>new tab.description
    TabBar->>TabBar: Exit edit mode
    deactivate TabBar
    
    TabBar-->>User: Display updated description

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • RunMaestro/Maestro#470 — Modifies App/MainPanel wiring and public props surface for threading handlers, similar architecture pattern used in this PR.
  • RunMaestro/Maestro#418 — Modifies useTabHandlers hook; potential overlap or interaction point with the new handleUpdateTabDescription logic added in this PR.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: tab description editing in overlay menu' clearly and specifically describes the main feature addition—enabling users to edit tab descriptions directly in the tab overlay/hover menu.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Feb 27 '26 14:02 coderabbitai[bot]

Greptile Summary

This PR adds user-editable descriptions to AI tabs, accessible through the tab hover overlay menu. The implementation is clean and well-tested:

Implementation highlights:

  • Description field added to AITab type and handler implemented in useTabHandlers
  • UI in tab overlay supports edit/display modes with keyboard shortcuts (Enter saves, Escape cancels, Shift+Enter adds newline)
  • Draft auto-saves on blur or overlay close during editing
  • Focus returns to description button after save/cancel for good keyboard UX
  • Feature gated behind encoreFeatures.tabDescription flag (default: false)

Code quality:

  • Proper state management using refs to avoid stale closures in cleanup effects
  • Handler trims whitespace and uses undefined for empty values (good data hygiene)
  • Only operates on active session, preventing cross-session modifications
  • Full test coverage for both handler logic (trimming, session isolation) and UI behavior (keyboard events, focus management, feature gating)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - clean implementation, comprehensive tests, and proper feature gating
  • Score reflects well-structured code following React best practices, comprehensive test coverage (21,026 tests passing), proper keyboard accessibility, feature flag gating to control rollout, and no breaking changes to existing functionality
  • No files require special attention - all changes are straightforward and well-tested

Important Files Changed

Filename Overview
src/renderer/types/index.ts Added description field to AITab and tabDescription flag to EncoreFeatureFlags - straightforward type additions
src/renderer/hooks/tabs/useTabHandlers.ts Added handleUpdateTabDescription handler with proper trimming, undefined for empty strings, and session isolation
src/renderer/components/TabBar.tsx Implemented description UI with edit/display modes, keyboard handling (Enter/Escape), blur save, and draft persistence on overlay close
src/tests/renderer/hooks/useTabHandlers.test.ts Added comprehensive tests covering trimming, empty strings, session isolation, and multi-tab scenarios
src/tests/renderer/components/TabBar.test.tsx Added UI tests for description display, edit mode, keyboard handlers, and feature flag gating

Last reviewed commit: 21bcf98

greptile-apps avatar Feb 27 '26 14:02 greptile-apps

📝 Walkthrough

Walkthrough

This change introduces a tab description editing feature throughout the application. It adds an onUpdateTabDescription callback that propagates from the root through the component hierarchy to TabBar, implements description editing UI with keyboard shortcuts, adds a corresponding handler in the tab management hook, introduces a feature flag to control availability, and includes comprehensive test coverage.

Changes

Cohort / File(s) Summary
Test Coverage
src/__tests__/renderer/components/TabBar.test.tsx, src/__tests__/renderer/hooks/useTabHandlers.test.ts
New test suites for description editing in TabBar (including overlay rendering, edit mode entry/exit, trimming, and submission) and comprehensive unit tests for the handleUpdateTabDescription handler covering trimmed values, empty strings, session scoping, and multi-tab behavior.
Feature Implementation
src/renderer/hooks/tabs/useTabHandlers.ts, src/renderer/stores/settingsStore.ts, src/renderer/types/index.ts
Implementation of handleUpdateTabDescription handler that trims and updates tab descriptions, new tabDescription feature flag (default: false), and type additions (description field on AITab, tabDescription boolean in EncoreFeatureFlags).
Component Hierarchy Wiring
src/renderer/App.tsx, src/renderer/hooks/props/useMainPanelProps.ts, src/renderer/components/MainPanel.tsx, src/renderer/components/TabBar.tsx
Propagation of handleUpdateTabDescription from App through useMainPanelProps and MainPanel to TabBar; TabBar implements description UI with edit mode (isEditingDescription, descriptionDraft), keyboard handlers (Enter to save, Escape to cancel), and conditional rendering behind the feature flag.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #418: Modifies useTabHandlers.ts to refactor tab construction with buildUnifiedTabs/ensureInUnifiedTabOrder, overlapping with the hook changes in this PR.
  • PR #452: Refactors App.tsx, useMainPanelProps, and MainPanel prop surfaces, creating potential conflicts with the prop threading changes introduced here.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding tab description editing functionality to the overlay menu, which aligns with the substantial changes across TabBar, handlers, and UI components.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Feb 27 '26 14:02 coderabbitai[bot]

@felipeggv please run the following on your machine for this PR so it can move toward acceptance.

Here is the prompt you should run:

You are responsible for getting this PR in RunMaestro/Maestro to an accept-ready state.

PR: https://github.com/RunMaestro/Maestro/pull/472
Branch/Head: inspect the PR branch locally before making changes.

Goal:
Drive this PR to zero unresolved CodeRabbit and Greptile review threads.

Process:
1. Fetch the PR locally and work from a clean git worktree on the PR branch.
2. List all unresolved CodeRabbit and Greptile review threads for this PR.
3. For each unresolved bot thread:
   - verify whether the issue is still real on the current PR head
   - if it is already fixed or the thread is outdated, resolve the GitHub review thread immediately
   - if it is real, implement the smallest correct fix on the PR branch
4. After each fix batch:
   - run the relevant validation commands locally
   - push the branch
   - re-poll the PR’s unresolved CodeRabbit/Greptile threads
   - resolve any newly stale/fixed bot threads
5. Repeat until this PR has zero unresolved CodeRabbit and Greptile threads.

Rules:
- Resolve bot threads only when the current branch state actually fixes them.
- Do not resolve human review threads unless explicitly asked.
- Be surgical. Do not broaden scope beyond the review findings.
- If local validation differs from CI because of environment issues, state the exact failing test/check and the exact missing dependency/file/path.
- If a bot comment is a design tradeoff rather than a bug, explain why and leave it unresolved only if it truly still applies.

Definition of done:
- zero unresolved CodeRabbit threads
- zero unresolved Greptile threads
- branch pushed
- latest validation/check status re-polled
- concise summary written with:
  - PR URL
  - commits pushed
  - threads resolved
  - any remaining blockers

Keep looping until the PR is clean.

jeffscottward avatar Mar 14 '26 17:03 jeffscottward

Thanks for this contribution, @felipeggv! Nice feature — clean implementation, good test coverage, and proper feature-flag gating.

One change I'd like addressed before approval:

🟠 Guard Enter/Escape during IME composition (src/renderer/components/TabBar.tsx around L490-500)

The handleDescriptionKeyDown handler currently processes save/cancel even while a user is mid-composition with an IME (Japanese, Chinese, Korean, etc.), which prematurely commits or cancels their input. CodeRabbit flagged this as unresolved and it's a real UX bug for international users.

Suggested fix:

 const handleDescriptionKeyDown = useCallback(
 	(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
+		const native = e.nativeEvent as KeyboardEvent;
+		if (native.isComposing || native.keyCode === 229) return;
+
 		if (e.key === 'Enter' && !e.shiftKey) {
 			e.preventDefault();
 			handleDescriptionSave(descriptionDraft);
 		} else if (e.key === 'Escape') {
 			e.preventDefault();
 			handleDescriptionCancel();
 		}
 	},
 	[descriptionDraft, handleDescriptionSave, handleDescriptionCancel]
 );

Optional nitpicks (feel free to apply or skip):

  • The inline callback ref ref={(el) => el?.focus()} on the textarea (~L763) is recreated each render. A stable useRef + useEffect keyed on isEditingDescription avoids repeated refocus.
  • In handleUpdateTabDescription (useTabHandlers.ts ~L973), short-circuit when trimmed matches the existing description to skip avoidable re-renders.

Once the IME guard lands, happy to approve. Thanks again!

pedramamini avatar Apr 23 '26 06:04 pedramamini

Thanks for the contribution, @felipeggv! Really nice feature — well-scoped, gated behind the encoreFeatures.tabDescription flag, and the test coverage is solid. Greptile gave this a 5/5 confidence score.

Before approving, there's one item from CodeRabbit's review I'd like to see addressed:

IME composition handling (TabBar.tsx, handleDescriptionKeyDown ~L490-500) — Enter/Escape will prematurely commit or cancel input while a user is composing text via an IME (e.g. Chinese/Japanese/Korean input). Quick guard at the top of the handler:

const native = e.nativeEvent as KeyboardEvent;
if (native.isComposing || native.keyCode === 229) return;

The other CodeRabbit items are nitpicks and optional — feel free to take them or leave them:

  • Inline callback ref ref={(el) => el?.focus()} at L763-765 — recreated each render; a stable ref + useEffect keyed on isEditingDescription is cleaner.
  • handleUpdateTabDescription in useTabHandlers.ts could short-circuit when description is unchanged to avoid recreating the session object.
  • Tests could add coverage for Shift+Enter (newline insertion) and draft-saved-on-overlay-close.

Once the IME guard is in, I'll happily approve. Thanks again!

pedramamini avatar May 26 '26 16:05 pedramamini