feat: sub extension can set 'platforms' now#847
Merged
RainyNight9 merged 1 commit intomainfrom Jul 31, 2025
Merged
Conversation
Before this commit, sub extensions were not allowed to set their
"platforms" field, this restriction is lifted in this commit.
By allowing this, a group extension can have sub extensions for
different platforms, here is an example (irrelavent fields are omitted
for the sake of simplicity):
```json
{
"name": "Suspend my machine",
"type": "Group",
"platforms": ["macos", "windows"],
"commands": [
{
"name": "Suspend macOS":
"platforms": ["macos"],
"action": {...}
},
{
"name": "Suspend Windows":
"platforms": ["windows"],
"action": {...}
}
]
}
```
While loading or installing extensions, incompatible sub extensions will
be filtered out by Coco, e.g., you won't see that "Suspend Windows"
command if you are on macOS.
An extra check is added in this commit to ensure a sub extensions won't
support the platforms that are incompatible with its main extension.
Even though main extensions and sub extensions can both have "platforms"
specified, the semantics of this field, when not set, differs between them.
For main extensions, it means this extension is compatible with all the
platforms supported by Coco (null == all). For sub extensions, having it
not set implicitly says that this field has the same value as the main
extension's "platforms" field.
The primary reason behind this design is that if we choose the semantics used
by the main extension, treating null as all, all the extensions we currently
have will become invalid, because they are all macOS-only, the main extensions's
"platforms" field is "macos" and sub extensions' "platforms" is not set (null),
they will be equivalent to:
```json
{
"name": "this is macOS-only",
"type": "Group",
"platforms": ["macos"],
"commands": [
{
"name": "How the fxxk can this support all the platforms!"
"platforms": ["macos", "windows", "linux"],
"type": "Command",
"action": {...}
}
]
}
```
This hits exactly the check we mentioned earlier and will be rejected by
Coco. If we have users installed them, the installed extensions will be
treated invalid and rejected by future Coco release, boom, we break backward
compatibility.
Also, the current design actually makes sense. Nobody wants to repeatedly
tell Coco that all the sub extensions support macOS if this can be said only
once:
```json
{
"name": "this is macOS-only",
"platforms": ["macos"],
"commands": [
{
"name": "This supports macOS"
"platforms": ["macos"],
},
{
"name": "This supports macOS too"
"platforms": ["macos"],
},
{
"name": "Guess what! this also supports macOS"
"platforms": ["macos"],
},
{
"name": "Come on dude, do I really to say this platform=macos so many times"
"platforms": ["macos"],
}
]
}
```
24a7cc9 to
613ad92
Compare
RainyNight9
approved these changes
Jul 31, 2025
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.
Before this commit, sub extensions were not allowed to set their "platforms" field, this restriction is lifted in this commit.
By allowing this, a group extension can have sub extensions for different platforms, here is an example (irrelavent fields are omitted for the sake of simplicity):
{ "name": "Suspend my machine", "type": "Group", "platforms": ["macos", "windows"], "commands": [ { "name": "Suspend macOS": "platforms": ["macos"], "action": {...} }, { "name": "Suspend Windows": "platforms": ["windows"], "action": {...} } ] }While loading or installing extensions, incompatible sub extensions will be filtered out by Coco, e.g., you won't see that "Suspend Windows" command if you are on macOS.
An extra check is added in this commit to ensure a sub extensions won't support the platforms that are incompatible with its main extension.
Even though main extensions and sub extensions can both have "platforms" specified, the semantics of this field, when not set, differs between them. For main extensions, it means this extension is compatible with all the platforms supported by Coco (null == all). For sub extensions, having it not set implicitly says that this field has the same value as the main extension's "platforms" field.
The primary reason behind this design is that if we choose the semantics used by the main extension, treating null as all, all the extensions we currently have will become invalid, because they are all macOS-only, the main extensions's "platforms" field is "macos" and sub extensions' "platforms" is not set (null), they will be equivalent to:
{ "name": "this is macOS-only", "type": "Group", "platforms": ["macos"], "commands": [ { "name": "How the fxxk can this support all the platforms!" "platforms": ["macos", "windows", "linux"], "type": "Command", "action": {...} } ] }This hits exactly the check we mentioned earlier and will be rejected by Coco. If we have users installed them, the installed extensions will be treated invalid and rejected by future Coco release, boom, we break backward compatibility.
Also, the current design actually makes sense. Nobody wants to repeatedly tell Coco that all the sub extensions support macOS if this can be said only once:
{ "name": "this is macOS-only", "platforms": ["macos"], "commands": [ { "name": "This supports macOS" "platforms": ["macos"], }, { "name": "This supports macOS too" "platforms": ["macos"], }, { "name": "Guess what! this also supports macOS" "platforms": ["macos"], }, { "name": "Come on dude, do I really to say this platform=macos so many times" "platforms": ["macos"], } ] }Standards checklist