Skip to content

fix(cloud): clarify autosync token log and add UTF-8 PS1 output encoding#454

Merged
Alan-TheGentleman merged 2 commits into
mainfrom
fix/windows-bg-sync-code-421
May 29, 2026
Merged

fix(cloud): clarify autosync token log and add UTF-8 PS1 output encoding#454
Alan-TheGentleman merged 2 commits into
mainfrom
fix/windows-bg-sync-code-421

Conversation

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

@Alan-TheGentleman Alan-TheGentleman commented May 29, 2026

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 misleading ENGRAM_CLOUD_TOKEN is required log messages to name both the env var and the cloud.json file 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/InputEncoding to UTF-8 so PowerShell 5.1 doesn't mangle the JSON payload.
  • Added TestTryStartAutosyncUsesFileToken locking the file-token-on-startup behavior end-to-end.

Test plan

go test ./cmd/engram/... and go build ./... clean.

Notes

Passed adversarial review. The Task Scheduler doc portion merged via #456, so this completes #421.

… 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).
Copilot AI review requested due to automatic review settings May 29, 2026 12:15
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 29, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@Alan-TheGentleman Alan-TheGentleman merged commit 178a015 into main May 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Windows background sync failures with PowerShell 5.1 and Task Scheduler

2 participants