Skip to content

feat(command-palette): add a toggle editor word wrap command (closes #1036) - #1076

Merged
debba merged 2 commits into
TabularisDB:mainfrom
Furox-Art:feat/word-wrap-command
Oct 14, 2026
Merged

debba merged 2 commits into
TabularisDB:mainfrom
Furox-Art:feat/word-wrap-command

Conversation

@Furox-Art

Copy link
Copy Markdown
Contributor

Closes #1036

What

A Toggle word wrap command in the command palette that flips the existing editorWordWrap preference — the change applies to every SQL editor immediately and persists like the Settings → Appearance toggle. The label reflects the current state ("Disable word wrap" when on, "Enable word wrap" when off), with wrap, line, editor keywords.

Where

  • src/utils/builtInCommands.ts — the command item lives next to connection.new-console in the editor group. The factory takes an optional editorActions argument ({ wordWrapEnabled, toggleWordWrap }) so the pure command builder stays testable.
  • src/hooks/useCommandPaletteActionItems.ts — reads the settings context and wires the toggle through updateSetting("editorWordWrap", …), same as AppearanceTab.tsx. The context is read via useContext so the palette still renders outside a SettingsProvider (the app always provides one).
  • i18n — commandPalette.commands.toggleWordWrapEnable/toggleWordWrapDisable added to all 11 locales (en, de, es, fr, it, ja, ko, pt-BR, ru, tl, zh).

Acceptance criteria

  • Running the command toggles wrapping in open editors without a reload and the value persists (it goes through the same updateSetting path as the Appearance toggle, which open editors read via context)
  • Settings → Appearance shows the new value (unchanged toggle reads the same preference)
  • Test in tests/utils/builtInCommands.test.ts — 4 new cases: command presence + keywords, state-dependent label in both directions, action execution, and absence when editor actions are not provided. The palette provider test's command-list expectation includes the new command.

Checks

  • pnpm typecheck — clean
  • pnpm lint — eslint + theme token check clean
  • pnpm test — 5859 passed; the single failure (tests/themes/compatibilityBaseline.test.ts) is pre-existing on main and unrelated (verified by re-running it on a clean checkout)

Disclosure: authored by @Furox-Art (AI-assisted). Happy to adjust anything.

The command palette gains an `editor.toggle-word-wrap` command that flips
the existing `editorWordWrap` preference, so wrapping applies to every SQL
editor immediately and persists like the Settings -> Appearance toggle.

- `src/utils/builtInCommands.ts`: new command item (label reflects the
  current state: "Enable word wrap" / "Disable word wrap", keywords
  `wrap`, `line`, `editor`). The built-in factory takes an optional
  `editorActions` argument (`wordWrapEnabled` + `toggleWordWrap`) that the
  hook supplies from live settings.
- `src/hooks/useCommandPaletteActionItems.ts`: reads the settings context
  (directly via `useContext`, so the palette still renders outside a
  provider) and wires the toggle through `updateSetting("editorWordWrap", ...)`.
- i18n: `commandPalette.commands.toggleWordWrapEnable/toggleWordWrapDisable`
  added to all 11 locales.
- Tests: 4 new cases in `tests/utils/builtInCommands.test.ts` (presence,
  state-dependent label, action execution, absent without editor actions);
  the built-in command list expectation in
  `tests/contexts/CommandPaletteProvider.test.tsx` includes the new command.

Closes #1036
const wordWrapEnabled = settingsContext?.settings.editorWordWrap ?? true;
const toggleWordWrap = useCallback(() => {
if (!settingsContext) return;
settingsContext.updateSetting("editorWordWrap", !wordWrapEnabled);

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.

SUGGESTION: Toggle writes a captured snapshot instead of the functional updater

updateSetting explicitly supports an updater form for read-then-write correctness (see the overload docs in src/contexts/SettingsContext.ts), and a toggle is a read-then-write: toggleWordWrap captures wordWrapEnabled in its closure, so two executions before a re-render (or any stale closure) write back the stale value. The updater form is race-safe and drops the captured-snapshot dependency:

Suggested change
settingsContext.updateSetting("editorWordWrap", !wordWrapEnabled);
settingsContext.updateSetting("editorWordWrap", (prev) => !(prev ?? true));

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/i18n/locales/fr.json Outdated
"openConnections": "Ouvrir le gestionnaire de connexions",
"openTableInConsole": "Ouvrir la table actuelle dans la console SQL"
"openTableInConsole": "Ouvrir la table actuelle dans la console SQL",
"toggleWordWrapEnable": "Activer le retour a la ligne",

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.

SUGGESTION: Missing accent — "retour a la ligne" should be "retour à la ligne"

The same file already uses the accented form for this feature ("Retour à la ligne automatique", fr.json:601); correct French requires "à".

Suggested change
"toggleWordWrapEnable": "Activer le retour a la ligne",
"toggleWordWrapEnable": "Activer le retour à la ligne",

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/i18n/locales/fr.json Outdated
"openTableInConsole": "Ouvrir la table actuelle dans la console SQL"
"openTableInConsole": "Ouvrir la table actuelle dans la console SQL",
"toggleWordWrapEnable": "Activer le retour a la ligne",
"toggleWordWrapDisable": "Desactiver le retour a la ligne"

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.

SUGGESTION: Missing accents — "Desactiver le retour a la ligne" should be "Désactiver le retour à la ligne"

Matches the established term "Retour à la ligne automatique" (fr.json:601).

Suggested change
"toggleWordWrapDisable": "Desactiver le retour a la ligne"
"toggleWordWrapDisable": "Désactiver le retour à la ligne"

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/i18n/locales/es.json Outdated
"openConnections": "Abrir gestor de conexiones",
"openTableInConsole": "Abrir la tabla actual en la consola SQL"
"openTableInConsole": "Abrir la tabla actual en la consola SQL",
"toggleWordWrapEnable": "Activar ajuste de linea",

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.

SUGGESTION: Missing accent — "linea" should be "línea"

The same file's word-wrap setting is "Ajuste de Línea" (es.json:596); Spanish requires the accent on "línea".

Suggested change
"toggleWordWrapEnable": "Activar ajuste de linea",
"toggleWordWrapEnable": "Activar ajuste de línea",

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/i18n/locales/es.json Outdated
"openTableInConsole": "Abrir la tabla actual en la consola SQL"
"openTableInConsole": "Abrir la tabla actual en la consola SQL",
"toggleWordWrapEnable": "Activar ajuste de linea",
"toggleWordWrapDisable": "Desactivar ajuste de linea"

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.

SUGGESTION: Missing accent — "linea" should be "línea"

Matches the established term "Ajuste de Línea" (es.json:596).

Suggested change
"toggleWordWrapDisable": "Desactivar ajuste de linea"
"toggleWordWrapDisable": "Desactivar ajuste de línea"

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/i18n/locales/ko.json Outdated
"openTableInConsole": "현재 테이블을 SQL 콘솔에서 열기"
"openTableInConsole": "현재 테이블을 SQL 콘솔에서 열기",
"toggleWordWrapEnable": "줄 바꿈 활성화",
"toggleWordWrapDisable": "줄 비활성화"

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.

SUGGESTION: Disable label drops "바꿈" (wrap) — inconsistent with the enable label

"줄 비활성화" reads as "disable line"; the enable label is "줄 바꿈 활성화" and the established term is "자동 줄바꿈" (ko.json:546). Use the parallel form:

Suggested change
"toggleWordWrapDisable": "줄 비활성화"
"toggleWordWrapDisable": "줄 바꿈 비활성화"

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • src/hooks/useCommandPaletteActionItems.ts
  • src/i18n/locales/es.json
  • src/i18n/locales/fr.json
  • src/i18n/locales/ko.json
Previous Review Summary (commit 8fa1474)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8fa1474)

Status: 6 Issues Found | Recommendation: Address suggestions before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 6
Issue Details (click to expand)

SUGGESTION

File Line Issue
src/hooks/useCommandPaletteActionItems.ts 22 Toggle writes a captured wordWrapEnabled snapshot instead of the functional updateSetting updater; a stale closure can write back the old value
src/i18n/locales/fr.json 2393 Missing accent: "Activer le retour a la ligne" → "Activer le retour à la ligne"
src/i18n/locales/fr.json 2394 Missing accents: "Desactiver le retour a la ligne" → "Désactiver le retour à la ligne"
src/i18n/locales/es.json 2248 Missing accent: "Activar ajuste de linea" → "Activar ajuste de línea"
src/i18n/locales/es.json 2249 Missing accent: "Desactivar ajuste de linea" → "Desactivar ajuste de línea"
src/i18n/locales/ko.json 2318 Disable label "줄 비활성화" drops "바꿈" (wrap); should be "줄 바꿈 비활성화" to match the enable label
Files Reviewed (15 files)
  • src/hooks/useCommandPaletteActionItems.ts - 1 issue
  • src/utils/builtInCommands.ts - no issues
  • src/i18n/locales/de.json - no issues
  • src/i18n/locales/en.json - no issues
  • src/i18n/locales/es.json - 2 issues
  • src/i18n/locales/fr.json - 2 issues
  • src/i18n/locales/it.json - no issues
  • src/i18n/locales/ja.json - no issues
  • src/i18n/locales/ko.json - 1 issue
  • src/i18n/locales/pt-BR.json - no issues
  • src/i18n/locales/ru.json - no issues
  • src/i18n/locales/tl.json - no issues
  • src/i18n/locales/zh.json - no issues
  • tests/contexts/CommandPaletteProvider.test.tsx - no issues
  • tests/utils/builtInCommands.test.ts - no issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 91.8K · Output: 1.7K · Cached: 99.4K

…p toggle

- Hook: use the functional `updateSetting` updater instead of a captured
  snapshot, so a toggle fired while another write is in flight cannot
  overwrite it with a stale value.
- fr: restore accents in "retour à la ligne" (both labels).
- es: restore the accent in "ajuste de línea" (both labels).
- ko: "줄 바꿈 비활성화" to match the enable label's "줄 바꿈 활성화".

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @Furox-Art, thanks a lot for picking up #1036! Using the functional updater in updateSetting("editorWordWrap", (prev) => !(prev ?? true)) is the right call to avoid a stale value, and the comment explaining why will save the next person some head scratching. Nice job keeping createBuiltInCommandItems testable by injecting editorActions, and on writing real translations for all 11 locales.

Since this is your first PR here: welcome! If you feel like hanging out with us, you're very welcome on our Discord: https://discord.com/invite/K2hmhfHRSt

I'm approving this. A few small things you can pick up as a follow-up, none of them blocking:

  1. In useCommandPaletteActionItems.ts the editorActions object is always passed, even when there's no SettingsProvider. In that case the command still shows up but toggleWordWrap does nothing. Passing editorActions only when settingsContext is available would be a bit cleaner (in the app the provider is always there, so this only shows up in isolated tests).
  2. SettingsProvider builds a new value object on every render, so with [settingsContext] as dependency the items useMemo recomputes on any settings change. The cost is negligible, just worth knowing.
  3. The command is listed even when no editor is open. That's fine for a global preference, just mentioning it in case you'd rather scope it.

I'll still do a manual check on my side before merging.

@debba
debba merged commit 941f8bd into TabularisDB:main Oct 14, 2026
5 checks passed
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.

[Feat]: Command palette: toggle editor word wrap

2 participants