feat(settings): issue context default toggle#2125
Conversation
…lude-issue-context-when-creating-a-task-from-an # Conflicts: # src/renderer/features/tasks/create-task-modal/initial-conversation-section.tsx # src/renderer/features/tasks/create-task-modal/modal-context-bar.tsx
Greptile SummaryThis PR adds a new "Include issue context by default" setting that, when enabled, automatically fetches and injects the selected issue's context into the initial agent prompt when creating a task from an issue. The implementation includes a request-ID cancellation guard in
Confidence Score: 5/5Safe to merge; the core auto-fetch and task-creation paths are correctly guarded. The request-ID cancellation in the auto-fetch path, the
|
| Filename | Overview |
|---|---|
| src/main/core/settings/schema.ts | Adds includeIssueContextByDefault: z.boolean() to the task settings schema — straightforward, consistent with existing fields. |
| src/main/core/settings/settings-registry.ts | Sets includeIssueContextByDefault: true as the default — consistent with the intent of the feature. |
| src/renderer/features/settings/components/TaskSettingsRows.tsx | Adds IncludeIssueContextByDefaultRow component following the exact same pattern as the existing setting rows; clean and complete. |
| src/renderer/features/tasks/hooks/useTaskSettings.ts | Extends TaskSettingsModel and its implementation with includeIssueContextByDefault, updateIncludeIssueContextByDefault, and resetIncludeIssueContextByDefault; defaults to true during load. |
| src/renderer/features/tasks/create-task-modal/initial-conversation-text.ts | Introduces formatInitialIssueContextBlock, hasInitialIssueContext, and upsertInitialIssueContext using a non-greedy regex; the pattern correctly preserves surrounding whitespace on replace. |
| src/renderer/features/tasks/conversations/resolve-context-action-text.ts | New helper that refreshes Linear issue context before building the context text, falling back to the original action text if refresh returns null. |
| src/renderer/features/tasks/create-task-modal/from-issue-content.tsx | Adds auto-fetch of issue context on issue selection with request-ID cancellation guard. The increment happens at the top of handleValueChange so all early-return paths correctly cancel in-flight requests. |
| src/renderer/features/tasks/create-task-modal/create-task-modal.tsx | Makes handleCreateTask async, adds isCreating guard on the Create button, and adds a fallback fetch inside handleCreateTask when issue context wasn't yet in the prompt. The finally block always resets isCreating, including on early returns. |
| src/renderer/features/tasks/create-task-modal/initial-conversation-section.tsx | Converts handleActionClick to async for linked-issue actions, using upsertInitialIssueContext instead of appendInitialConversationText. Manual clicks have no loading/disabled state during the fetch, allowing unconstrained concurrent requests. |
| src/renderer/features/tasks/create-task-modal/modal-context-bar.tsx | Adds issueActionPending prop to show a spinner and disable the issue button while context is being fetched automatically. |
| src/renderer/tests/initial-conversation-text.test.ts | Good test coverage: append, replace with surrounding text, replace-only block, and blank-line preservation are all exercised. |
Sequence Diagram
sequenceDiagram
participant User
participant FromIssueContent
participant ModalContextBar
participant resolveContextActionText
participant handleCreateTask
User->>FromIssueContent: Select issue
FromIssueContent->>FromIssueContent: increment issueContextRequestId
alt "includeIssueContextByDefault = true"
FromIssueContent->>resolveContextActionText: fetch issue context (requestId N)
FromIssueContent->>ModalContextBar: "issueActionPending=true"
resolveContextActionText-->>FromIssueContent: issueContext
alt requestId matches current
FromIssueContent->>FromIssueContent: upsertInitialIssueContext(prompt, issueContext)
end
FromIssueContent->>ModalContextBar: "issueActionPending=false"
end
User->>handleCreateTask: Click Create
handleCreateTask->>handleCreateTask: setIsCreating(true)
alt "from-issue && setting on && no context yet in prompt"
handleCreateTask->>resolveContextActionText: fetch issue context (fallback)
resolveContextActionText-->>handleCreateTask: issueContext
handleCreateTask->>handleCreateTask: upsertInitialIssueContext(prompt, issueContext)
end
handleCreateTask->>handleCreateTask: createTask(builtInitialConversation)
handleCreateTask->>handleCreateTask: navigate + onClose
handleCreateTask->>handleCreateTask: finally: setIsCreating(false)
User->>ModalContextBar: Click Add issue context manually
ModalContextBar->>resolveContextActionText: fetch issue context (no request guard)
resolveContextActionText-->>ModalContextBar: issueContext
ModalContextBar->>FromIssueContent: upsertInitialIssueContext(current, text)
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/renderer/features/tasks/create-task-modal/initial-conversation-section.tsx:91-99
**Manual "Add issue context" button has no loading state during its own fetch**
`handleActionClick` for a `linked-issue` action is async and fires `resolveContextActionText`, but `issueActionPending` is only driven by the auto-fetch in `from-issue-content.tsx`. When a user clicks the button manually (e.g. the auto-fetch was already done or disabled), `issueActionPending` stays `false`, the button remains enabled, and rapid multiple clicks launch concurrent fetches with no request-ID guard. Each settled promise independently calls `state.setPrompt((current) => upsertInitialIssueContext(current, text))`, so the final content is correct, but there is no visual feedback and redundant network requests fire freely.
Reviews (3): Last reviewed commit: "Fix stale issue context requests" | Re-trigger Greptile
|
could you once again fix the conflicts, please?:) @janburzinski |
|
@arnestrickmann did :D |
Screen.Recording.2026-05-19.at.20.59.12.mov