Skip to content

Dev - #24

Closed
MEKXH wants to merge 25 commits into
mainfrom
dev
Closed

Dev#24
MEKXH wants to merge 25 commits into
mainfrom
dev

Conversation

@MEKXH

@MEKXH MEKXH commented Mar 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

google-labs-jules Bot and others added 25 commits February 25, 2026 22:24
Optimizes session history persistence by appending new messages to the JSONL file instead of rewriting the entire history on every turn. This changes the I/O complexity from O(N) to O(1) per turn.

- Adds `Append` method to `SessionManager` in `internal/session/manager.go`.
- Updates `AddMessage` to return the new message object.
- Updates `AgentLoop` in `internal/agent/loop.go` to use `Append` instead of `Save`.
- Adds benchmark test demonstrating ~300x speedup for 1000 message history.
- Adds functional test ensuring data integrity with append-only writes.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
- Add color-coded status icons (Green ✔, Red ✖) to tool execution logs for better scannability.
- Add visual separators (•) between keyboard shortcuts in the help footer to improve readability.
- Update `chat_render_test.go` to force color output during tests and verify the new behavior.

These changes improve the UX by making critical information (success/failure) immediately visible and by organizing the help footer more clearly.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
This PR introduces two micro-UX improvements to the `golem chat` TUI:

1. **Color-Coded Tool Execution Status**: Tool execution results now
display a green checkmark (✔) for success and a red cross (✖) for
errors. Previously, these were rendered in uniform gray text, making it
harder to quickly scan for failures.
2. **Footer Separators**: The keyboard shortcut footer now includes a
bullet separator (`•`) between items, improving the visual grouping and
readability of the available commands.

Testing:
- Updated `TestView_RendersFooter` to verify the presence of separators.
- Added `TestRenderMessage_ToolIcons` to verify that ANSI color codes
are correctly applied to the status icons.
- Forced color output in tests using
`lipgloss.SetColorProfile(termenv.TrueColor)` to ensure reliable
assertions.

---
*PR created automatically by Jules for task
[3429724070416734327](https://jules.google.com/task/3429724070416734327)
started by @MEKXH*
💡 **What**: Replaced the O(N) full-file rewrite strategy for session
persistence with an O(1) append-only strategy using `os.O_APPEND`.

🎯 **Why**: As conversation history grows, rewriting the entire JSONL
file on every turn becomes increasingly expensive (e.g., ~4ms for 1000
messages). This causes unnecessary I/O overhead and latency.

📊 **Impact**: 
- Reduces disk I/O from O(N) to O(1) per turn.
- Benchmark results show ~300x speedup for saving a turn with 1000
messages of history (15µs vs 4900µs).
- Constant time performance regardless of conversation length.

🔬 **Measurement**: 
- Run `go test -bench=. ./internal/session` to verify the performance
difference.
- Run `go test ./internal/session/...` to verify correctness.

---
*PR created automatically by Jules for task
[9953064947980912194](https://jules.google.com/task/9953064947980912194)
started by @MEKXH*
- Refactor `RecallContext` to list directory files once instead of twice.
- Skip reading file content for keyword search if the file was already processed as a "recent" entry.
- Reduces memory recall latency by avoiding redundant I/O (approx 8x speedup in synthetic benchmark).
- Update tests to reflect that entries are no longer double-counted in SourceHits.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
- Replaced plain text output with a styled lipgloss table
- Added color-coded status indicators (SeaGreen for enabled, Gray for disabled)
- Improved readability with consistent column alignment and spacing
- Followed design system colors (Purple headers)

This change makes the scheduled jobs list easier to scan and visually consistent with other CLI commands.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
💡 **What:** Enhanced the `golem cron list` command output with a styled,
tabular layout using `lipgloss`.
🎯 **Why:** The previous plain-text output was hard to scan and lacked
visual hierarchy. The new design improves readability and consistency
with the rest of the CLI.
📸 **Before/After:**
*(Before)* Plain text table, no colors.
*(After)* Purple headers, SeaGreen/Gray status indicators, clear column
separation.
♿ **Accessibility:** Improved contrast for disabled items (dimmed) vs
enabled items (green), making status instantly recognizable. Used
standard terminal colors for broad compatibility.

---
*PR created automatically by Jules for task
[4948592623909661438](https://jules.google.com/task/4948592623909661438)
started by @MEKXH*
⚡ Bolt: Optimize memory recall I/O

💡 What:
Refactored `RecallContext` in `internal/memory/manager.go` to:
1. Call `collectDiaryFiles` only once.
2. Reuse the file list for both "recent" entry selection and "keyword"
search.
3. Check `seenPaths` *before* reading the file content in the keyword
search loop, preventing double-reads of files already included as
"recent".

🎯 Why:
The previous implementation performed two directory listings and blindly
read file contents for keyword searching even if the file had already
been loaded as a recent entry. This caused unnecessary I/O overhead,
which scales linearly with the number of diary files.

📊 Impact:
- Reduces redundant `os.ReadFile` calls.
- Benchmark (synthetic) showed reduction from ~1.8ms to ~0.22ms per op
for 100 diary files.
- Eliminates one `os.ReadDir` call per recall.

🔬 Measurement:
- `go test -bench . internal/memory/benchmark_test.go` (before deletion)
showed 8x improvement.
- Existing tests pass (with minor adjustment to SourceHits expectation).

---
*PR created automatically by Jules for task
[8997917101839574265](https://jules.google.com/task/8997917101839574265)
started by @MEKXH*
Added red coloring and an "ERROR" label to error messages in the chat TUI
so that system/tool execution errors are visually distinct from normal
agent replies. This improves scannability and UX when diagnosing issues.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
💡 **What**: Added visual distinction (red styling and "ERROR" label) for
error messages in the TUI chat interface.
🎯 **Why**: Error messages (e.g., from tool failures or system errors)
were previously styled exactly like normal "GOLEM" responses. This made
it difficult for users to quickly spot failures in a text-heavy log.
Color-coding and re-labeling them improves scannability and provides
immediate visual feedback.
📸 **Before/After**: Error messages now render with a red background for
the header and a red border for the content, instead of the default
SeaGreen.
♿ **Accessibility**: Improves visual hierarchy and scannability by using
semantic coloring (Red) for error states.

References: `.Jules/palette.md` learning on TUI Tool Execution Feedback.

---
*PR created automatically by Jules for task
[11106586624431986512](https://jules.google.com/task/11106586624431986512)
started by @MEKXH*
Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
💡 What: Replaced plain text fmt.Printf tabular output with lipgloss
styles and JoinHorizontal alignment in `channels list`.
🎯 Why: Makes scanning the channel list much easier by color coding
enabled states (green), disabled states (dim gray), and error states
(red). Also ensures cross-platform column alignment is pixel perfect
without breaking due to ANSI codes.
♿ Accessibility: Improved color contrast and clear distinct states
instead of relying purely on reading the string value.

---
*PR created automatically by Jules for task
[1299448172152027757](https://jules.google.com/task/1299448172152027757)
started by @MEKXH*
💡 What: Implemented a double-checked locking pattern in
`Manager.GetOrCreate` using a fast-path read lock (`m.mu.RLock()`).
🎯 Why: Previously, retrieving any existing session acquired a full
global write lock (`m.mu.Lock()`) on the entire `Manager`. In a
multi-channel or concurrent server environment, this created significant
lock contention because the vast majority of calls are cache hits.
📊 Impact: drastically reduces global lock contention and improves
throughput for concurrent message processing across channels. Write
locks are now strictly reserved for cache misses (when creating a
session for the first time).
🔬 Measurement: Run benchmarks using `go test -bench .
./internal/session/...` and observe performance in highly concurrent
server workloads (`golem run`).

---
*PR created automatically by Jules for task
[15993202011742759563](https://jules.google.com/task/15993202011742759563)
started by @MEKXH*
Replaced `fmt.Printf("%-20s")` with `lipgloss.JoinHorizontal` and
`lipgloss.Style.Width` in `skills list` and `skills search` commands to
prevent jagged columns when ANSI escape sequences or multi-byte characters
are present, aligning with the pattern used in other commands.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
🎨 Palette: Tabular Output Alignment in Skills CLI

💡 What: Updated `cmd/golem/commands/skills.go` to use `lipgloss` for
rendering tables.
🎯 Why: Prevents column jaggedness caused by invisible ANSI escape codes
and varying character widths when styling is applied.
♿ Accessibility/UX: Provides consistent, readable alignment for CLI
output regardless of content length or terminal capability.

---
*PR created automatically by Jules for task
[11074279529773642838](https://jules.google.com/task/11074279529773642838)
started by @MEKXH*
* Eliminate redundant `strings.ToLower()` inside loops across `extractKeywordExcerpt` and `containsAnyKeyword`, avoiding O(N * M) allocations for memory files.
* Remove pre-flight `m.Ensure()` file system operations on hot read paths (`ReadLongTerm`, `RecallContext`, `ReadRecentDiaries`), natively returning nil results on `os.IsNotExist`.

Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
Co-authored-by: MEKXH <59291264+MEKXH@users.noreply.github.com>
### 💡 What:
Color-code tool execution messages in the TUI chat to match their status
icon colors (Red for errors, SeaGreen for success). Both the icon and
the message text now share the semantic color.

### 🎯 Why:
In text-heavy TUI logs, relying only on plain text checkmarks (✔) or
crosses (✖) at the start of a gray log line is insufficient for quick
scanning. Explicitly color-coding the text improves scannability, making
it much easier for users to spot failed tool executions at a glance
without reading every line.

### 📸 Before/After:
**Before:** Tool output text was always rendered in `toolLogStyle`
(gray, italicized), with only a colored ✖ or ✔ icon prepended.
**After:** The entire tool output line (icon + text) is rendered in Red
(#FF0000) for errors and SeaGreen (#2E8B57) for successes.

### ♿ Accessibility:
Improves visual hierarchy and contrast for status indicators, aiding
quick comprehension in dense terminal environments. Reduces cognitive
load by associating semantic meaning (success/error) with both symbol
and text color.

---
*PR created automatically by Jules for task
[5128142950716635144](https://jules.google.com/task/5128142950716635144)
started by @MEKXH*
💡 What: Lifted `strings.ToLower()` allocations out of the keyword
checking/excerpting loop inside `RecallContext`. Also, removed
`m.Ensure()` calls from read-only paths.
🎯 Why: `RecallContext` matches user queries against daily diaries and
long-term memory. Previously, it performed a `strings.ToLower()` on the
file contents _inside_ helper function loops for every potential keyword
match. This led to thousands of unnecessary string allocations. Also,
`m.Ensure()` executed file stat and mkdir calls on every single read
operation, even though reading already handles `os.IsNotExist`.
📊 Impact: Expected to reduce CPU cycles and GC pressure significantly on
large workspaces by pre-computing lowercased content exactly once per
file read, and eliminating filesystem stat checks on the hot path.
🔬 Measurement: Run a benchmark or the unit tests via `make test` to
verify no regressions in functionality.

---
*PR created automatically by Jules for task
[9968487151001914513](https://jules.google.com/task/9968487151001914513)
started by @MEKXH*
将项目所有英文代码注释翻译为中文,保持注释规范性和准确性。
涉及 35 个文件的注释规范化处理。
@MEKXH MEKXH closed this Mar 3, 2026
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