Skip to content

About

☕️ Skeleton for a new app or extension for OpenCloud Web

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Comments for OpenCloud

OpenCloud web extension for discussing files, folders, and spaces. Adds a sidebar panel in the Files app and a comment dashboard that aggregates threads across all spaces.

Comments are stored as WebDAV sidecar files next to each resource (.{name}.jsco) — no native comments API required. Every resource with comments is additionally marked with a status tag (Kommentiert / Kommentarchiv) through the OpenCloud graph tags API, so the dashboard can find commented resources with an indexed tag search instead of scanning every folder. The storage layer is abstracted so a future backend can replace it without rewriting the UI.

App ID comments
License AGPL-3.0
OpenCloud 7.x (extension-sdk 7.1.2)
Languages English, German

Screenshots

Comment dashboard

Filter threads by status, replies, resource type, and tags across all spaces.

Comment dashboard

Sidebar panel

Discuss a selected file or folder directly from the Files app sidebar.

Comments sidebar panel

Features

Sidebar panel

  • Comment on a selected file or folder from the Files app sidebar
  • Markdown support for comment bodies
  • Thread replies, edit, soft-delete, resolve / reopen
  • Live refresh via SSE when sidecar files change
  • Opens automatically (and in the right editor) when a resource is reached from the dashboard or a mention notification

Comment dashboard

Route: /comments/dashboard (app menu entry)

Aggregates all comment threads the current user can access and supports filtering by:

Filter Values Initial Reset default
Status all, open, resolved, search all open all
Replies all, answered, unanswered answered all
Type all, file, folder, space all all
Author all, me me all
Tag any assigned tag — —

Each entry shows the thread preview, target metadata (refreshed from WebDAV), reply count, and a shortcut to open the resource — files open in the matching editor, folders and spaces open in the Files view — with the comments sidebar scrolled into place.

Status tags

Every resource that has comments is tagged so it can be found quickly and filtered by state:

Tag Meaning
Kommentiert The resource has at least one open thread
Kommentarchiv The resource has threads, but all are resolved
(no tag) The resource has no threads (e.g. after delete all comments)

Details in Tag system below.

Internationalization

UI strings are centralized in src/i18n/messages.ts and translated in l10n/translations.json. Components use useCommentGettext() so translations are registered even when the extension loads lazily (e.g. sidebar panel).

To add or change a string:

  1. Add the English msgid to commentMessages in src/i18n/messages.ts
  2. Add translations to l10n/translations.json (de, en, …)
  3. Use $gettext(msg.yourKey) in Vue/TS code

Architecture

flowchart LR
  subgraph UI
    Panel[CommentsPanel]
    Dashboard[CommentsDashboard]
  end

  subgraph Composables
    UC[useComments]
    UD[useCommentsDashboard]
  end

  subgraph Storage
    Sidecar[WebdavSidecarCommentStorage]
    DashStore[WebdavSidecarDashboardStorage]
  end

  subgraph OpenCloud
    WebDAV[(WebDAV .{name}.jsco)]
    Tags[[graph tags API]]
    Search[(tag search index)]
    SSE[SSE file touched]
  end

  Panel --> UC --> Sidecar
  Sidecar -->|read/write JSON| WebDAV
  Sidecar -->|assign/unassign status tag| Tags
  Dashboard --> UD --> DashStore
  DashStore -->|tag search| Search
  DashStore -->|read matched JSON| WebDAV
  Tags --> Search
  SSE --> UC
Loading

Sidecar layout:

{space}/{container}/.{resourceName}.jsco

Example: /projects/Plan.md → /projects/.Plan.md.jsco

Each JSON document contains threads[] with status, comments[], and a target snapshot. The dashboard resolves live names and paths from WebDAV on load.

See docs/ for the storage model, dashboard API, and planned native backend.

Tag system

The tag system is what makes the dashboard fast. Instead of walking every folder to find sidecar files, the dashboard asks the OpenCloud search index for resources carrying a status tag, then reads only those sidecars.

Which resources get tagged

Both the source resource (the commented file/folder/space) and its .jsco sidecar are tagged. Tagging both improves coverage: on shared mountpoints WebDAV sometimes omits tags on the source resource, but the sidecar remains queryable in the recipient's space.

State machine

The tag state is derived from the sidecar document's threads:

Threads State Tag assigned Tag removed
Any thread open active Kommentiert Kommentarchiv
Threads exist, all resolved archived Kommentarchiv Kommentiert
No threads none — Kommentiert and Kommentarchiv

Implemented in src/utils/commentTags.ts (getCommentTagState, getTagsToAssign, getTagsToUnassign) and applied via the graph tags API (assignTags / unassignTags, endpoint /v1.0/extensions/org.libregraph/tags).

When tags are synced

WebdavSidecarCommentStorage re-syncs the tag after every operation that can change the state:

  • Creating the first thread, replying, editing, soft-deleting a comment
  • Resolving / reopening a thread
  • Loading the sidecar (self-healing if a tag drifted)
  • Delete all comments removes the sidecar and unassigns both tags from the source resource

Assigning the target tag and unassigning the opposite tag are performed independently. Assigning runs first, so it can never be skipped just because unassigning the opposite tag failed — which is exactly what happens on the very first comment, when the opposite tag does not exist on the server yet. Both calls are best-effort and never block comment storage.

How the dashboard uses tags

