Skip to content

Fix hideCtrlGToEdit patch#361

Merged
bl-ue merged 5 commits intomainfrom
fix-hidectrlgtoedit-patch
Jan 12, 2026
Merged

Fix hideCtrlGToEdit patch#361
bl-ue merged 5 commits intomainfrom
fix-hidectrlgtoedit-patch

Conversation

@basekevin
Copy link
Member

@basekevin basekevin commented Jan 11, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Ctrl‑G to Edit prompt now respects the renamed setting and behaves correctly.
  • Chores

    • Renamed configuration flag and added automatic migration for existing configs.
    • Updated patch tooling and UI setting references to use the new flag name.
  • Documentation

    • Added an Unreleased changelog entry describing the fix.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 11, 2026

📝 Walkthrough

Walkthrough

Renamed config key hideCtrlGToEditPrompthideCtrlGToEdit; added a migration to move the old key during config load; replaced the old patch module with a new implementation and updated types, defaults, patch index, and UI references; removed the deleted patch file and added a changelog entry.

Changes

Cohort / File(s) Summary
Types & Defaults
src/types.ts, src/defaultSettings.ts
Renamed misc property hideCtrlGToEditPrompthideCtrlGToEdit in MiscConfig and DEFAULT_SETTINGS.
Config
src/config.ts
Imported and invoked migrateHideCtrlGToEditPrompt(readConfig) inside readConfigFile() alongside existing migrations.
Migration
src/migration.ts
Added exported migrateHideCtrlGToEditPrompt(readConfig: TweakccConfig) to move misc.hideCtrlGToEditPromptmisc.hideCtrlGToEdit and delete the old key.
Patch Implementation
src/patches/hideCtrlGToEdit.ts
New patch `writeHideCtrlGToEdit(oldFile: string): string
Patch Removal
src/patches/hideCtrlGToEditPrompt.ts
Deleted previous writeHideCtrlGToEditPrompt module and its helper.
Patch Integration
src/patches/index.ts
Updated imports and feature gate to use writeHideCtrlGToEdit and config.settings.misc?.hideCtrlGToEdit.
UI
src/ui/components/MiscView.tsx
Updated default, getter, and toggle logic to reference hideCtrlGToEdit instead of hideCtrlGToEditPrompt.
Misc / Docs / Style
CHANGELOG.md, src/patches/toolsets.ts
Added changelog entry; removed an extraneous blank line in toolsets.ts.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through keys and nudged a flag,
Old prompt tucked in a tidy bag.
A patch reborn, a migration neat,
I nibble code and dance on feet.
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: renaming and fixing the hideCtrlGToEdit patch implementation across the codebase through configuration updates, migration logic, and UI changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f0e18b and a3affb0.

📒 Files selected for processing (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/ui/components/MiscView.tsx (1)

37-41: ensureMisc() mutates the wrong object via stale closure—mutations are lost.

ensureMisc() reads/writes the outer settings (lines 38-40) but is called inside updateSettings(settings => { ... }). Since updateSettings creates a deep copy and only preserves mutations to the parameter, mutations to the outer scope closure are discarded. This means ensureMisc() has no effect.

Proposed refactor (pass draft parameter instead of using closure)
-  const ensureMisc = () => {
-    if (!settings.misc) {
-      settings.misc = { ...defaultMisc };
-    }
-  };
+  const ensureMisc = (draft: typeof settings) => {
+    if (!draft.misc) {
+      draft.misc = { ...defaultMisc };
+    }
+  };

   // ... in toggle functions:
-        toggle: () => {
-          updateSettings(settings => {
-            ensureMisc();
-            settings.misc!.hideCtrlGToEdit = !settings.misc!.hideCtrlGToEdit;
-          });
-        },
+        toggle: () => {
+          updateSettings(draft => {
+            ensureMisc(draft);
+            draft.misc!.hideCtrlGToEdit = !draft.misc!.hideCtrlGToEdit;
+          });
+        },

Also applies to: 67-72, 80-86, 94-100, 108-114, 123-128, 136-141, 148-154, 161-167, 175-181

🧹 Nitpick comments (2)
src/patches/hideCtrlGToEdit.ts (1)

8-9: Consider pattern flexibility for potential future Claude Code format changes.

The regex pattern is intentionally specific to match the minified bundle format (if(X&&Y)p("tengu_external_editor_hint_shown",), as documented in the code comment. This specificity helps avoid false positives but creates fragility if Claude Code's bundler output changes (e.g., added whitespace, additional operands, or different operators). If the bundle format evolves, this pattern will silently fail to match. An optional refactor would be to make the pattern more flexible (e.g., /if\(\s*([$\w\s&|]+)\s*\)p\("tengu_external_editor_hint_shown",/) if and when such changes occur.

src/ui/components/MiscView.tsx (1)

25-35: Avoid duplicated defaults drift in defaultMisc.

Now that defaultMisc is being updated (Line 31), consider sourcing it from a single canonical place (e.g., DEFAULT_SETTINGS.misc) to prevent the UI’s “initialization defaults” from diverging from actual config defaults.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92a2362 and b2b45ab.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • src/config.ts
  • src/defaultSettings.ts
  • src/migration.ts
  • src/patches/hideCtrlGToEdit.ts
  • src/patches/hideCtrlGToEditPrompt.ts
  • src/patches/index.ts
  • src/patches/toolsets.ts
  • src/types.ts
  • src/ui/components/MiscView.tsx
💤 Files with no reviewable changes (2)
  • src/patches/toolsets.ts
  • src/patches/hideCtrlGToEditPrompt.ts
🧰 Additional context used
🧬 Code graph analysis (4)
src/migration.ts (1)
src/types.ts (1)
  • TweakccConfig (143-151)
src/config.ts (1)
src/migration.ts (1)
  • migrateHideCtrlGToEditPrompt (93-99)
src/patches/index.ts (1)
src/patches/hideCtrlGToEdit.ts (1)
  • writeHideCtrlGToEdit (31-46)
src/patches/hideCtrlGToEdit.ts (1)
src/patches/index.ts (2)
  • LocationResult (71-75)
  • showDiff (89-127)
🔇 Additional comments (7)
src/patches/hideCtrlGToEdit.ts (1)

31-46: LGTM! Clean patch implementation.

The function correctly:

  • Returns null on pattern match failure
  • Replaces the condition with false to disable the Ctrl+G hint
  • Calls showDiff for verbose debugging output
  • Preserves surrounding code structure
src/types.ts (1)

113-113: LGTM! Clean property rename.

The property rename from hideCtrlGToEditPrompt to hideCtrlGToEdit is straightforward and consistent with the PR objectives.

src/migration.ts (1)

89-99: LGTM! Correct migration implementation.

The migration function properly:

  • Checks for the old property's existence before migrating
  • Copies the value to the new property name
  • Removes the old property to avoid confusion
  • Is idempotent (safe to run multiple times)
  • Follows the same pattern as existing migrations in the file
src/config.ts (2)

11-14: LGTM! Correct import addition.

The migration function is properly imported alongside the existing userMessageDisplay migration.


251-252: LGTM! Proper migration integration.

The migration is correctly positioned in the config read flow and will run automatically to update existing configurations with the renamed property.

src/patches/index.ts (1)

60-62: Rename wiring for ctrl-g patch is consistent.

Import + gate + writer call all use hideCtrlGToEdit / writeHideCtrlGToEdit.

Please confirm the config migration runs before applyCustomization(...) is invoked (so old configs still enable the patch). A quick pointer would be where src/migration.ts is called in the config load flow.

Also applies to: 666-669

src/defaultSettings.ts (1)

747-757: Default rename is correct and fully integrated.

DEFAULT_SETTINGS.misc.hideCtrlGToEdit (Line 753) aligns with the new config key. The old key hideCtrlGToEditPrompt exists only in migration code for backward compatibility, confirming the rename is complete. The new key is properly defined in types, used in the UI, and integrated into the patch system.

basekevin and others added 2 commits January 10, 2026 18:40
Co-authored-by: bl-ue <54780737+bl-ue@users.noreply.github.com>
@bl-ue bl-ue merged commit d618555 into main Jan 12, 2026
2 checks passed
@bl-ue bl-ue deleted the fix-hidectrlgtoedit-patch branch January 12, 2026 15:50
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