feat(comments): reintroduce comments popover with in-memory draft store#1415
Conversation
|
@jschwxrz is attempting to deploy a commit to the General Action Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR replaces the database-backed line comments system with a lightweight in-memory Key changes:
Notable issue: Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/renderer/hooks/useCommentInjection.ts | New hook that bridges DraftCommentsStore to PendingInjectionManager; has a logic bug where tab switching in MultiAgentTask clears the wrong scope's pending comments, and missing unmount cleanup leaks comments into subsequent tasks. |
| src/renderer/lib/DraftCommentsStore.ts | Well-designed in-memory comment store with useSyncExternalStore integration, 200-comment cap, and proper scope isolation; minor API issue where add() returns an ID even when the comment wasn't stored at capacity. |
| src/renderer/lib/PendingInjectionManager.ts | Global singleton for coordinating comment injection timing between React hooks and the class-based TerminalSessionManager; the singleton design creates cross-task contamination risk when multiple tasks are simultaneously mounted. |
| src/renderer/components/MultiAgentTask.tsx | handleRunAll correctly builds per-variant comment payloads and consumes comments only after successful PTY injection; properly isolates variants via buildCommentScopeKey. |
| src/renderer/terminal/TerminalSessionManager.ts | Correctly gates comment injection behind providerId check, slash-command detection, and hasUserMessage guard; only triggers injection for real user messages, not bare Enter presses. |
| src/renderer/lib/terminalInjection.ts | Payload construction correctly uses raw multiline for Claude and bracketed paste for other providers; inputData is only trailing-newline-stripped and may carry residual ANSI sequences. |
| src/shared/text/stripAnsi.ts | Clean, option-driven stripAnsi implementation replacing multiple ad-hoc inline regexes; correctly handles CSI, OSC-BEL, OSC-ST, and other escapes with composable options. |
| src/renderer/lib/formatCommentsForAgent.ts | Straightforward XML formatter grouping comments by file; correctly sorts by line number and supports optional intro and leading-newline options. |
| src/renderer/lib/slashCommand.ts | Correctly classifies /commands and TUI-style i/model prefixed inputs to skip comment injection; regex SINGLE_PREFIX_TUI_SLASH_RE requires at least 3 chars after the slash which covers real commands. |
| src/renderer/hooks/useLineComments.ts | Clean React hook wrapping DraftCommentsStore with useSyncExternalStore; correctly memoizes callbacks and filters by file path for the diff-view use case. |
| src/renderer/components/CommentsPopover.tsx | Simple, clean popover UI for displaying and deleting draft comments; reads from TaskScopeContext and correctly groups by file path. |
| src/renderer/terminal/submitCapture.ts | Correctly reconstructs submitted text from keystroke stream by handling backspace, Ctrl-U, and Enter; uses shared stripAnsi with private CSI params enabled. |
| src/renderer/components/ChatInterface.tsx | Correctly replaced useTaskComments with useCommentInjection and removed the old comment prepending logic from issue context builders. |
Sequence Diagram
sequenceDiagram
participant User
participant DiffView
participant DraftCommentsStore
participant useCommentInjection
participant PendingInjectionManager
participant TerminalSessionManager
participant PTY
User->>DiffView: Click gutter + icon
DiffView->>DraftCommentsStore: add(scopeKey, comment)
DraftCommentsStore-->>useCommentInjection: notify subscribers
useCommentInjection->>useCommentInjection: formatCommentsForAgent(comments)
useCommentInjection->>PendingInjectionManager: setPending(formattedXML)
User->>TerminalSessionManager: type message + Enter
TerminalSessionManager->>TerminalSessionManager: consumeSubmittedInput(data)
TerminalSessionManager->>PendingInjectionManager: getPending()
PendingInjectionManager-->>TerminalSessionManager: formattedXML
TerminalSessionManager->>TerminalSessionManager: isSlashCommandInput? → no
TerminalSessionManager->>TerminalSessionManager: buildCommentInjectionPayload(providerId, input, formattedXML)
TerminalSessionManager->>PTY: ptyInput(payload)
TerminalSessionManager->>PendingInjectionManager: markUsed()
PendingInjectionManager->>useCommentInjection: onInjectionUsed callback
useCommentInjection->>DraftCommentsStore: consumeAll(scopeKey)
Note over DraftCommentsStore: Comments cleared from store
Note over PendingInjectionManager: MultiAgent path differs — handleRunAll injects per-variant directly via ptyInput, then calls consumeAll manually
Last reviewed commit: 63b906a
summary
changes:
fixes #1388