Skip to content

feat(ui): render message action buttons (client::action, #494) - #1088

Merged
jmattheis merged 1 commit into
gotify:masterfrom
EinfacheSache:feat/action-buttons
Nov 29, 2026
Merged

jmattheis merged 1 commit into
gotify:masterfrom
EinfacheSache:feat/action-buttons

Conversation

@EinfacheSache

@EinfacheSache EinfacheSache commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Implements the web UI part of #494 using the format from #494 (comment).

"extras": {
  "client::action": {
    "buttons": [
      {"label": "Approve", "http": {"method": "post", "url": "https://example.com/approve?id=5", "headers": {"Authorization": "bearer token"}}}
    ]
  }
}

action buttons

Behavior

  • Buttons are rendered below the message content. A tooltip shows METHOD host.
  • Clicking sends the request with fetch (method, url, headers). The button is disabled while the request runs, and the result is reported in a snackbar (success, HTTP error status, or network/CORS error).
  • method is case-insensitive and defaults to POST. Allowed methods are GET, POST, PUT, PATCH and DELETE.

Safety

  • Only http:/https: URLs are accepted, so javascript:, data: and similar URLs are dropped.
  • credentials: "omit" and referrerPolicy: "no-referrer" are set, so no cookies or Gotify URL leak to the target.
  • Invalid buttons are skipped silently: a missing or empty label, a missing URL, or an unknown method. Non-string header values are dropped.
  • Requests come from the browser, so the target needs to allow CORS (e.g. Access-Control-Allow-Origin and Access-Control-Allow-Headers for custom headers). I'll document this in a docs PR for gotify/website, so other clients (Android, iGotify) can follow the same format.

Tests

  • src/message/extras.test.ts: unit tests for parsing and validation.
  • src/tests/message-actions.test.ts: e2e test with a local HTTP target. It checks that the buttons render, that a click sends the right method, path and header, and that the success and failure snackbars appear.
  • The full UI suite (CI=true yarn test) passes locally, along with tsc, lint and testformat.

I haven't touched the Android client.

@jmattheis

Copy link
Copy Markdown
Member

I've made some changes and:

  • added zod for parsing the object.
  • body param for defining the request body
  • show parsing errors in the message
  • remove POST default (explicit is almost always better)

Could you have a look at it?

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.82%. Comparing base (2affea1) to head (624d040).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1088   +/-   ##
=======================================
  Coverage   81.82%   81.82%           
=======================================
  Files          69       69           
  Lines        3290     3290           
=======================================
  Hits         2692     2692           
  Misses        598      598           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

EinfacheSache added a commit to EinfacheSache/website that referenced this pull request Nov 22, 2026
@EinfacheSache

Copy link
Copy Markdown
Contributor Author

Thanks a lot, your changes look good to me. Types, lint, unit and e2e tests pass locally.

I added two commits on top:

  • Reject requests fetch can't send: GET/HEAD with a body and the methods CONNECT/TRACE/TRACK always fail in fetch with a TypeError before anything is sent. The user saw "network error or CORS" for these. They're now reported as parsing errors like other invalid buttons.
  • Buttons that open a URL: {"label": "Status page", "open": {"url": "https://status.example.com"}} opens the URL in a new tab instead of sending a request. It's useful for "service X is down → open status page", which the web UI can't do today (it doesn't support client::notification.click.url). It's a separate commit, so if you'd rather discuss the format first or have it in its own PR, I'll drop it.

I've updated the docs in gotify/website#108 to match (method required, body, open).

@jmattheis

Copy link
Copy Markdown
Member

The extra validation is okay, but please remove the open URL thingy. This should be already covered by a normal markdown link, therefore I don't want to include this right now.

EinfacheSache pushed a commit to EinfacheSache/website that referenced this pull request Nov 23, 2026
The open url buttons were dropped from gotify/server#1088, a markdown
link covers that use case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TfcCbQtufdKZ9AtMjeVvch
@EinfacheSache

Copy link
Copy Markdown
Contributor Author

Removed the open URL buttons in 3d2cd75 and updated the docs in gotify/website#108. Ready to merge from my side.

Render the HTTP action buttons defined in
extras["client::action"].buttons as proposed in gotify#494.

Clicking a button sends the configured request via fetch (method, url,
headers, body). Only http(s) URLs are accepted, invalid buttons are
skipped and reported in a warning. Cookies are not sent (credentials:
omit) and the result is reported via a snackbar.
@jmattheis
jmattheis enabled auto-merge November 29, 2026 15:25
@jmattheis
jmattheis added this pull request to the merge queue Nov 29, 2026
Merged via the queue into gotify:master with commit 03dfc3d Nov 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants