Skip to content

⚡ Bolt: [performance improvement] - #372

Open
Lucenx9 wants to merge 1 commit into
mainfrom
bolt-perf-truthy-env-13932124642738032432
Open

⚡ Bolt: [performance improvement]#372
Lucenx9 wants to merge 1 commit into
mainfrom
bolt-perf-truthy-env-13932124642738032432

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

💡 What: Replaced .map().unwrap_or(false) with .is_some_and() and replaced .to_lowercase() with .eq_ignore_ascii_case() in is_truthy_env.
🎯 Why: Eagerly calling .to_lowercase() allocates a new String unnecessarily when comparing against known ASCII literals.
📊 Impact: Eliminates one redundant O(N) heap allocation per environment variable check.
🔬 Measurement: Verify tests run as expected.


PR created automatically by Jules for task 13932124642738032432 started by @Lucenx9

  • Updated environment truthiness checks to avoid lowercase string allocations while preserving support for 1, true, and yes (case-insensitive, with existing trimming behavior).
  • Limited impact to socket CLI Rust logic; no native GTK/VTE behavior or public APIs changed.
  • Added contributor guidance for ASCII-only comparisons. No security or privacy behavior changes.

💡 What: Replaced `.map().unwrap_or(false)` with `.is_some_and()` and replaced `.to_lowercase()` with `.eq_ignore_ascii_case()` in `is_truthy_env`.
🎯 Why: Eagerly calling `.to_lowercase()` allocates a new `String` unnecessarily when comparing against known ASCII literals.
📊 Impact: Eliminates one redundant O(N) heap allocation per environment variable check.
🔬 Measurement: Verify tests run as expected.

Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Truthy environment matching

Layer / File(s) Summary
Allocation-free truthy comparison
crates/forktty-ui-gtk/src/socket_cli/hooks/event.rs, .jules/bolt.md
is_truthy_env replaces lowercasing and matching with direct "1" equality and ASCII-insensitive "true"/"yes" checks; the guidance note documents this comparison pattern.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: rust

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the change, but it is too generic and doesn’t describe the affected area or specific optimization. Use a concise descriptive title such as 'rust/socket: avoid lowercase allocation in is_truthy_env'.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Privacy Boundary ✅ Passed The only runtime change is is_truthy_env for local debug gating; no telemetry, network, or persistence code was added, and the other file is a note.
Terminal Command Safety ✅ Passed PASS: The patch only changes env-flag parsing for hook_debug; no PTY/socket/worktree/shell/packaging/notification command paths or input handling changed.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-perf-truthy-env-13932124642738032432

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc73aefb69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .jules/bolt.md
@@ -0,0 +1,3 @@
## 2024-07-24 - Avoid `.to_lowercase()` for ASCII checks

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove the task-local .jules root bucket

This commit introduces a new top-level .jules/ directory just to store a one-off Bolt learning note; I checked the parent tree and .jules did not exist before this change. That makes the repository shape drift for task-local metadata rather than a durable category of ForkTTY content, so the note should be omitted or kept outside the repo.

AGENTS.md reference: AGENTS.md:L122-L131

Useful? React with 👍 / 👎.

@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.

🧹 Nitpick comments (1)
crates/forktty-ui-gtk/src/socket_cli/hooks/event.rs (1)

258-263: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid overstating this as allocation-free.

This removes the to_lowercase() allocation, but trimmed_env() still allocates a String for every lookup via .trim().to_string() (in addition to std::env::var returning an owned value). If full allocation elimination is required, perform the trim and comparison on the owned value inside this closure; otherwise describe the optimization as removing the extra lowercasing allocation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/forktty-ui-gtk/src/socket_cli/hooks/event.rs` around lines 258 - 263,
Update the comments above the trimmed_env lookup to state only that the change
removes the extra lowercasing allocation, since trimmed_env still allocates a
String. Do not claim the environment check is allocation-free, and leave the
comparison implementation unchanged unless full allocation elimination is
explicitly required.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/forktty-ui-gtk/src/socket_cli/hooks/event.rs`:
- Around line 258-263: Update the comments above the trimmed_env lookup to state
only that the change removes the extra lowercasing allocation, since trimmed_env
still allocates a String. Do not claim the environment check is allocation-free,
and leave the comparison implementation unchanged unless full allocation
elimination is explicitly required.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0190ea68-e42e-4b0a-8d5e-4f750217c238

📥 Commits

Reviewing files that changed from the base of the PR and between e6b0e87 and cc73aef.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • crates/forktty-ui-gtk/src/socket_cli/hooks/event.rs

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