Skip to content

Allow canceling / reverting prompt enhancement - #1267

Closed
hassoncs wants to merge 3 commits into
mainfrom
cancel-revert-enhancement
Closed

Allow canceling / reverting prompt enhancement#1267
hassoncs wants to merge 3 commits into
mainfrom
cancel-revert-enhancement

Conversation

@hassoncs

@hassoncs hassoncs commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

Allow canceling / reverting prompt enhancement!

2025-07-21 11 03 35

  • Clicking the button again while it loads will cancel the enhancement
  • After enhancement, the button turns into a "revert" button
  • If the enhanced prompt is changed at all, the revert button becomes an 'enhance' button again

Summary by CodeRabbit

  • New Features

    • Added the ability to cancel an ongoing prompt enhancement or revert to the original prompt after enhancement in the chat interface.
    • The enhance prompt button now dynamically changes its function, tooltip, aria-label, and icon based on the current state (enhance, cancel, revert).
  • Bug Fixes

    • Improved handling of prompt enhancement cancellation and revert actions to ensure consistent user experience.
  • Tests

    • Enhanced and extended test coverage for prompt enhancement, including scenarios for canceling and reverting enhancements.
  • Localization

    • Added new translations for prompt enhancement actions ("Cancel enhancement" and "Revert to original prompt") across all supported languages.

@changeset-bot

