PadIO: context_modes resolution (context token to mode) - #15
Merged
Conversation
Map the external context token from ContextObserver to a mode, per profile. Policy lives here so the bridge stays dumb: ProfileConfig gains an optional context_modes ([String: String], token -> mode name), decoded with decodeIfPresent ?? [:] so existing configs keep parsing. Resolution rules, all deliberate: - fires only on token change (ContextObserver publishes only on change) - no match (or nil token) leaves the mode alone, never falls back to default_mode - a mode picked by hand sticks until the token changes - an unknown mode name is logged and ignored, mirroring setMode - only the active profile is affected refreshActiveProfile now restores the context-implied mode on return to a profile instead of snapping to default_mode, and sets both activeModeName and profileModes[name] to keep them consistent. Closes #9 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Implements #9. Builds on #8.
Maps the context token published by
ContextObserverto a mode, per profile. All policy lives in PadIO so the bridge (#12) stays dumb and just reports a raw process name.Config format
New optional key on
ProfileConfig:context_modesis[String: String](token → mode), decoded withdecodeIfPresent(...) ?? [:], so every existing config keeps parsing unchanged. Matching is exact on the token.Resolution rules (
applyContext)ContextObserverpublishes only when the token actually changes, so an unchanged token never re-applies a mode.context_modesentry (or a nil token) keeps the active mode; it does not fall back todefault_mode. This is what makes many app-specific modes safe..setModehandling.Profile-switch interaction
refreshActiveProfilenow restores the context-implied mode when a profile becomes active again (alt-tab away from Ghostty and back), instead of snapping todefault_mode. When it applies a context mode it sets bothactiveModeNameandprofileModes[name], so it no longer widens the pre-existing gap where onlyactiveModeNamewas set.Verified
BuildProject.context_modesanywhere is unchanged (empty dict default).Runtime check (writing
claude/nvim/ an unmapped token to the context file and watching the mode HUD) is easiest to do end-to-end once the bridge in #12 exists, or by hand withprintf ... > tmp && mv tmp ~/.config/padio/context.🤖 Generated with Claude Code