Skip to content

Comments

Add option to append trailing space after pasted text#5

Closed
dannysmith wants to merge 1 commit intomainfrom
add-space-at-end
Closed

Add option to append trailing space after pasted text#5
dannysmith wants to merge 1 commit intomainfrom
add-space-at-end

Conversation

@dannysmith
Copy link
Owner

@dannysmith dannysmith commented Dec 4, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new setting to optionally append a trailing space when pasting text. Users can enable or disable this formatting option in the application settings to automatically add spacing after paste operations.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

A new feature adds an optional trailing space to pasted text. Changes include a new append_trailing_space boolean setting in the app configuration, conditional text transformation logic in the paste method, a Tauri command to toggle the setting, a React UI component for the toggle, TypeScript bindings, and settings store integration.

Changes

Cohort / File(s) Change Summary
Backend Settings Configuration
src-tauri/src/settings.rs, src-tauri/src/lib.rs
Added append_trailing_space: bool field to AppSettings struct with serde default, and exported the new setting command via run().
Backend Clipboard & Shortcut Logic
src-tauri/src/clipboard.rs, src-tauri/src/shortcut.rs
Implemented conditional trailing space appending in paste logic before execution; added new Tauri command change_append_trailing_space_setting to persist setting changes (duplicate function definition present).
Frontend TypeScript Bindings
src/bindings.ts
Extended AppSettings type with optional append_trailing_space field and added changeAppendTrailingSpaceSetting(enabled: boolean) command method.
Frontend UI Components
src/components/settings/AppendTrailingSpace.tsx, src/components/settings/debug/DebugSettings.tsx
Created new memoized AppendTrailingSpace React component with toggle functionality; integrated component into debug settings group.
Frontend State Management
src/stores/settingsStore.ts
Extended settings updater map with append_trailing_space entry invoking the new backend command.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Critical attention required: Duplicate function definition in src-tauri/src/shortcut.rs will cause compile-time error; remove one instance of change_append_trailing_space_setting.
  • Verify setting persistence: Ensure clipboard.rs correctly reads the setting value before applying transformation.
  • Component integration: Confirm AppendTrailingSpace component correctly syncs with settings store and backend command.
  • Type consistency: Cross-check append_trailing_space field naming across Rust, TypeScript bindings, and React components.

Poem

🐰 A trailing space, so crisp and bright,
Now pasted text takes final flight,
With toggles set and logic neat,
The clipboard's made completely sweet! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add option to append trailing space after pasted text' directly and clearly describes the main change: introducing a new feature/setting to append trailing spaces to pasted text, which is comprehensively implemented across backend, settings, and UI components.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-space-at-end

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.

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 244a99e and 390173d.

📒 Files selected for processing (8)
  • src-tauri/src/clipboard.rs (1 hunks)
  • src-tauri/src/lib.rs (1 hunks)
  • src-tauri/src/settings.rs (2 hunks)
  • src-tauri/src/shortcut.rs (1 hunks)
  • src/bindings.ts (2 hunks)
  • src/components/settings/AppendTrailingSpace.tsx (1 hunks)
  • src/components/settings/debug/DebugSettings.tsx (2 hunks)
  • src/stores/settingsStore.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
src-tauri/src/lib.rs (1)
src-tauri/src/shortcut.rs (1)
  • change_append_trailing_space_setting (698-704)
src/components/settings/debug/DebugSettings.tsx (1)
src/components/settings/AppendTrailingSpace.tsx (1)
  • AppendTrailingSpace (10-27)
src/stores/settingsStore.ts (1)
src/bindings.ts (1)
  • commands (7-601)
src/components/settings/AppendTrailingSpace.tsx (1)
src/hooks/useSettings.ts (1)
  • useSettings (46-78)
src-tauri/src/shortcut.rs (1)
src-tauri/src/settings.rs (2)
  • get_settings (562-578)
  • write_settings (580-586)
🔇 Additional comments (9)
src-tauri/src/lib.rs (1)

256-256: LGTM!

The new command change_append_trailing_space_setting is correctly added to the command collection, following the established pattern for other settings commands.