changeset-bot Bot commented Jul 11, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4e3cbec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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={

Comment thread webview-ui/src/i18n/locales/zh-TW/kilocode.json Outdated
Comment thread webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx Outdated
Comment thread webview-ui/src/components/chat/ChatTextArea.tsx Outdated
Comment thread webview-ui/src/components/chat/ChatTextArea.tsx Outdated
Comment thread apps/playwright-e2e/tests/enhance-prompt.test.ts Outdated
@hassoncs
hassoncs force-pushed the cancel-revert-enhancement branch 2 times, most recently from 14246b7 to 354d9d2 Compare July 17, 2025 04:21
@chrarnoldus

Copy link
Copy Markdown
Collaborator

related? RooCodeInc/Roo-Code#5742

@hassoncs
hassoncs force-pushed the cancel-revert-enhancement branch from 3f8688a to d7a8933 Compare July 21, 2025 17:52
@hassoncs
hassoncs changed the base branch from main to roo-v3.23.14 July 21, 2025 17:52
@hassoncs

Copy link
Copy Markdown
Contributor Author

@chrarnoldus, oh yeah! Looks like they built a rough version of this based on the native undo! I'll see what parts of this make sense to keep around

@hassoncs
hassoncs force-pushed the cancel-revert-enhancement branch 2 times, most recently from 473383d to 0a08647 Compare July 21, 2025 22:34
Base automatically changed from roo-v3.23.14 to main July 22, 2025 12:26
@hassoncs
hassoncs force-pushed the cancel-revert-enhancement branch 3 times, most recently from 91a0a89 to 81148d5 Compare July 22, 2025 17:49
@hassoncs
hassoncs changed the base branch from main to cleanup-playwright-helpers July 22, 2025 17:50
@hassoncs hassoncs changed the title WIP: Allow canceling / reverting prompt enhancement Allow canceling / reverting prompt enhancement Jul 22, 2025
@hassoncs
hassoncs marked this pull request as ready for review July 22, 2025 17:51
Base automatically changed from cleanup-playwright-helpers to main July 22, 2025 18:50
@hassoncs
hassoncs force-pushed the cancel-revert-enhancement branch 5 times, most recently from 8d22646 to 0d35e84 Compare July 24, 2025 23:12
Comment thread webview-ui/src/components/chat/ChatTextArea.tsx
@coderabbitai

coderabbitai Bot commented Jul 25, 2025

Copy link
Copy Markdown

Walkthrough

This update introduces a reversible prompt enhancement feature in the chat interface. Users can now enhance, cancel, or revert prompt enhancements. The UI and logic for the enhance prompt button have been updated accordingly, including state management, localization, and comprehensive tests. Supporting Playwright helpers were added to facilitate end-to-end testing.

Changes

File(s) Change Summary
.changeset/old-socks-decide.md Documents the addition of cancel and revert support for prompt enhancement.
apps/playwright-e2e/helpers/enhance-prompt-helpers.ts Adds Playwright helper functions for interacting with the enhance prompt button.
webview-ui/src/components/chat/ChatTextArea.tsx Implements prompt enhancement, cancellation, and revert logic with UI state management.
webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx Updates and extends tests for prompt enhancement, cancellation, and revert behaviors.
webview-ui/src/i18n/locales/.../kilocode.json (all language variants) Adds new localization keys for "cancel enhancement" and "revert to original prompt" in all supported languages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatTextArea
    participant VSCodeWebview

    User->>ChatTextArea: Click "Enhance" button
    ChatTextArea->>VSCodeWebview: Post message to enhance prompt
    alt Enhancement in progress
        User->>ChatTextArea: Click "Cancel" button
        ChatTextArea->>VSCodeWebview: Cancel enhancement request
    else Enhancement completed
        VSCodeWebview-->>ChatTextArea: Send enhanced prompt
        ChatTextArea->>User: Show enhanced prompt
        User->>ChatTextArea: Click "Revert" button
        ChatTextArea->>User: Restore original prompt
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A sparkle, a spin, then a twist in the air,
Enhance or revert—your prompt’s in good care!
With cancel at hand and translations anew,
The button now listens to all that you do.
Rabbits approve, with a hop and a cheer—
Your prompts are reversible, magic is here!
✨🔄🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/playwright-e2e/helpers/enhance-prompt-helpers.ts

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

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

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a126e62 and 4e3cbec.

📒 Files selected for processing (26)
  • .changeset/old-socks-decide.md (1 hunks)
  • apps/playwright-e2e/helpers/enhance-prompt-helpers.ts (1 hunks)
  • webview-ui/src/components/chat/ChatTextArea.tsx (8 hunks)
  • webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx (6 hunks)
  • webview-ui/src/i18n/locales/ar/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ca/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/cs/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/de/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/en/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/es/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/fr/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/hi/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/id/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/it/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ja/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ko/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/nl/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/pl/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/pt-BR/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ru/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/th/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/tr/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/uk/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/vi/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/zh-CN/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/zh-TW/kilocode.json (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • webview-ui/src/i18n/locales/hi/kilocode.json
  • webview-ui/src/i18n/locales/en/kilocode.json
  • webview-ui/src/i18n/locales/ru/kilocode.json
  • webview-ui/src/i18n/locales/uk/kilocode.json
  • webview-ui/src/i18n/locales/cs/kilocode.json
🚧 Files skipped from review as they are similar to previous changes (21)
  • .changeset/old-socks-decide.md
  • webview-ui/src/i18n/locales/ca/kilocode.json
  • webview-ui/src/i18n/locales/ar/kilocode.json
  • webview-ui/src/i18n/locales/id/kilocode.json
  • webview-ui/src/i18n/locales/pl/kilocode.json
  • webview-ui/src/i18n/locales/pt-BR/kilocode.json
  • webview-ui/src/i18n/locales/tr/kilocode.json
  • webview-ui/src/i18n/locales/es/kilocode.json
  • webview-ui/src/i18n/locales/de/kilocode.json
  • webview-ui/src/i18n/locales/zh-TW/kilocode.json
  • webview-ui/src/i18n/locales/ja/kilocode.json
  • webview-ui/src/i18n/locales/nl/kilocode.json
  • webview-ui/src/i18n/locales/vi/kilocode.json
  • webview-ui/src/i18n/locales/zh-CN/kilocode.json
  • webview-ui/src/i18n/locales/ko/kilocode.json
  • webview-ui/src/i18n/locales/th/kilocode.json
  • webview-ui/src/i18n/locales/fr/kilocode.json
  • webview-ui/src/components/chat/tests/ChatTextArea.spec.tsx
  • webview-ui/src/i18n/locales/it/kilocode.json
  • apps/playwright-e2e/helpers/enhance-prompt-helpers.ts
  • webview-ui/src/components/chat/ChatTextArea.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cancel-revert-enhancement

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (6)
webview-ui/src/i18n/locales/en/kilocode.json (1)

55-56: Consider using Title Case for consistency

Most button-style labels in this file use Title Case (e.g., “Condense Conversation”).
Aligning with that convention would improve visual consistency:

-			"cancelEnhancement": "Cancel enhancement",
-			"revertEnhancement": "Revert to original prompt"
+			"cancelEnhancement": "Cancel Enhancement",
+			"revertEnhancement": "Revert to Original Prompt"
webview-ui/src/i18n/locales/ca/kilocode.json (1)

61-63: Minor ordering nit – keep key order consistent

Most locale files list cancelEnhancement first, then revertEnhancement. This file reverses them.
Ordering has no runtime effect, but aligning all locale files reduces noisiness in diffs and makes bulk-edits easier.

-			"revertEnhancement": "Tornar a l'indicador original",
-			"cancelEnhancement": "Cancel·lar millora"
+			"cancelEnhancement": "Cancel·lar millora",
+			"revertEnhancement": "Tornar a l'indicador original"
.changeset/old-socks-decide.md (1)

7-9: Typo: “it's” → “its”

Possessive its should not have an apostrophe.

-Once the prompt has been enhanced, the button will become a revert button, which returns the prompt to it's original text.
+Once the prompt has been enhanced, the button will become a revert button, which returns the prompt to its original text.
webview-ui/src/i18n/locales/pt-BR/kilocode.json (1)

53-57: Optional wording tweak: use “aprimoramento”.

In Brazilian Portuguese the verb aprimorar is the usual counterpart to enhance in UI wording. “Cancelar melhoria” is understandable but a bit generic.

-      "cancelEnhancement": "Cancelar melhoria",
+      "cancelEnhancement": "Cancelar aprimoramento",
webview-ui/src/i18n/locales/id/kilocode.json (1)

53-57: Untranslated term “prompt”.

"Kembalikan ke prompt asli" keeps prompt in English while the rest of the file generally localises technical terms (“browser”, “tool” etc.). If you prefer full Bahasa, consider:

-      "revertEnhancement": "Kembalikan ke prompt asli"
+      "revertEnhancement": "Kembalikan ke perintah asli"

If “prompt” is deliberately left in English across the product, ignore this.

webview-ui/src/i18n/locales/ko/kilocode.json (1)

54-56: Key order differs from other locales – keep consistency for diff hygiene.

Other locales declare "cancelEnhancement" first, "revertEnhancement" second; the Korean file reverses them. Functional-wise it’s harmless (JSON objects are unordered) but consistent ordering eases future bulk edits.

No change required if you don’t care, just flagging.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db5f327 and a126e62.

📒 Files selected for processing (26)
  • .changeset/old-socks-decide.md (1 hunks)
  • apps/playwright-e2e/helpers/enhance-prompt-helpers.ts (1 hunks)
  • webview-ui/src/components/chat/ChatTextArea.tsx (9 hunks)
  • webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx (6 hunks)
  • webview-ui/src/i18n/locales/ar/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ca/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/cs/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/de/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/en/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/es/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/fr/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/hi/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/id/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/it/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ja/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ko/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/nl/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/pl/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/pt-BR/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/ru/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/th/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/tr/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/uk/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/vi/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/zh-CN/kilocode.json (1 hunks)
  • webview-ui/src/i18n/locales/zh-TW/kilocode.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/playwright-e2e/helpers/enhance-prompt-helpers.ts (2)
apps/playwright-e2e/helpers/webview-helpers.ts (1)
  • findWebview (12-18)
apps/playwright-e2e/tests/playwright-base-test.ts (1)
  • expect (3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: storybook-playwright-snapshot
  • GitHub Check: test-extension (windows-latest)
  • GitHub Check: test-webview (windows-latest)
🔇 Additional comments (35)
webview-ui/src/i18n/locales/hi/kilocode.json (1)

54-56: Hindi localization looks good

The new enhancePrompt keys read naturally and match the intended meaning.

webview-ui/src/i18n/locales/zh-CN/kilocode.json (1)

54-56: Chinese (Simplified) strings are accurate

Translations correctly reflect the feature’s intent and style.

webview-ui/src/i18n/locales/it/kilocode.json (1)

54-56: Italian translations OK

Wording is clear and consistent with the rest of the file.

webview-ui/src/i18n/locales/ar/kilocode.json (1)

54-56: New localisation keys look good
cancelEnhancement / revertEnhancement are added with clear, accurate Arabic translations and correct JSON structure. 👍

webview-ui/src/i18n/locales/ru/kilocode.json (1)

54-56: Translation addition LGTM
Both new keys are present, translation wording is natural, and the surrounding commas/braces are correct. No issues spotted.

webview-ui/src/i18n/locales/ja/kilocode.json (1)

54-56: Japanese strings read well
Wording matches existing style and JSON syntax is intact. Nothing further to do.

webview-ui/src/i18n/locales/pl/kilocode.json (1)

54-56: Translation keys added correctly; JSON stays valid

Keys are well-named, alphabetically placed, and keep the file syntactically sound.
No further action needed.

webview-ui/src/i18n/locales/es/kilocode.json (1)

54-56: Spanish strings added without issues

JSON structure and punctuation are intact; translations read naturally.
LGTM.

webview-ui/src/i18n/locales/vi/kilocode.json (1)

54-56: Vietnamese additions look good

Both keys are present, accents are correct, and no comma/brace problems found.

webview-ui/src/i18n/locales/uk/kilocode.json (1)

54-56: Ukrainian localisation OK

Terminology matches UI intent; JSON remains valid.

webview-ui/src/i18n/locales/fr/kilocode.json (2)

54-56: French keys added correctly

Strings are clear, apostrophes escaped by using double-quotes, and object placement is consistent.


54-56: Locale coverage verified
All kilocode.json locale files include both cancelEnhancement and revertEnhancement. No missing translations detected.

webview-ui/src/i18n/locales/cs/kilocode.json (1)

53-57: LGTM – translation reads naturally.

Both strings are idiomatic and match the intended actions. No issues spotted.

webview-ui/src/i18n/locales/nl/kilocode.json (1)

54-57: LGTM! Dutch localization strings added correctly.

The new enhancePrompt section provides appropriate Dutch translations for the cancel and revert functionality. The translations are accurate and follow the existing localization structure.

webview-ui/src/i18n/locales/th/kilocode.json (1)

54-57: LGTM! Thai localization strings added correctly.

The new enhancePrompt section provides Thai translations for the cancel and revert functionality. The JSON structure is consistent with the existing localization format.

webview-ui/src/i18n/locales/de/kilocode.json (1)

54-57: LGTM! German localization strings added correctly.

The new enhancePrompt section provides accurate German translations for the cancel and revert functionality. The translations are linguistically correct and follow the existing localization structure.

webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx (5)

45-47: Good fix! Button selector now uses stable test ID.

The change from role-based selector to data-testid="enhance-prompt-button" addresses the previous review feedback and provides a more reliable way to select the button across different states (enhance/cancel/revert).


189-214: Excellent improvement! Test now properly simulates user workflow.

The test has been made asynchronous and now correctly simulates clicking the enhance button before dispatching the enhanced prompt event. This ensures the internal state (originalPromptBeforeEnhancement) is properly set, making the test more realistic and reliable.


232-248: Good practice! Fallback test also updated with proper workflow simulation.

The fallback test consistently follows the same pattern of clicking the enhance button first, ensuring all test scenarios properly simulate the user interaction flow.


282-301: Well-designed test! Properly verifies cancellation behavior.

This test correctly simulates the cancellation workflow by clicking the enhance button twice (start then cancel) and verifies that the enhanced prompt is not applied when the enhancement was cancelled. This validates the state management logic.


303-328: Comprehensive test! Validates the complete revert workflow.

This test properly simulates the full revert scenario: enhance → receive enhanced prompt → click revert button. It correctly verifies that the original prompt is restored, ensuring the revert functionality works as expected.

webview-ui/src/components/chat/ChatTextArea.tsx (8)

40-40: LGTM!

The RotateCcw import is correctly added to support the revert button icon functionality.


158-161: LGTM!

The new state variables are properly typed and initialized to support the prompt enhancement revert functionality.


181-184: LGTM!

The enhanced message handler correctly guards against applying stale enhancements by checking originalPromptBeforeEnhancement state, and properly stores the enhanced text for revert functionality.


238-239: LGTM!

The dependency array is correctly updated to include originalPromptBeforeEnhancement since the effect callback now references this state variable.


283-297: LGTM!

The button state logic is well-structured with proper conditions for each state ("enhance", "cancel", "revert"). The use of useCallback and useMemo provides appropriate performance optimization.


306-336: LGTM!

The enhanced handleEnhancePrompt function correctly handles all three scenarios (enhance, cancel, revert) with proper state management. The cancel logic cleverly uses setOriginalPromptBeforeEnhancement(null) to ignore pending responses.


700-708: LGTM!

The dependency array is correctly updated to include all the new slash command related variables referenced in the callback.


585-621: LGTM!

The button rendering logic properly handles all three states with appropriate tooltips, aria-labels, and icons. The spin animation for the cancel state provides good user feedback. The test ID will facilitate automated testing.

apps/playwright-e2e/helpers/enhance-prompt-helpers.ts (6)

1-4: LGTM!

The imports and type definition are correct and align with the button states implemented in the ChatTextArea component.


12-17: LGTM!

The getEnhanceButton function correctly uses the webview helper pattern and locates the button by its test ID with an appropriate timeout.


19-27: LGTM!

The waitForEnhanceButtonState function is well-implemented with proper timeout handling and uses the accessible aria-label attribute for state detection.


29-40: LGTM!

The clickEnhanceButton function provides a useful abstraction that combines clicking with optional state waiting, making tests more concise and readable.


42-47: LGTM!

The verifyEnhanceButtonReady function provides comprehensive verification of the button's initial state, ensuring tests start from a consistent baseline.


6-10: ARIA-label constants match English locale translations
Verified that the hard-coded labels in apps/playwright-e2e/helpers/enhance-prompt-helpers.ts correspond exactly to the English i18n entries:

  • “Enhance prompt with additional context” ← chat.enhancePrompt in webview-ui/src/i18n/locales/en/chat.json
  • “Cancel enhancement” ← kilocode.cancelEnhancement in webview-ui/src/i18n/locales/en/kilocode.json
  • “Revert to original prompt” ← kilocode.revertToOriginal in webview-ui/src/i18n/locales/en/kilocode.json

These helpers will work as expected under the English locale. To prevent breakages if tests run in other languages, either:

  • Force Playwright to launch with en locale, or
  • Import the English JSON and derive the labels in code for consistency across locales

Comment thread webview-ui/src/components/chat/ChatTextArea.tsx Outdated
Comment thread webview-ui/src/i18n/locales/tr/kilocode.json
Comment thread webview-ui/src/i18n/locales/zh-TW/kilocode.json Outdated
Adds functionality to revert an enhanced prompt to its original state and to cancel an ongoing enhancement process.

- Introduces `originalPromptBeforeEnhancement` and `enhancedPromptText` states in `ChatTextArea` to manage prompt history.
- Updates `handleEnhancePrompt` to support "cancel" and "revert" actions based on the current prompt state.
- Changes the enhance button icon and aria-label dynamically to reflect "enhance", "cancel", or "revert" states.
- Adds new helper functions and tests for Playwright E2E to verify the new prompt enhancement states and actions.
- Includes new i18n strings for "cancel enhancement" and "revert to original prompt" across all supported languages.
Chris Hasson added 2 commits July 25, 2025 11:55
Corrected a typo in the Traditional Chinese localization file for "cancel enhancement" from "取消增强功能" to "取消增強功能".

Updated the dependency array in `ChatTextArea.tsx` to properly wrap kilocode-specific changes with `// kilocode_change start` and `// kilocode_change end` comments, ensuring better maintainability and conflict avoidance with upstream updates.
@hassoncs
hassoncs force-pushed the cancel-revert-enhancement branch from a126e62 to 4e3cbec Compare July 25, 2025 18:59
@hassoncs hassoncs closed this Oct 24, 2025
@markijbema
markijbema deleted the cancel-revert-enhancement branch February 22, 2026 14:45
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.

4 participants