fix: resolve multiple bugs from code review #116#173
Merged
mengzhuo merged 1 commit intosipeed:mainfrom Feb 15, 2026
Merged
Conversation
Contributor
Author
|
Fixes four issues identified in the community code review: |
mengzhuo
requested changes
Feb 15, 2026
| // Characters like ':' are valid on Linux but illegal on Windows; we replace | ||
| // them so the same key works everywhere. The original key is preserved inside | ||
| // the JSON file, so loadSessions still maps back to the right in-memory key. | ||
| func sanitizeFilename(key string) string { |
Collaborator
There was a problem hiding this comment.
can we use filepath in standard library?
Contributor
Author
There was a problem hiding this comment.
Simplified — now uses \ for the colon (the only char that actually appears in session keys) and \ for validation. Dropped the manual replacer. Thanks for the review!
Fixes four issues identified in the community code review: - Session persistence broken on Windows: session keys like "telegram:123456" contain ':', which is illegal in Windows filenames. filepath.Base() strips drive-letter prefixes on Windows, causing Save() to silently fail. Added sanitizeFilename() to replace invalid chars in the filename while keeping the original key in the JSON payload. - HTTP client with no timeout: HTTPProvider used Timeout: 0 (infinite wait), which can hang the entire agent if an API endpoint becomes unresponsive. Set a 120s safety timeout. - Slack AllowFrom type mismatch: SlackConfig used plain []string while every other channel uses FlexibleStringSlice, so numeric user IDs in Slack config would fail to parse. - Token estimation wrong for CJK: estimateTokens() divided byte length by 4, but CJK characters are 3 bytes each, causing ~3x overestimation and premature summarization. Switched to utf8.RuneCountInString() / 3 for better cross-language accuracy. Also added unit tests for the session filename sanitization. Ref sipeed#116
d370ca7 to
0a88ff0
Compare
Collaborator
|
LGTM, thanks |
emadomedher
pushed a commit
to emadomedher/picoclaw
that referenced
this pull request
Feb 17, 2026
fix: resolve multiple bugs from code review sipeed#116
StarWindv
referenced
this pull request
in StarWindv/PicoClaw-shou
Feb 19, 2026
fix: resolve multiple bugs from code review #116
This was referenced Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes four issues identified in the community code review:
Session persistence broken on Windows: session keys like "telegram:123456" contain ':', which is illegal in Windows filenames. filepath.Base() strips drive-letter prefixes on Windows, causing Save() to silently fail. Added sanitizeFilename() to replace invalid chars in the filename while keeping the original key in the JSON payload.
HTTP client with no timeout: HTTPProvider used Timeout: 0 (infinite wait), which can hang the entire agent if an API endpoint becomes unresponsive. Set a 120s safety timeout.
Slack AllowFrom type mismatch: SlackConfig used plain []string while every other channel uses FlexibleStringSlice, so numeric user IDs in Slack config would fail to parse.
Token estimation wrong for CJK: estimateTokens() divided byte length by 4, but CJK characters are 3 bytes each, causing ~3x overestimation and premature summarization. Switched to utf8.RuneCountInString() / 3 for better cross-language accuracy.
Also added unit tests for the session filename sanitization.
Ref #116