src/components/settings/debug/DebugSettings.tsx (1)

12-12: LGTM!

The AppendTrailingSpace component is correctly imported and rendered with consistent props (descriptionMode="tooltip" and grouped={true}), matching the pattern of other settings in the Debug group.

Also applies to: 44-44

src/bindings.ts (2)

247-254: LGTM!

The auto-generated binding for changeAppendTrailingSpaceSetting follows the established pattern for boolean setting commands.


613-613: LGTM!

The AppSettings type correctly includes the new append_trailing_space?: boolean field, consistent with the Rust-side definition.

src-tauri/src/settings.rs (2)

288-289: LGTM!

The new append_trailing_space field is correctly added with #[serde(default)] annotation, following the same pattern as mute_while_recording. This ensures backward compatibility when deserialising existing settings that lack this field.


488-488: LGTM!

The default value of false is consistent with the #[serde(default)] behaviour for booleans.

src-tauri/src/clipboard.rs (1)

237-242: LGTM!

The conditional trailing space transformation is correctly implemented before the paste operation. The logic applies consistently across all paste methods.

Note: If the transcribed text already ends with a space, this will result in a double space. This is likely acceptable since it's a user-configurable convenience feature, but worth being aware of.

src/stores/settingsStore.ts (1)

124-125: LGTM!

The settings updater for append_trailing_space is correctly wired to call the backend command, following the established pattern for boolean settings.

src-tauri/src/shortcut.rs (1)

696-704: LGTM!

The change_append_trailing_space_setting command follows the established pattern for boolean settings commands, correctly reading, updating, and persisting the setting.

Comment on lines +1 to +27
import React from "react";
import { ToggleSwitch } from "../ui/ToggleSwitch";
import { useSettings } from "../../hooks/useSettings";

interface AppendTrailingSpaceProps {
descriptionMode?: "inline" | "tooltip";
grouped?: boolean;
}

