Skip to content

feat: summarize initial prompt to generate task title in background - #2363

Open
daewoongoh wants to merge 1 commit into
Zoo-Code-Org:mainfrom
daewoongoh:feat/task-title-summary
Open

daewoongoh wants to merge 1 commit into
Zoo-Code-Org:mainfrom
daewoongoh:feat/task-title-summary

Conversation

@daewoongoh

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #2333

Description

This PR implements automatic background title generation for new root tasks with minimal changes.

Key design points:

  • Background Execution: In Task.startTask, title generation starts as a fire-and-forget background operation after
    the first message is saved. It does not block the agent loop or delay startup. Subtasks and resumed history tasks skip
    title generation.
  • Resource and Timeout Limits: Title generation uses an isolated singleCompletionHandler with a strict 10-second
    timeout. Prompts longer than 1,000 characters are trimmed before sending to prevent token waste and latency. Generated
    titles are clamped to a maximum of 50 characters.
  • Safe Abort on User Cancellation: When a user cancels the task (cancelCurrentRequest, requestAbort, or dispose),
    titleAbortController immediately aborts the underlying network transport. The task title safely falls back to the
    original prompt without overwriting.
  • Race and Override Protection: Uses existing store-level locks via renameTaskWithId. If a user manually renames the
    task before generation finishes, the manual title is preserved.
  • ReDoS Prevention: Uses a template in src/shared/support-prompt.ts with linear string trimming (indexOf/slice)
    rather than vulnerable regular expressions.
  • UI Synchronization: Updates ExtensionStateContext so the generated title immediately reflects in both the chat
    header (TaskHeader) and the recent task list (HistoryPreview).

Test Procedure

  1. Run the new and focused unit tests:
npx vitest run core/task/__tests__/taskTitleGenerator.spec.ts core/task/__tests__/Task.titleGeneration.spec.ts
webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx
  1. Verify type checking and linting:
pnpm check-types
pnpm --dir src exec eslint --max-warnings=0 core/task/taskTitleGenerator.ts core/task/Task.ts shared/support-prompt.ts
core/task/__tests__/taskTitleGenerator.spec.ts core/task/__tests__/Task.titleGeneration.spec.ts
pnpm --dir webview-ui exec eslint --max-warnings=0 src/context/ExtensionStateContext.tsx
src/context/__tests__/ExtensionStateContext.spec.tsx
  1. Manual verification:
    • Start a new task with a long prompt. Observe that the agent starts immediately and the header updates to a concise
    summary title shortly after.
    • Start a task and click Cancel immediately. Verify that title generation aborts and the prompt remains the title.
    • Check the chat home screen (recent task list) to confirm the title displays properly.

Pre-Submission Checklist

[✓] Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
[✓] Scope: My changes are focused on the linked issue (one major feature/fix per PR).
[✓] Self-Review: I reviewed my own code with care.
[✓] Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words,
active voice, one idea per sentence, no contractions.
[✓] Testing: New and/or updated tests have been added to cover my changes (if applicable).
[✓] Test Helpers (test changes only): Shared test helpers (src/test-utils/, @/utils/test-utils) are used only for mechanical
duplication; test intent and scenario-specific mocks remain visible.
[ ] Visual Snapshot (UI changes only): Not applicable. Existing UI components are reused.
[✓] Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
[✓] Contribution Guidelines: I read and agree to the Contributor Guidelines /CONTRIBUTING.md.

Videos (interaction / animation only)

Documentation Updates

[✓] No documentation updates are required.

Additional Notes

• All 66 added/affected unit tests pass.
• No as any or ESLint suppression count increases.

Get in Touch

hehegwk_2384

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1

  • coderabbit-review-active

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Fix the failing required CI checks; awaiting-maintainer requires CI and automated review completion.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/task/Task.ts 94.11% 0 Missing and 2 partials ⚠️
src/core/task/taskTitleGenerator.ts 94.73% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Changed-code mutation testing

Report for PR head da836b466eb0.

Surviving / uncovered mutants Advisories
48 1
Details: mutants, guidance, and reproduction

Changed-code mutation testing

PackageChanged executable linesValidKilledTimeoutSurvivedNo coverageResult
extension96113680432Advisory findings
webview385030Advisory findings

