From a8915ac722a94bbc5736ee4a4ecd8ff9dce005e7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 8 Aug 2026 07:42:18 +0000 Subject: [PATCH] perf: optimize padRight string padding using native padEnd Replaces custom string repetition and manual padding computation with native String.prototype.padEnd, which is executed via optimized native C++ methods under the hood, speeding up directory listing rendering. Co-authored-by: nathanBurg <58287074+nathanBurg@users.noreply.github.com> --- .jules/bolt.md | 5 +++++ packages/mcp/src/shared/list-files-response.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..f6112e68 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,5 @@ +# Bolt's Journal + +## 2025-02-17 - Global process.platform Interleaving in Concurrent Testing +**Learning:** Redefining global state properties like `process.platform` in async/concurrent test suites causes state pollution and race conditions across test blocks. In Bun, concurrent test execution means async describes/its yield control, causing different platform-based mock suites to run concurrently and override the shared `process.platform` back and forth. +**Action:** Isolate mock configurations inside test execution contexts or run tests using strict serial execution (or stub process/platform on a per-function dependency injection basis) rather than mutating global/process-level state. diff --git a/packages/mcp/src/shared/list-files-response.ts b/packages/mcp/src/shared/list-files-response.ts index d70221d6..a39ff075 100644 --- a/packages/mcp/src/shared/list-files-response.ts +++ b/packages/mcp/src/shared/list-files-response.ts @@ -438,6 +438,11 @@ function longestPathLength(entries: LeanRepoFileEntry[]): number { return max; } +/** + * Optimized padding using native `String.prototype.padEnd`. + * Built-in native implementation in C++ is faster and more efficient + * than manually concatenating strings via `repeat` inside loops. + */ function padRight(text: string, width: number): string { - return text.length >= width ? text : text + " ".repeat(width - text.length); + return text.padEnd(width); }