Skip to content

feat: new extension type View#894

Merged
medcl merged 1 commit intomainfrom
view-mode
Sep 25, 2025
Merged

feat: new extension type View#894
medcl merged 1 commit intomainfrom
view-mode

Conversation

@SteveLauC
Copy link
Copy Markdown
Member

@SteveLauC SteveLauC commented Sep 9, 2025

This commit introduces a new extension type View, which enables developers to implement extensions with GUI. It is implemented using iframe, developers can specify the path to the HTML file in the Extension.page field, then Coco will load and render that page when the extension gets opened.

coco-api

We provide a TypeScript library 1 that will contain the APIs developers need to make the experience better.

We start from file system APIs. Since the embedded HTML page will be loaded by WebView, which has no access to the local file system, we provide APIs to bridge that gap. Currently, fs:read_dir() is the only API we implemented, more will come soon.

Permission

As View extensions run user-provided code, we introduce a permision mechanism to sandbox the code. Developers must manually specify the permission their extension needs in the "plugin.json" file, e,g.:

"permissions": {
  "fs": [
    { "path": "/Users/foo/Downloads", "access": ["read", "write"] },
    { "path": "/Users/foo/Documents", "access": ["read"] }
  ],
  "http": [
    { "host": "api.github.com" }
  ],
  "api": ["fs:read_dir"]
}

Currently, both fs and api permissions are implemented. Permission checks apply only to View extensions for now; Command extensions will support them in the future.

Standards checklist

  • The PR title is descriptive
  • The commit messages are semantic
  • Necessary tests are added
  • Updated the release notes
  • Necessary documents have been added if this is a new feature
  • Performance tests checked, no obvious performance degradation

@SteveLauC SteveLauC marked this pull request as draft September 9, 2025 02:58
@SteveLauC SteveLauC force-pushed the view-mode branch 2 times, most recently from 54eecd6 to 91f77bb Compare September 14, 2025 01:00
@SteveLauC SteveLauC force-pushed the view-mode branch 5 times, most recently from 07426e2 to df242ae Compare September 24, 2025 03:14
@SteveLauC SteveLauC changed the title View mode feat: View extension Sep 24, 2025
This commit introduces a new extension type View, which enables developers
to implement extensions with GUI. It is implemented using iframe, developers
can specify the path to the HTML file in the `Extension.page` field, then
Coco will load and render that page when the extension gets opened.

coco-api

We provide a TypeScript library [1] that will contain the APIs developers
need to make the experience better.

We start from file system APIs. Since the embedded HTML page will be loaded
by WebView, which has no access to the local file system, we provide APIs
to bridge that gap. Currently, `fs:read_dir()` is the only API we implemented, more
will come soon.

Permission

As View extensions run user-provided code, we introduce a permision
mechanism to sandbox the code. Developers must manually specify the
permission their extension needs in the "plugin.json" file, e,g.:

"permissions": {
  "fs": [
    { "path": "/Users/foo/Downloads", "access": ["read", "write"] },
    { "path": "/Users/foo/Documents", "access": ["read"] }
  ],
  "http": [
    { "host": "api.github.com" }
  ],
  "api": ["fs:read_dir"]
}

Currently, both fs and api permissions are implemented. Permission checks
apply only to View extensions for now; Command extensions will support
them in the future.

[1]: https://github.com/infinilabs/coco-api
@SteveLauC SteveLauC changed the title feat: View extension feat: new extension type View Sep 25, 2025
@SteveLauC SteveLauC marked this pull request as ready for review September 25, 2025 02:59
Copy link
Copy Markdown
Member

@medcl medcl left a comment

Choose a reason for hiding this comment

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

LGTM

@medcl medcl merged commit 7ac4508 into main Sep 25, 2025
8 checks passed
@medcl medcl deleted the view-mode branch September 25, 2025 03:12
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.

3 participants