feat: ReservedProperty protocol for plugin→frontend coordination#1143
Open
wyjrichhh wants to merge 3 commits into
Open
feat: ReservedProperty protocol for plugin→frontend coordination#1143wyjrichhh wants to merge 3 commits into
wyjrichhh wants to merge 3 commits into
Conversation
Introduce ReservedProperty to track and preserve reserved comments across Rime updates, and avoid clearing them on caret/selection-only updates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lotem
requested changes
Jun 17, 2026
| // │ the active InputController via handleReservedProperty│ | ||
| // └──────────────────────────────────────────────────────────────┘ | ||
| // | ||
| // The leading-underscore namespace marks the key as part of this |
Member
There was a problem hiding this comment.
Keys with leading-underscore are "transient options/properties":
https://github.com/rime/librime/blob/d71168e9e8c8392ed219dca011dbc76b80727d6c/src/rime/context.cc#L313
Their lifetime are bound to the active input schema in the context.
Author
There was a problem hiding this comment.
Thanks — corrected. The header now states that leading-underscore keys are librime transient properties whose lifetime is bound to the active input schema in the context (and cleared on schema change), and frames this protocol as reserving a subset of that namespace rather than inventing it. Fixed in b983b60.
- Document leading-underscore keys as librime transient properties whose lifetime is bound to the active input schema (per @lotem, context.cc). - Rename the bare-value shorthand field from `indices` to the neutral `value` so non-index keys can reuse the same scalar shorthand. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename short local bindings flagged by swiftlint and reposition a cyclomatic_complexity disable comment so it sits directly above the function declaration: - ReservedProperty.swift: n -> index - SquirrelApplicationDelegate.swift: eq -> eqIndex - SquirrelInputController.swift: move disable directive to the decl No behavioural change. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Summary
Introduces a
ReservedPropertyprotocol so a librime plugin can coordinatewith the Squirrel frontend over the existing
propertymessage channel,using reserved keys with a leading underscore (e.g.
_refresh_ui). Unknownreserved keys are silently ignored, so the wire format is backward-compatible.
The motivating use case (per #1124) is letting a plugin drive
semantic comment styling (accent / warning colors) on specific candidate
indices, and trigger a UI refresh without a keystroke.
Changes
sources/ReservedProperty.swift(new) — definesReservedPropertyKey,ReservedPropertyValue(URL-query-style parsing of the value payload), andindex-set decoding. This is the documented wire format and reserved-key table.
SquirrelApplicationDelegate.swift— routespropertymessages whose valuestarts with
_to the active input controller as reserved properties.SquirrelInputController.swift— addshandleReservedProperty(...)and astate-type reserved-property cache.
rimeUpdategains aclearReservedCommentsflag (defaulttrue) so reserved-comment indices setby the previous Compose() are dropped on ordinary state-changing updates and
preserved only for the
_refresh_ui-driven render.SquirrelPanel.swift/SquirrelTheme.swift— apply per-index semanticcomment colors (
accentCommentTextColor,warningCommentTextColor).Testing
missing
cangjie5*.dict.yamlresources and a CoreSimulator version mismatch,both unrelated to this change — CI build is the reliable signal here).