WebdavSidecarDashboardStorage.listThreads picks its strategy from the requested status:

  • open / resolved / all → indexed tag search (webdav.search with a KQL tag: pattern), e.g. tag:Kommentiert, tag:Kommentarchiv, or tag:Kommentiert OR tag:Kommentarchiv. Only matched sidecars are read. This is the fast path.
  • search all → full recursive directory scan (reads every .jsco). This is the slow fallback and is only used when explicitly searching everything.

The KQL patterns are built in src/utils/dashboardStatusTags.ts (buildDashboardTagSearchPattern). Because the source resource and the sidecar can both match, dashboard entries are de-duplicated by space:thread id.

Limitations: individual file shares & notifications

Comments on individually shared files (single-file shares, not folders or project spaces) rely on a separate .jsco sidecar. Mentions, dashboard filters, and notifications are best effort in that setup. Share notifications in the bell come from the OpenCloud server; @mention alerts are not server notifications today.

See docs/individual-file-shares-and-notifications.md for details. The sidebar shows a warning when commenting on such files.

Project structure

src/
├── index.ts                 # Extension entry, routes, sidebar registration
├── components/              # Panel, thread, form
├── views/CommentsDashboard.vue
├── composables/             # useComments, useCommentsDashboard, sidebar/route glue
├── storage/                 # WebDAV sidecar adapters (comment + dashboard)
├── constants/tags.ts        # Kommentiert / Kommentarchiv tag names
├── i18n/                    # messages, registration, useCommentGettext
└── utils/                   # target resolution, tag sync, dashboard helpers

l10n/translations.json       # gettext catalog (de, en, …)
docs/                        # API and design notes
tests/unit/                  # Vitest unit tests
tests/live/                  # Optional live WebDAV tests

Development

Requires Docker, Docker Compose, and pnpm.

pnpm install
pnpm build:w          # watch build → dist/
docker compose up

Add to /etc/hosts:

127.0.0.1 test.oc

Open https://test.oc:9200 (demo user admin / admin).

The compose stack mounts ./dist into the OpenCloud container at /web/apps/comments.

Build & deploy

pnpm build

Output lands in dist/. Copy it to your OpenCloud web apps directory:

rsync -a dist/ /path/to/opencloud/apps/comments/

When using opencloud-compose, the parent repo's build-web-extensions.sh handles build and deploy to config/opencloud/apps/comments/.

Official reference: OpenCloud web applications

Scripts

Command Description
pnpm build Production build
pnpm build:w Development watch build
pnpm test:unit Unit tests (Vitest)
pnpm check:types TypeScript check
pnpm lint ESLint
pnpm format:write Prettier

Tests

pnpm test:unit

Live WebDAV tests (optional, need a running OpenCloud instance) live under tests/live/. They are excluded from pnpm test:unit; run them with:

pnpm test:live

Dashboard API

For programmatic access to aggregated threads, see docs/dashboard-api.md.

import { WebdavSidecarDashboardStorage } from './storage/WebdavSidecarDashboardStorage'

// Pass the graph client to enable tag search and target-link enrichment.
const api = new WebdavSidecarDashboardStorage(webdav, graph)
const { entries, total } = await api.listThreads(spaces, {
  status: 'open',        // uses the fast tag search (tag:Kommentiert)
  answered: 'unanswered',
  type: 'folder',
  limit: 50
})

WebDAV & tag examples

There is no dedicated HTTP comments API yet. These examples show the underlying storage and tag layer.

export OC_HOST='https://test.oc:9200'
export OC_USER='admin'
export OC_PASS='admin'
export OC_RESOLVE='--resolve test.oc:9200:127.0.0.1'

List drives

curl -k -s -u "${OC_USER}:${OC_PASS}" ${OC_RESOLVE} \
  "${OC_HOST}/graph/v1.0/me/drives" \
  | jq '.value[] | {name, driveAlias, id, webDavUrl: .root.webDavUrl}'

List sidecars in a folder

curl -k -s -u "${OC_USER}:${OC_PASS}" ${OC_RESOLVE} \
  -X PROPFIND \
  "${OC_HOST}/dav/spaces/${SPACE_ID}/Testordner/" \
  -H 'Depth: 1' \
  | grep -E '\\.jsco'

Read one sidecar

curl -k -s -u "${OC_USER}:${OC_PASS}" ${OC_RESOLVE} \
  "${OC_HOST}/dav/spaces/${SPACE_ID}/Testordner/.Plan.md.jsco" \
  | jq .

List all defined tags

curl -k -s -u "${OC_USER}:${OC_PASS}" ${OC_RESOLVE} \
  "${OC_HOST}/graph/v1.0/extensions/org.libregraph/tags" \
  | jq '.value[].name'

Search resources by status tag (what the dashboard fast path does)

The client issues a REPORT against /dav/spaces/ (all spaces at once) with a KQL tag: pattern:

curl -k -s -u "${OC_USER}:${OC_PASS}" ${OC_RESOLVE} \
  -X REPORT \
  "${OC_HOST}/dav/spaces/" \
  -H 'Content-Type: application/xml' \
  --data '<?xml version="1.0"?>
<oc:search-files xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:prop><oc:fileid/><d:displayname/></d:prop>
  <oc:search>
    <oc:pattern>tag:Kommentiert</oc:pattern>
    <oc:limit>200</oc:limit>
  </oc:search>
</oc:search-files>'

Filter a sidecar with jq

# open threads only
jq '.threads[] | select(.status == "open")'

# threads with at least one reply
jq '.threads[] | select([.comments[] | select(.deletedAt == null)] | length > 1)'

Roadmap

License

AGPL-3.0 — see LICENSE.

About

☕️ Skeleton for a new app or extension for OpenCloud Web

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages