Skip to content

Track ZCode desktop sessions through approved lifecycle hooks - #128

Open
iPeluwa wants to merge 2 commits into
iamnotstatic:mainfrom
iPeluwa:feat/zcode-session-hooks
Open

iPeluwa wants to merge 2 commits into
iamnotstatic:mainfrom
iPeluwa:feat/zcode-session-hooks

Conversation

@iPeluwa

@iPeluwa iPeluwa commented Oct 21, 2026 •

Copy link
Copy Markdown

ZCode desktop sessions do not run the shell wrappers, so Vibetime never sees them. This adds ZCode to the desktop hook lifecycle and includes the fixes from #122.

  • Install, reconcile and remove hooks in ~/.zcode/cli/config.json alongside the existing desktop integrations.
  • Map SessionStart to session start, and UserPromptSubmit, PostToolUse and Stop to activity. Sessions close through the inactivity reaper because ZCode provides no session-end event.
  • Normalize sess_<uuid> IDs and ignore sub-agent IDs to prevent duplicate sessions.
  • Preserve user-approved hooks when their commands match. A changed executable path creates a fresh hook requiring approval in ZCode again.
  • Return without writing the config when nothing changed, preserving its exact bytes and modification time and avoiding a routine repair overwriting a toggle the user is saving.
  • Preserve unrelated commands and matcher-group metadata when Vibetime shares a group with other hooks, including during stale-command replacement and uninstall.
  • Leave invalid JSON and unsupported config shapes untouched. Document restart and Settings → Hooks approval without enabling hooks automatically.

Validation: the complete local suite passes 160/160. Tests cover merging, idempotency, saved approval, replacement, removal, invalid/unsupported configuration, fresh configuration, ID normalization and sub-agent exclusion. Added regressions verify no write on a matching enabled config and preservation of mixed groups; all three new regressions fail against the previous PR head.

The earlier macOS live verification is recorded in #122. This review reruns automated tests and does not claim a fresh ZCode desktop check. Windows and Linux desktop acceptance remain unverified.

Combined validation: all three revised branches merge cleanly in the order below and pass 192/192 local tests together.

Merge order: 1. #127 (storage) → 2. #129 (delivery) → 3. #128 (this PR). This replaces the closed #122.

@iamnotstatic

Copy link
Copy Markdown
Owner

Checked this against the #122 notes: the no-op repair now leaves the file alone (bytes and mtime), and odd shapes are left untouched instead of throwing. The mixed group handling is a nice addition. Only nit: a valid file with an unexpected shape says "not valid JSON", which might confuse someone. Good to go once #129 is in.

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.

2 participants