Skip to content

Mirror: fix: context condensing prompt not saving properly (#5634)#33

Merged
jeremylongshore merged 1 commit intomainfrom
mirror/PR-5634
Feb 15, 2026
Merged

Mirror: fix: context condensing prompt not saving properly (#5634)#33
jeremylongshore merged 1 commit intomainfrom
mirror/PR-5634

Conversation

@jeremylongshore
Copy link
Copy Markdown
Owner

Mirror of upstream PR #5634

Verdict: APPROVE | Tier 2

Review: kilocode-5634-review.md

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 15, 2026

Warning

Rate limit exceeded

@jeremylongshore has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 26 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mirror/PR-5634

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @jeremylongshore, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the context condensing prompt was not saving correctly and experienced UI flickering during input. The solution involves implementing a local state management strategy within the PromptsSettings component. By using a local state for the condensing prompt during editing and synchronizing it with the global state on blur, the user experience is significantly improved, and the prompt's value is reliably persisted.

Highlights

  • Introduced Local State for Condensing Prompt: A new local state variable, localCondensingPrompt, was added to PromptsSettings.tsx to manage the condensing prompt's value during user input, preventing UI flickering.
  • Improved Prompt Value Retrieval Logic: The getSupportPromptValue function was updated to prioritize the new local state for the 'CONDENSE' prompt type, falling back to the extension state and then the default value.
  • Enhanced Input Handling for Condensing Prompt: The onChange event handler for the prompt textarea now updates the local state immediately for the 'CONDENSE' prompt. An onBlur event handler was added to synchronize the local state with the extension's global state when the input loses focus, ensuring the prompt saves correctly.
  • Initialized Local State on Tab Switch: A new useEffect hook was added to initialize localCondensingPrompt with the current customCondensingPrompt value whenever the active support option switches to 'CONDENSE'.
Changelog
  • .changeset/fix-condensing-prompt.md
    • Added a new changeset file to document the fix for the condensing prompt saving issue.
  • webview-ui/src/components/settings/PromptsSettings.tsx
    • Introduced a local state variable for the condensing prompt to prevent flickering.
    • Updated prompt value retrieval logic to prioritize the local state for the condensing prompt.
    • Modified input event handlers to update local state on change and synchronize with global state on blur.
    • Added an effect to initialize the local condensing prompt state when the 'CONDENSE' tab is activated.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Fix context condensing prompt flickering and save issue

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Fix context condensing prompt not saving properly
• Add local state to prevent UI flickering during editing
• Sync local state with extension state on blur event
• Initialize local condensing prompt when switching to CONDENSE tab
Diagram
flowchart LR
  A["User edits condensing prompt"] -->|"Update local state immediately"| B["Local state updated"]
  B -->|"Prevent flickering"| C["UI reflects changes"]
  C -->|"On blur event"| D["Sync with extension state"]
  D -->|"Save to storage"| E["Prompt persisted"]
Loading

Grey Divider

File Changes

1. .changeset/fix-condensing-prompt.md 📝 Documentation +5/-0

Add changeset for condensing prompt fix

• Add changeset entry documenting the patch fix
• Mark as patch version bump for kilo-code package

.changeset/fix-condensing-prompt.md


2. webview-ui/src/components/settings/PromptsSettings.tsx 🐞 Bug fix +26/-2

Implement local state for condensing prompt editing

• Add localCondensingPrompt state to track prompt value during editing
• Add useEffect hook to initialize local state when switching to CONDENSE tab
• Update getSupportPromptValue to use local state as primary source
• Add onInput handler to update local state immediately for CONDENSE prompts
• Add onBlur handler to sync local state with extension state on blur

webview-ui/src/components/settings/PromptsSettings.tsx


Grey Divider

Qodo Logo

@jeremylongshore jeremylongshore merged commit 0b4e525 into main Feb 15, 2026
11 of 14 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix an issue where the context condensing prompt was not saving properly, causing flickering during typing. It introduces a local state to manage the prompt's value during editing. While the overall approach is sound, the implementation of the onInput event handler is flawed as it continues to update the global state on every keystroke, which negates the benefit of the local state. I've provided a critical review comment with a code suggestion to correct this logic.

@qodo-code-review
Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. No tests for CONDENSE prompt 📘 Rule violation ⛯ Reliability
Description
The PR changes PromptsSettings behavior for the CONDENSE prompt (local state + blur sync) but
does not add/update any Vitest coverage for this user-facing fix. This risks regressions in prompt
editing/saving behavior going forward.
Code

webview-ui/src/components/settings/PromptsSettings.tsx[R199-214]

+							// For CONDENSE, update local state immediately to prevent flickering
+							if (activeSupportOption === "CONDENSE") {
+								setLocalCondensingPrompt(value)
+							}
							updateSupportPrompt(activeSupportOption, value)
						}}
+						onBlur={(e) => {
+							// For CONDENSE, sync with extension state on blur
+							if (activeSupportOption === "CONDENSE") {
+								const value =
+									(e as unknown as CustomEvent)?.detail?.target?.value ??
+									((e as any).target as HTMLTextAreaElement).value
+								setLocalCondensingPrompt(undefined)
+								updateSupportPrompt(activeSupportOption, value)
+							}
+						}}
Evidence
PR Compliance ID 9 requires relevant code changes to add or update Vitest tests. This PR introduces
new CONDENSE-specific editing/sync logic in PromptsSettings and is shipped as a patch-level
user-facing fix (changeset), but no corresponding test changes are present in the PR diff.

AGENTS.md
webview-ui/src/components/settings/PromptsSettings.tsx[199-214]
.changeset/fix-condensing-prompt.md[1-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PromptsSettings` now has new `CONDENSE`-specific local state and `onBlur` sync behavior, but the PR does not include any Vitest tests to validate the updated prompt editing/saving flow.

## Issue Context
This change is a user-facing patch (changeset added) and affects how prompt values are displayed/updated while typing and when focus leaves the textarea.

## Fix Focus Areas
- webview-ui/src/components/settings/PromptsSettings.tsx[75-214]
- .changeset/fix-condensing-prompt.md[1-5] પહેલાં

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Local prompt resync race 🐞 Bug ⛯ Reliability
Description
The new effect re-initializes localCondensingPrompt whenever customCondensingPrompt changes while
the CONDENSE tab is active, which can cause extra rerenders/cursor jumps and can overwrite the
buffered text during extension state broadcasts—undermining the stated goal of preventing flicker
while typing.
Code

webview-ui/src/components/settings/PromptsSettings.tsx[R75-80]

+	// Initialize local condensing prompt when switching to CONDENSE tab
+	useEffect(() => {
+		if (activeSupportOption === "CONDENSE") {
+			setLocalCondensingPrompt(customCondensingPrompt)
+		}
+	}, [activeSupportOption, customCondensingPrompt])
Evidence
PromptsSettings sets localCondensingPrompt from customCondensingPrompt on every change while
CONDENSE is active. But CONDENSE edits post messages to the extension, and the extension persists
and immediately broadcasts updated state back to the webview. The webview then replaces state from
these broadcasts. This means customCondensingPrompt can change frequently during typing, repeatedly
triggering the effect and re-setting localCondensingPrompt—reintroducing the flicker/cursor-reset
behavior this PR is trying to avoid, and potentially overwriting the buffered local value if the
broadcasted value is stale/lagging.

webview-ui/src/components/settings/PromptsSettings.tsx[75-80]
webview-ui/src/components/settings/PromptsSettings.tsx[192-204]
src/core/webview/webviewMessageHandler.ts[2020-2029]
webview-ui/src/context/ExtensionStateContext.tsx[412-419]
webview-ui/src/context/ExtensionStateContext.tsx[229-246]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`localCondensingPrompt` is intended to prevent flicker while typing in the CONDENSE prompt textarea, but the current sync `useEffect` runs whenever `customCondensingPrompt` changes and can repeatedly reset the local buffer during extension state broadcasts.

### Issue Context
The extension broadcasts state after `updateCondensingPrompt` (`provider.postStateToWebview()`), and the webview applies those updates to context. When typing quickly, this can cause frequent `customCondensingPrompt` changes and trigger the sync effect repeatedly.

### Fix Focus Areas
- webview-ui/src/components/settings/PromptsSettings.tsx[75-80]
- webview-ui/src/components/settings/PromptsSettings.tsx[192-214]

### Suggested approach
- Change the sync effect to run only when switching into the CONDENSE tab (dependency on `activeSupportOption` only), OR
- Guard syncing with `if (activeSupportOption === &quot;CONDENSE&quot; &amp;&amp; localCondensingPrompt === undefined) setLocalCondensingPrompt(customCondensingPrompt)` to avoid overwriting during active edits, potentially using an `isEditing` ref toggled by `onFocus`/`onBlur`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@jeremylongshore jeremylongshore deleted the mirror/PR-5634 branch February 15, 2026 03:12
@jeremylongshore
Copy link
Copy Markdown
Owner Author

Review Summary

Aspect Assessment
Verdict APPROVE
Confidence 4/5
Blocking Issues 0
Suggestions 1 (minor)

Checklist

  • Changeset included
  • Addresses input flickering during typing
  • Clean local state pattern

Analysis

The fix uses a standard React pattern for controlled inputs that sync with external state:

  1. localCondensingPrompt — immediate local state during editing
  2. onBlur — syncs local state back to extension state
  3. useEffect — initializes local state when switching to CONDENSE tab

This prevents the "flickering" problem where typing triggers a round-trip to extension state, which updates the textarea, resetting cursor position.

The pattern is applied only to the CONDENSE prompt type (not ENHANCE), which suggests the issue is specific to how condensing prompt state is managed upstream.

Suggestion

The onBlur handler duplicates the value extraction logic from onChange. Consider extracting to a shared helper:

const extractValue = (e: any) =>
  (e as unknown as CustomEvent)?.detail?.target?.value ??
  ((e as any).target as HTMLTextAreaElement).value

Minor — not blocking.

Recommendation

APPROVE — Correct fix for a common React controlled input issue. Merge.


@jeremylongshore
Copy link
Copy Markdown
Owner Author

Review Journal: kilocode Kilo-Org#5634

PR: #5634 |
Author: @Patel230 | Size: 33 lines, 2 files | Confidence: 4/5

Summary

Fixes textarea flickering when editing the condensing prompt by introducing a local state pattern. Before: typing triggered a round-trip through extension state, causing cursor reset. After: local state handles immediate input, syncs on blur. APPROVE — standard React controlled input fix with changeset.

What Changed

Added localCondensingPrompt state that:

  1. Initializes from extension state when switching to the CONDENSE tab
  2. Updates immediately on keystroke (local, no round-trip)
  3. Syncs back to extension state on onBlur

This is a textbook React pattern for controlled inputs that need to sync with external state (VS Code extension host in this case).

Analysis

The pattern is applied only to the CONDENSE prompt, not the ENHANCE prompt. This suggests the flickering issue is specific to how condensing prompt state flows through the extension host. The onBlur handler duplicates some value extraction logic from onChange — minor, could be refactored into a shared helper, but not worth blocking on.

VS Code's web component wrappers (<vscode-text-area>) fire events differently from native HTML elements, requiring the CustomEvent?.detail?.target?.value fallback chain. This is the same pattern seen in PR Kilo-Org#5826.

Lessons Learned

  • Local state prevents controlled input flickering when the source of truth has round-trip latency (e.g., VS Code extension host)
  • VS Code web components cause controlled input issues that native HTML elements don't

Review #13 of 75 | Methodology

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