Focused tests

  • extension (cwd src): core/task/__tests__/ask-auto-deny.spec.ts, core/webview/__tests__/ClineProvider.spec.ts, api/providers/__tests__/kimi-code.spec.ts, core/webview/__tests__/ClineProvider.taskHistory.spec.ts, core/task-persistence/__tests__/TaskHistoryStore.spec.ts, __tests__/extension.spec.ts, core/task/__tests__/Task.spec.ts, core/task/__tests__/ask-queued-message-drain.spec.ts, core/task/__tests__/Task.persistence.spec.ts, core/tools/__tests__/executeCommand.spec.ts, activate/__tests__/registerCommands.spec.ts, core/webview/__tests__/webviewMessageHandler.spec.ts, core/webview/__tests__/ClineProvider.sticky-mode.spec.ts, core/tools/__tests__/executeCommandTool.spec.ts, core/webview/__tests__/ClineProvider.apiHandlerRebuild.spec.ts, api/providers/fetchers/__tests__/modelCache.spec.ts, core/task/__tests__/Task.streaming-tool-calls.spec.ts, core/webview/__tests__/ClineProvider.sticky-profile.spec.ts, api/providers/__tests__/native-ollama.spec.ts, api/providers/__tests__/lmstudio.spec.ts, core/config/__tests__/importExport.spec.ts, __tests__/ClineProvider.history-resume-delegation.spec.ts, core/context-management/__tests__/context-management.spec.ts, core/task/__tests__/Task.dispose.test.ts, core/config/__tests__/ContextProxy.spec.ts, core/task/__tests__/ask-clear-approval-buttons.spec.ts, api/providers/__tests__/lmstudio-native-tools.spec.ts, api/providers/__tests__/lm-studio.spec.ts, api/providers/__tests__/lite-llm.spec.ts, core/task/__tests__/ask-allowlist-cwd.spec.ts, api/providers/__tests__/opencode-go.spec.ts, core/webview/__tests__/ClineProvider.stale-view.spec.ts, api/providers/__tests__/lm-studio-timeout.spec.ts, core/config/__tests__/ProviderSettingsManager.spec.ts, core/task/__tests__/grace-retry-errors.spec.ts, core/task/__tests__/flushPendingToolResultsToHistory.spec.ts, core/task/__tests__/taskTitleGenerator.spec.ts, __tests__/single-open-invariant.spec.ts, api/providers/__tests__/openrouter.spec.ts, api/providers/fetchers/__tests__/openrouter.spec.ts, core/webview/__tests__/ClineProvider.lockApiConfig.spec.ts, api/providers/__tests__/model-catalog-adapters.spec.ts, core/task/__tests__/Task.throttle.test.ts, core/webview/__tests__/webviewMessageHandler.routerModels.spec.ts, core/assistant-message/__tests__/presentAssistantMessage-custom-tool.spec.ts, core/checkpoints/__tests__/checkpoint.test.ts, core/task/__tests__/Task.run-shadow.spec.ts, core/webview/__tests__/webviewMessageHandler.delete.spec.ts, services/code-index/__tests__/manager.spec.ts, core/assistant-message/__tests__/presentAssistantMessage-tool-usage-attribution.spec.ts, core/task/__tests__/reasoning-preservation.test.ts, __tests__/ClineProvider.delegation.spec.ts, core/webview/__tests__/ClineProvider.flicker-free-cancel.spec.ts, api/providers/__tests__/zoo-gateway.spec.ts, core/task/__tests__/Task.ignored-disabled-tools-notice.spec.ts, api/providers/__tests__/nanogpt.spec.ts, core/condense/__tests__/index.spec.ts, services/code-index/__tests__/code-index-status-manager.spec.ts, api/providers/__tests__/vercel-ai-gateway.spec.ts, activate/__tests__/registerCodeActions.spec.ts, core/webview/__tests__/webviewMessageHandler.checkpoint.spec.ts, core/webview/__tests__/checkpointRestoreHandler.spec.ts, core/task/__tests__/grounding-sources.test.ts, core/webview/__tests__/webviewMessageHandler.edit.spec.ts, utils/__tests__/autoImportSettings.spec.ts, api/providers/__tests__/requesty.spec.ts, api/providers/__tests__/friendli.spec.ts, __tests__/ClineProvider.subtask-links.spec.ts, api/providers/__tests__/io-intelligence.spec.ts, core/webview/__tests__/webviewMessageHandler.openFile.spec.ts, core/webview/__tests__/generateSystemPrompt.spec.ts, core/condense/__tests__/foldedFileContext.spec.ts, api/providers/fetchers/__tests__/lmstudio.test.ts, core/assistant-message/__tests__/presentAssistantMessage-unknown-tool.spec.ts, core/task/__tests__/Task.resume-eviction-race.spec.ts, core/task/__tests__/Task.titleGeneration.spec.ts, extension/__tests__/api-task-conversation-history-length.spec.ts, core/message-manager/index.spec.ts, core/assistant-message/__tests__/presentAssistantMessage-auto-deny.spec.ts, __tests__/removeClineFromStack-delegation.spec.ts, api/providers/__tests__/kenari.spec.ts, core/task/__tests__/Task.abort-reason-race.spec.ts, extension/__tests__/api-start-task-logging.spec.ts, activate/__tests__/handleUri.spec.ts, core/assistant-message/__tests__/presentAssistantMessage-images.spec.ts, core/webview/__tests__/messageEnhancer.test.ts, api/providers/__tests__/poe.spec.ts, core/task/__tests__/apiConversationHistory.spec.ts, core/assistant-message/__tests__/presentAssistantMessage-tool-repetition.spec.ts, core/tools/__tests__/generateImageTool.test.ts, core/condense/__tests__/condense.spec.ts, core/webview/__tests__/webviewMessageHandler.readOriginalContent.spec.ts, core/webview/__tests__/webviewMessageHandler.searchFiles.spec.ts, extension/__tests__/api-configuration.spec.ts, api/__tests__/index.spec.ts, api/providers/fetchers/__tests__/modelEndpointCache.spec.ts, core/webview/__tests__/webviewMessageHandler.cloudAuth.spec.ts, extension/__tests__/api-start-new-task.spec.ts, core/webview/__tests__/webviewMessageHandler.importRooHistory.spec.ts, services/code-index/__tests__/workspace-indexing-enablement-manager.spec.ts, core/webview/__tests__/webviewMessageHandler.readFileContent.spec.ts, core/task/__tests__/Task.pending-action.spec.ts, extension/__tests__/api-has-task-ui-message-text.spec.ts, core/condense/__tests__/rewind-after-condense.spec.ts, __tests__/abandonSubtask.spec.ts, activate/__tests__/handleTask.spec.ts, core/context-management/__tests__/truncation.spec.ts, api/providers/__tests__/unbound.spec.ts, core/task/__tests__/ask-abort-race.spec.ts, utils/__tests__/enhance-prompt.spec.ts, core/webview/__tests__/webviewMessageHandler.abandonSubtask.spec.ts, core/assistant-message/__tests__/presentAssistantMessage.spec.ts, core/webview/__tests__/webviewMessageHandler.lockApiConfig.spec.ts, services/marketplace/__tests__/marketplace-setting-check.spec.ts, extension/__tests__/api-send-message.spec.ts, __tests__/nested-delegation-resume.spec.ts, core/webview/__tests__/ClineProvider.pending-action.spec.ts, extension/__tests__/api-delegation-events.spec.ts, shared/__tests__/support-prompts.spec.ts, core/webview/__tests__/ClineProviderFactory.spec.ts, core/task/__tests__/ToolExecutionContext.spec.ts, services/code-index/__tests__/code-index-scope.spec.ts, extension/__tests__/api-delete-queued-message.spec.ts, __tests__/task-run-dispatch.spec.ts, core/task/__tests__/Task.sticky-profile-race.spec.ts, __tests__/api-subtask.spec.ts, extension/__tests__/api-theme-fixture.spec.ts, test-utils/__tests__/provider.spec.ts, core/task/__tests__/Task.terminal-operation.spec.ts, __tests__/new-task-delegation.spec.ts, core/condense/__tests__/nested-condense.spec.ts, extension/__tests__/api-terminal-profile.spec.ts, core/assistant-message/__tests__/toTelemetryToolName.spec.ts
  • webview (cwd .): webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx

All surviving and uncovered mutants

Warning annotations highlight up to 20 unique locations (maximum 7 per file). This summary lists every advisory mutant.

extension

src/core/task/Task.ts

LineStatusMutatorReplacement
3203SurvivedConditionalExpressionfalse
3203SurvivedLogicalOperatorthis.abort && this.abandoned
3217SurvivedConditionalExpressionfalse
3217SurvivedLogicalOperator(controller.signal.aborted || this.abort) && this.abandoned
3217SurvivedConditionalExpressionfalse
3217SurvivedLogicalOperatorcontroller.signal.aborted && this.abort
3222SurvivedConditionalExpressionfalse
3227NoCoverageUpdateOperatori--
3227SurvivedConditionalExpressionfalse
3227SurvivedEqualityOperatori <= 20
3227SurvivedEqualityOperatori >= 20
3228SurvivedConditionalExpressionfalse
3228SurvivedLogicalOperator(controller.signal.aborted || this.abort) && this.abandoned
3228SurvivedConditionalExpressionfalse
3228SurvivedLogicalOperatorcontroller.signal.aborted && this.abort
3231SurvivedConditionalExpressiontrue
3231SurvivedConditionalExpressionfalse
3239SurvivedOptionalChainingexisting.title
3243SurvivedConditionalExpressionfalse
3243SurvivedLogicalOperator(controller.signal.aborted || this.abort) && this.abandoned
3243SurvivedConditionalExpressionfalse
3243SurvivedLogicalOperatorcontroller.signal.aborted && this.abort
3249NoCoverageStringLiteral``
3251SurvivedConditionalExpressiontrue

src/core/task/taskTitleGenerator.ts

LineStatusMutatorReplacement
24SurvivedMethodExpressioncleaned.replace(/^["'`]|["'`]$/g, "")
24SurvivedRegex/["'`]|["'`]$/g
24SurvivedRegex/^["'`]|["'`]/g
26SurvivedMethodExpressioncleaned.replace(/[.!?]+$/, "")
26SurvivedRegex/[.!?]+/
28SurvivedConditionalExpressiontrue
28SurvivedEqualityOperatorcleaned.length >= MAX_TITLE_LENGTH
29SurvivedMethodExpressioncleaned.slice(0, MAX_TITLE_LENGTH)
45SurvivedOptionalChainingprompt.trim
62SurvivedBlockStatement{}
63SurvivedCallExpression;
66SurvivedConditionalExpressionfalse
67SurvivedStringLiteral""
67SurvivedObjectLiteral{}
67SurvivedBooleanLiteralfalse
84SurvivedConditionalExpressionfalse
84SurvivedLogicalOperatorcontroller.signal.aborted && parentSignal?.aborted
92SurvivedStringLiteral""
95SurvivedCallExpression;
96SurvivedConditionalExpressionfalse
97SurvivedStringLiteral""

webview

webview-ui/src/context/ExtensionStateContext.tsx

LineStatusMutatorReplacement
617SurvivedConditionalExpressiontrue
617SurvivedConditionalExpressionfalse
617SurvivedEqualityOperatorprevState.currentTaskItem?.id !== item.id

Resolve a mutation gap

Add or strengthen a focused test that fails under the mutation. If the mutant is equivalent, request maintainer approval for the narrowest mutator-specific exclusion and explain why it cannot change behavior:

// Stryker disable next-line ConditionalExpression: normalized input cannot reach the alternate branch
const result = condition ? value : fallback

Broad all exclusions and exclusions without a concrete reason are reported as advisories.

Reproduce locally

From a full checkout containing both commits:

pnpm install --frozen-lockfile
node scripts/stryker-diff.mjs ci --base 73931fe8be253b93ec11103a0672c615e849f895 --head 3668f246525357568be1e745dd37d531d3fd1633

Mutation reports

  • extension: reports/mutation/extension/mutation.html
  • webview: reports/mutation/webview/mutation.html

The workflow uploads generated reports in the changed-code-mutation-report artifact. A direct artifact link appears below after upload.

Advisory findings

  • src/core/task/Task.ts:4501: mutation exclusions must use "// Stryker disable next-line MutatorName: concrete reason"; broad or unreasoned exclusions are not allowed.

This branch has not been deployed

No deployments
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.

[ENHANCEMENT] Generate a session title from the first user message

1 participant