export const AppendTrailingSpace: React.FC<AppendTrailingSpaceProps> =
React.memo(({ descriptionMode = "tooltip", grouped = false }) => {
const { getSetting, updateSetting, isUpdating } = useSettings();

const enabled = getSetting("append_trailing_space") ?? false;

return (
<ToggleSwitch
checked={enabled}
onChange={(enabled) => updateSetting("append_trailing_space", enabled)}
isUpdating={isUpdating("append_trailing_space")}
label="Append Trailing Space"
description="Automatically add a space at the end of transcribed text, making it easier to dictate multiple sentences in a row."
descriptionMode={descriptionMode}
grouped={grouped}
/>
);
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check the broader context of this setting and PR
# Look for append_trailing_space usage elsewhere in the codebase
rg "append_trailing_space" --type ts --type tsx -B 2 -A 2

Repository: dannysmith/Handy

Length of output: 87


🏁 Script executed:

# Check if there's a PR description or README that clarifies the behavior
git log --oneline -20

Repository: dannysmith/Handy

Length of output: 121


🏁 Script executed:

# Look for related documentation or comments about pasted vs transcribed text
rg "pasted|transcribed" --type ts --type tsx --type md -B 2 -A 2

Repository: dannysmith/Handy

Length of output: 87


🏁 Script executed:

# Examine the useSettings hook to understand the setting's purpose
fd "useSettings" --type ts --type tsx | head -5

Repository: dannysmith/Handy

Length of output: 229


🏁 Script executed:

# Check the ToggleSwitch component to see standard parameter naming patterns
fd "ToggleSwitch" --type ts --type tsx | head -5

Repository: dannysmith/Handy

Length of output: 229


🏁 Script executed:

# Search for append_trailing_space usage
rg "append_trailing_space" -B 2 -A 2

Repository: dannysmith/Handy

Length of output: 4938


🏁 Script executed:

# Look for related context about pasted or transcribed text
rg "pasted|transcribed" -B 2 -A 2

Repository: dannysmith/Handy

Length of output: 3502


🏁 Script executed:

# Find and examine useSettings hook
fd "useSettings"

Repository: dannysmith/Handy

Length of output: 84


🏁 Script executed:

# Find and examine ToggleSwitch component
fd "ToggleSwitch"

Repository: dannysmith/Handy

Length of output: 94


🏁 Script executed:

# Quick check of the ToggleSwitch component to see parameter naming patterns
head -50 src/components/ui/ToggleSwitch.tsx

Repository: dannysmith/Handy

Length of output: 1856


🏁 Script executed:

# Verify the useSettings hook implementation
head -50 src/hooks/useSettings.ts

Repository: dannysmith/Handy

Length of output: 1637


Fix description to match actual behavior

The description says "transcribed text" but the setting actually controls spacing during paste. The backend applies the trailing space when pasting to the clipboard (see src-tauri/src/clipboard.rs), not during transcription. Update the description to say "pasted text" instead of "transcribed text" for accuracy.

Avoid shadowing enabled in the onChange handler

The enabled variable from getSetting and the enabled parameter in the onChange callback share the same name, which reduces readability. Rename the callback parameter:

-      <ToggleSwitch
-        checked={enabled}
-        onChange={(enabled) => updateSetting("append_trailing_space", enabled)}
+      <ToggleSwitch
+        checked={enabled}
+        onChange={(nextEnabled) =>
+          updateSetting("append_trailing_space", nextEnabled)
+        }
         isUpdating={isUpdating("append_trailing_space")}
         label="Append Trailing Space"
         description="Automatically add a space at the end of pasted text, making it easier to dictate multiple sentences in a row."
         descriptionMode={descriptionMode}
         grouped={grouped}
       />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import React from "react";
import { ToggleSwitch } from "../ui/ToggleSwitch";
import { useSettings } from "../../hooks/useSettings";
interface AppendTrailingSpaceProps {
descriptionMode?: "inline" | "tooltip";
grouped?: boolean;
}
export const AppendTrailingSpace: React.FC<AppendTrailingSpaceProps> =
React.memo(({ descriptionMode = "tooltip", grouped = false }) => {
const { getSetting, updateSetting, isUpdating } = useSettings();
const enabled = getSetting("append_trailing_space") ?? false;
return (
<ToggleSwitch
checked={enabled}
onChange={(enabled) => updateSetting("append_trailing_space", enabled)}
isUpdating={isUpdating("append_trailing_space")}
label="Append Trailing Space"
description="Automatically add a space at the end of transcribed text, making it easier to dictate multiple sentences in a row."
descriptionMode={descriptionMode}
grouped={grouped}
/>
);
});
import React from "react";
import { ToggleSwitch } from "../ui/ToggleSwitch";
import { useSettings } from "../../hooks/useSettings";
interface AppendTrailingSpaceProps {
descriptionMode?: "inline" | "tooltip";
grouped?: boolean;
}
export const AppendTrailingSpace: React.FC<AppendTrailingSpaceProps> =
React.memo(({ descriptionMode = "tooltip", grouped = false }) => {
const { getSetting, updateSetting, isUpdating } = useSettings();
const enabled = getSetting("append_trailing_space") ?? false;
return (
<ToggleSwitch
checked={enabled}
onChange={(nextEnabled) =>
updateSetting("append_trailing_space", nextEnabled)
}
isUpdating={isUpdating("append_trailing_space")}
label="Append Trailing Space"
description="Automatically add a space at the end of pasted text, making it easier to dictate multiple sentences in a row."
descriptionMode={descriptionMode}
grouped={grouped}
/>
);
});
🤖 Prompt for AI Agents
In src/components/settings/AppendTrailingSpace.tsx around lines 1 to 27, the UI
description is inaccurate and the onChange callback shadows the outer enabled
variable; update the description string to reference "pasted text" (e.g.,
"Automatically add a space at the end of pasted text...") to match backend
behavior, and rename the onChange parameter from enabled to a different name
like newValue or checked to avoid shadowing the local enabled constant, then
pass that renamed parameter into updateSetting.

@dannysmith dannysmith closed this Dec 4, 2025
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