fix(cloud): clarify autosync token log and add UTF-8 PS1 output encoding#454
Merged
Conversation
… encoding (#421) - Correct misleading log message in tryStartAutosync: token can come from cloud.json (file fallback via resolveCloudRuntimeConfig) or ENGRAM_CLOUD_TOKEN; the old message implied only the env var was checked, causing Windows users running under Task Scheduler to think file-based config was unsupported. - Add TestTryStartAutosyncUsesFileToken to lock the file-token fallback path for autosync startup — the existing behavior was correct but untested. - Set [Console]::OutputEncoding and InputEncoding to UTF-8 in the Windows PowerShell hook so non-ASCII characters in hook JSON payloads are not mangled by the default system codepage (CP1252/CP850).
There was a problem hiding this comment.
Pull request overview
Improves reliability and debuggability of Engram Cloud background sync on Windows by clarifying autosync configuration logs, ensuring UTF-8 console encoding for a PowerShell hook, and adding an end-to-end regression test for file-based token fallback.
Changes:
- Clarified autosync startup error logs to indicate both supported token/server sources (env vars and
cloud.json). - Forced UTF-8 console input/output encoding in the Claude Code PowerShell hook to prevent JSON corruption on Windows.
- Added an end-to-end test asserting autosync startup succeeds when the cloud token is only present in
cloud.json(no env vars).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cmd/engram/main.go |
Updates autosync missing-config log messages to accurately reflect env + file fallback behavior. |
cmd/engram/sync_cloud_auth_test.go |
Adds a regression test ensuring autosync startup uses the persisted cloud.json token when env vars are absent. |
plugin/claude-code/scripts/user-prompt-submit.ps1 |
Sets console UTF-8 encoding to prevent non-ASCII JSON payload corruption on Windows PowerShell environments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Closes #421 — Windows background sync, code-side fixes. (The Windows Task Scheduler documentation template already shipped in #456.)
Change
cmd/engram/main.go: corrected the misleadingENGRAM_CLOUD_TOKEN is requiredlog messages to name both the env var and thecloud.jsonfile source. (The token file-fallback itself already worked, from fix(cloud): client v1.15.9 sync --cloud does not send Authorization header despite valid cloud.json #343.)plugin/claude-code/scripts/user-prompt-submit.ps1: set[Console]::OutputEncoding/InputEncodingto UTF-8 so PowerShell 5.1 doesn't mangle the JSON payload.TestTryStartAutosyncUsesFileTokenlocking the file-token-on-startup behavior end-to-end.Test plan
go test ./cmd/engram/...andgo build ./...clean.Notes
Passed adversarial review. The Task Scheduler doc portion merged via #456, so this completes #421.