Skip to content

feat(settings): issue context default toggle#2125

Merged
arnestrickmann merged 9 commits into
mainfrom
jan/eng-1330-auto-include-issue-context-when-creating-a-task-from-an
May 21, 2026
Merged

feat(settings): issue context default toggle#2125
arnestrickmann merged 9 commits into
mainfrom
jan/eng-1330-auto-include-issue-context-when-creating-a-task-from-an

Conversation

@janburzinski
Copy link
Copy Markdown
Collaborator

Screen.Recording.2026-05-19.at.20.59.12.mov

…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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Greptile Summary

This 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 from-issue-content.tsx for the auto-fetch path and a fallback fetch inside handleCreateTask when context wasn't yet in the prompt at creation time.

  • Settings plumbing: schema, registry defaults, useTaskSettings hook, and the settings UI row are all wired up consistently with the existing settings pattern.
  • Auto-fetch on issue selection: from-issue-content.tsx increments issueContextRequestId at the top of handleValueChange (before all early returns), so in-flight requests from prior selections are correctly invalidated regardless of which early-return path is taken.
  • Upsert helper: upsertInitialIssueContext uses a non-greedy regex that correctly preserves surrounding whitespace when replacing, backed by a test covering the blank-line-preservation case.

Confidence Score: 5/5

Safe to merge; the core auto-fetch and task-creation paths are correctly guarded.

The request-ID cancellation in the auto-fetch path, the hasInitialIssueContext guard in handleCreateTask, and the finally-based isCreating reset all work correctly. The only unguarded path is the manual "Add issue context" button click in InitialConversationField, which lacks a loading state and de-duplication, but its outcome is still correct because upsertInitialIssueContext replaces rather than appends.

initial-conversation-section.tsx — the manual action-click path has no loading state or request guard.

Important Files Changed

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)
Loading
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

Comment thread src/renderer/features/tasks/create-task-modal/create-task-modal.tsx
Comment thread src/renderer/features/tasks/create-task-modal/create-task-modal.tsx Outdated
@janburzinski
Copy link
Copy Markdown
Collaborator Author

@greptileai

Comment thread src/renderer/features/tasks/create-task-modal/from-issue-content.tsx Outdated
@janburzinski
Copy link
Copy Markdown
Collaborator Author

@greptileai

@arnestrickmann
Copy link
Copy Markdown
Contributor

could you once again fix the conflicts, please?:) @janburzinski

@janburzinski
Copy link
Copy Markdown
Collaborator Author

@arnestrickmann did :D

Copy link
Copy Markdown
Contributor

@arnestrickmann arnestrickmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@arnestrickmann arnestrickmann merged commit 8fa1ded into main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants