Skip to content

WIP: Allow canceling / reverting prompt enhancement #1267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hassoncs
Copy link
Contributor

@hassoncs hassoncs commented Jul 11, 2025

Allow canceling / reverting prompt enhancement!
2025-07-11 11 12 42

Copy link

changeset-bot bot commented Jul 11, 2025

⚠️ No Changeset found

Latest commit: ce5eaf7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@hassoncs hassoncs changed the title 'chore: WIP' WIP: Allow canceling / reverting prompt enhancement Jul 11, 2025
@hassoncs hassoncs requested a review from Copilot July 11, 2025 18:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for canceling and reverting prompt enhancements in the chat UI.

  • Introduces cancelEnhancement and revertEnhancement labels in all locales.
  • Updates ChatTextArea to store original/enhanced prompt state and handle cancel/revert flows.
  • Adds unit and E2E tests covering enhancement, cancellation, and revert behaviors.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
webview-ui/src/i18n/locales/*/kilocode.json Added enhancePrompt translations for all locales
webview-ui/src/components/chat/ChatTextArea.tsx Implemented prompt cancellation and revert logic
webview-ui/src/components/chat/tests/ChatTextArea.spec.tsx Added tests for cancel/revert prompt enhancement
apps/playwright-e2e/tests/enhance-prompt.test.ts New E2E tests for prompt enhancement flows
apps/playwright-e2e/tests/chat-with-response-refactored.test.ts New refactored chat E2E test
apps/playwright-e2e/playwright.config.ts Adjusted retry settings
apps/playwright-e2e/helpers/test-setup-helpers.ts Extracted shared test setup helper
apps/playwright-e2e/helpers/enhance-prompt-helpers.ts Helper functions for E2E prompt enhancement tests
apps/playwright-e2e/helpers/chat-helpers.ts Helper functions for E2E chat interactions
Comments suppressed due to low confidence (1)

webview-ui/src/components/chat/ChatTextArea.tsx:1480

  • The translation key namespace appears incorrect; verify whether it should be t("chat:enhancePrompt.cancelEnhancement") instead of t("kilocode:chat.enhancePrompt.cancelEnhancement").
							title={

@@ -46,6 +46,10 @@
"condense": {
"wantsToCondense": "Kilo Code 想要壓縮你的對話",
"condenseConversation": "壓縮對話"
},
"enhancePrompt": {
"cancelEnhancement": "取消增强功能",
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Use traditional Chinese characters for zh-TW: change to "取消增強功能".

Suggested change
"cancelEnhancement": "取消增强功能",
"cancelEnhancement": "取消增強功能",

Copilot uses AI. Check for mistakes.

fireEvent.click(enhanceButton)

// Cancel enhancement
fireEvent.click(enhanceButton)
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

The test helper getEnhancePromptButton only selects the sparkle icon, so after enhancement or cancellation the icon changes and this selector will fail. Consider selecting by data-testid="enhance-prompt-button" or updating the helper to cover all states.

Copilot uses AI. Check for mistakes.

Comment on lines +1464 to +1472
console.log("Icon state debug:", {
isEnhancingPrompt,
hasEnhancedText: !!enhancedPromptText,
hasOriginalText: !!originalPromptBeforeEnhancement,
inputLength: inputValue.trim().length,
enhancedLength: enhancedPromptText?.trim().length,
textsMatch: inputValue.trim() === enhancedPromptText?.trim(),
canRevert,
})
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Remove or guard debug console.log statements before merging to avoid polluting the production console.

Suggested change
console.log("Icon state debug:", {
isEnhancingPrompt,
hasEnhancedText: !!enhancedPromptText,
hasOriginalText: !!originalPromptBeforeEnhancement,
inputLength: inputValue.trim().length,
enhancedLength: enhancedPromptText?.trim().length,
textsMatch: inputValue.trim() === enhancedPromptText?.trim(),
canRevert,
})
if (process.env.NODE_ENV === 'development') {
console.log("Icon state debug:", {
isEnhancingPrompt,
hasEnhancedText: !!enhancedPromptText,
hasOriginalText: !!originalPromptBeforeEnhancement,
inputLength: inputValue.trim().length,
enhancedLength: enhancedPromptText?.trim().length,
textsMatch: inputValue.trim() === enhancedPromptText?.trim(),
canRevert,
})
}

Copilot uses AI. Check for mistakes.

@@ -248,15 +253,43 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
return
}

// If currently enhancing, cancel the enhancement
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

This multi-line change (handling cancel/revert logic) should be wrapped with // kilocode_change start and // kilocode_change end comments per fork guidelines.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,51 @@
import { test, type TestFixtures } from "./playwright-base-test"
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

New test file should include // kilocode_change - new file at the top to mark it as a new addition.

Copilot uses AI. Check for mistakes.

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.

1 participant