9 Commits
Author SHA1 Message Date
Mateusz PstruchaandClaude Opus 5.5 d225294ba8 Bump to 0.8.5
CI / build (push) Successful in 16s
Release / release (push) Successful in 12s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:50:32 +01:00
Mateusz PstruchaandClaude Opus 5.5 be8d97aa76 Ignore local Claude files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:50:22 +01:00
mtps b8dccdd82f Merge pull request 'Publish straight to the bucket' (#1) from claude/static-publish into master
CI / build (push) Successful in 15s
2026-11-09 13:07:40 +01:00
Mateusz PstruchaandClaude Opus 5.5 9533392c81 🚀 publish straight to the bucket
CI / build (pull_request) Successful in 25s
The release builds and uploads with ygg/actions/static-publish, instead of
deploying static-server through kara.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 15:13:05 +01:00
Mateusz PstruchaandClaude Opus 5.5 29af920dfb Edit accounts from the Accounts screen
CI / build (push) Successful in 11s
Each account gets an Edit button opening the add form pre-filled with
its settings; the password field is optional ("unchanged") and only a
new value replaces the stored one. Editing no longer rewrites the hosts
or login from the address, so a working setup isn't silently changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:11:10 +02:00
Mateusz PstruchaandClaude Opus 5.5 f763777477 Bump to 0.8.4
CI / build (push) Successful in 32s
Release / release (push) Successful in 17s
Release / deploy (push) Successful in 14s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:53:51 +02:00
Mateusz PstruchaandClaude Opus 5.5 50d8059d8b Add an Accounts screen
CI / build (push) Successful in 11s
Lists the mail accounts Tern syncs with their live sync status (polled
while open), message counts and the last error when one fails; adds an
account with the same address-derived defaults as the Android app; and
removes one after saying plainly that its synced mail goes with it.
With no account yet, the mail list points there and the form opens on
its own — until now the webapp had no way to connect a mailbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:48:57 +02:00
Mateusz PstruchaandClaude Opus 5.5 4affa135cd Bump to 0.8.3
CI / build (push) Successful in 20s
Release / release (push) Successful in 18s
Release / deploy (push) Successful in 15s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:31 +02:00
Mateusz PstruchaandClaude Opus 5.5 f2a9e1762f Deploy tern-web on its own, calling the API on its own origin
CI / build (push) Successful in 12s
The webapp now deploys from its own release as a static-server Swarm
stack (deploy/static.yml, tern.mtps.pl on 11902) instead of driving the
server's deployment. It's built with VITE_TERN_API — the
TERN_API_URL repository variable, defaulting to
https://tern-api.mtps.pl — and sends REST calls and the live-update
socket there. Empty (development), it stays same-origin behind Vite's
proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:44:22 +02:00
9 changed files with 538 additions and 58 deletions

No files matched your search

+12 -49
View File
@@ -23,8 +23,12 @@ jobs:
- name: Type check
run: npm run check
# The API is its own origin when deployed. Overridable with the
# TERN_API_URL repository variable.
- name: Build
run: npm run build
env:
VITE_TERN_API: ${{ vars.TERN_API_URL || 'https://tern-api.mtps.pl' }}
- name: Create release archive
run: |
@@ -45,53 +49,12 @@ jobs:
tern-web-*.tgz
tern-web-*.tgz.sha256
# Deploys the release to tern.mtps.pl (kara, deploy/compose). It lives
# here rather than in tern-server because tags are pushed server-first and
# the single runner works through them in order, so by the time this runs
# both the server image and this webapp release exist. A deploy job in
# tern-server would have to wait for this repo's release while holding
# the only runner.
deploy:
needs: release
runs-on: rocky-10
steps:
# The deployment definition is versioned with the server it deploys.
- name: Check out deployment definition
uses: actions/checkout@v4
# Straight to the bucket, with a key that only reaches it. The bucket and
# the nginx site come from deployments/tern-web.yml in ygg/deployments.
- name: Publish
uses: https://git.app.ygg/ygg/actions/static-publish@v2
with:
repository: mtps/tern-server
ref: ${{ gitea.ref_name }}
- name: Check the server image exists
env:
IMAGE: git.app.ygg/mtps/tern-server
TAG: ${{ gitea.ref_name }}
run: |
# Fails fast with a clear message if the server release didn't
# publish this version (failed, or still running on another
# runner), instead of a deploy that can't pull its image.
VERSION="${TAG#v}"
for i in $(seq 1 20); do
docker manifest inspect "$IMAGE:$VERSION" >/dev/null 2>&1 && exit 0
echo "waiting for $IMAGE:$VERSION ($i/20)"
sleep 30
done
echo "::error::$IMAGE:$VERSION not found in the registry — did the tern-server release succeed?"
exit 1
- name: Derive version
id: version
env:
TAG: ${{ gitea.ref_name }}
run: echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Deploy
uses: https://git.app.ygg/ygg/actions/deploy@v2
with:
type: compose
dist-path: deploy/tern.yml
extra-vars: |
version=${{ steps.version.outputs.version }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
path: dist
bucket: tern.mtps.pl
access-key-id: ${{ secrets.STATIC_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.STATIC_SECRET_ACCESS_KEY }}
+4
View File
@@ -3,3 +3,7 @@ dist
.env
*.log
.DS_Store
# Local Claude Code files
CLAUDE.md
.claude/
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "tern-web",
"version": "0.8.2",
"version": "0.8.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tern-web",
"version": "0.8.2",
"version": "0.8.5",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@tsconfig/svelte": "^5.0.4",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "tern-web",
"private": true,
"version": "0.8.2",
"version": "0.8.5",
"type": "module",
"scripts": {
"dev": "vite",
+420
View File
@@ -0,0 +1,420 @@
<script lang="ts">
// The mail accounts Tern syncs, with how each one's sync is going, and
// the form to connect another. Only the server ever talks to the mail
// server (server-architecture-spec.md §2); this screen just hands it the
// settings and shows what it reports back.
import { createAccount, deleteAccount, listAccounts, updateAccount, type Account } from './api';
import { formatFullDate } from './format';
let {
reloadKey = 0,
onChanged,
}: {
/** Bumped by the parent when accounts change elsewhere (another tab). */
reloadKey?: number;
/** Tells the parent the account list changed (sidebar, compose). */
onChanged?: () => void;
} = $props();
/** Sync status isn't pushed as an event, so an open screen polls it. */
const STATUS_POLL_MS = 5_000;
let accounts = $state<Account[]>([]);
let loaded = $state(false);
let error = $state<string | null>(null);
let adding = $state(false);
/** The account being edited; the form is shared with adding. */
let editing = $state<Account | null>(null);
let saving = $state(false);
let formError = $state<string | null>(null);
// Form fields. Login and hosts follow the address until edited by hand.
let email = $state('');
let displayName = $state('');
let imapHost = $state('');
let imapPort = $state(993);
let smtpHost = $state('');
let smtpPort = $state(587);
let login = $state('');
let password = $state('');
let loginEdited = $state(false);
let hostsEdited = $state(false);
async function load() {
try {
accounts = await listAccounts();
error = null;
} catch (e) {
error = e instanceof Error ? e.message : 'failed to load accounts';
} finally {
loaded = true;
}
}
// Loads on mount and whenever the parent bumps reloadKey; polls while open.
$effect(() => {
void reloadKey;
load();
});
$effect(() => {
const timer = setInterval(load, STATUS_POLL_MS);
return () => clearInterval(timer);
});
// With no account yet, the form is the whole point of the screen.
$effect(() => {
if (loaded && accounts.length === 0) adding = true;
});
function emailChanged() {
const domain = email.includes('@') ? email.split('@')[1] : '';
if (!loginEdited) login = email;
if (!hostsEdited) {
imapHost = domain ? `mail.${domain}` : '';
smtpHost = imapHost;
}
}
function resetForm() {
email = displayName = imapHost = smtpHost = login = password = '';
imapPort = 993;
smtpPort = 587;
loginEdited = hostsEdited = false;
formError = null;
}
function startEdit(a: Account) {
adding = false;
editing = a;
email = a.email_address ?? '';
displayName = a.display_name ?? '';
imapHost = a.imap_host;
imapPort = a.imap_port;
smtpHost = a.smtp_host;
smtpPort = a.smtp_port;
login = a.username;
password = '';
// Editing the address must not silently rewrite settings that work.
loginEdited = hostsEdited = true;
formError = null;
}
function closeForm() {
adding = false;
editing = null;
resetForm();
}
async function save(event: SubmitEvent) {
event.preventDefault();
saving = true;
formError = null;
const settings = {
name: editing?.name ?? (email.split('@')[1] || email),
imap_host: imapHost.trim(),
imap_port: Number(imapPort),
smtp_host: smtpHost.trim(),
smtp_port: Number(smtpPort),
username: login.trim(),
password,
email_address: email.trim() || null,
display_name: displayName.trim() || null,
};
try {
if (editing) await updateAccount(editing.id, settings);
else await createAccount(settings);
closeForm();
await load();
onChanged?.();
} catch (e) {
formError = e instanceof Error ? e.message : 'failed to save the account';
} finally {
saving = false;
}
}
async function remove(a: Account) {
const what = a.email_address ?? a.username;
const count = a.sync?.messages ?? 0;
if (
!confirm(
`Remove ${what}?\n\nTern stops syncing it and deletes the ${count} message${count === 1 ? '' : 's'} it synced from it, ` +
`including anything you've tagged or filed. Mail on your mail server isn't touched — adding the account again re-syncs the inbox.`,
)
)
return;
try {
await deleteAccount(a.id);
await load();
onChanged?.();
} catch (e) {
error = e instanceof Error ? e.message : 'failed to remove the account';
}
}
function statusText(a: Account): string {
const s = a.sync;
if (!s || s.status === 'pending') return 'Waiting to connect…';
switch (s.status) {
case 'syncing':
return s.caught_up ? 'Connecting…' : 'First sync in progress…';
case 'idle':
return 'Connected — new mail arrives as it lands';
case 'error':
return 'Can’t sync — retrying';
}
}
</script>
<div class="accounts">
<header>
<h2>Accounts</h2>
{#if !adding && !editing}
<button class="primary" onclick={() => { resetForm(); adding = true; }}>Add account</button>
{/if}
</header>
<p class="hint">
The mailboxes Tern syncs. Your Tern server connects to each one itself — IMAP over TLS on port 993 to
read, SMTP on 587 (STARTTLS) or 465 to send — so the mail server has to be reachable from it.
</p>
{#if error}<p class="error">{error}</p>{/if}
{#if accounts.length > 0}
<ul>
{#each accounts as a (a.id)}
<li>
<span class="dot state-{a.sync?.status ?? 'pending'}" aria-hidden="true"></span>
<div class="body">
<strong>{a.display_name ? `${a.display_name} <${a.email_address ?? a.username}>` : (a.email_address ?? a.username)}</strong>
<span class="detail">IMAP {a.imap_host}:{a.imap_port} · SMTP {a.smtp_host}:{a.smtp_port} · login {a.username}</span>
<span class="status state-{a.sync?.status ?? 'pending'}">
{statusText(a)}{#if a.sync}{` · ${a.sync.messages} message${a.sync.messages === 1 ? '' : 's'}`}{/if}
</span>
{#if a.sync?.status === 'error' && a.sync.last_error}
<span class="last-error">{a.sync.last_error}</span>
{/if}
{#if a.sync}<span class="detail">Last update {formatFullDate(a.sync.updated_at)}</span>{/if}
</div>
<div class="row-actions">
<button onclick={() => startEdit(a)} disabled={editing?.id === a.id}>Edit</button>
<button onclick={() => remove(a)}>Remove</button>
</div>
</li>
{/each}
</ul>
{/if}
{#if adding || editing}
<form onsubmit={save}>
<h3>
{#if editing}Edit {editing.email_address ?? editing.username}
{:else if accounts.length === 0}Connect your first mailbox
{:else}Add an account{/if}
</h3>
<label class="wide">Email address
<input type="email" bind:value={email} oninput={emailChanged} required autocomplete="email" />
</label>
<label class="wide">Your name <span class="optional">(optional, shown on mail you send)</span>
<input bind:value={displayName} autocomplete="name" />
</label>
<label>IMAP server
<input bind:value={imapHost} oninput={() => (hostsEdited = true)} required />
</label>
<label class="port">Port
<input type="number" min="1" max="65535" bind:value={imapPort} required />
</label>
<label>SMTP server
<input bind:value={smtpHost} oninput={() => (hostsEdited = true)} required />
</label>
<label class="port">Port
<input type="number" min="1" max="65535" bind:value={smtpPort} required />
</label>
<label class="wide">Login
<input bind:value={login} oninput={() => (loginEdited = true)} required autocomplete="username" />
</label>
<label class="wide">Password
<input
type="password"
bind:value={password}
required={!editing}
placeholder={editing ? 'unchanged — type a new one to replace it' : ''}
autocomplete={editing ? 'new-password' : 'current-password'}
/>
</label>
{#if editing}
<p class="hint wide">
Saving reconnects with the new settings. Mail already here stays as long as it's the same mailbox;
point it at a different one and it's synced afresh.
</p>
{/if}
<p class="hint wide">
Stored encrypted on your Tern server, never in this browser. Tern only reads your inbox and sends —
it never changes anything on the mail server.
</p>
{#if formError}<p class="error wide">{formError}</p>{/if}
<div class="actions wide">
{#if accounts.length > 0}
<button type="button" onclick={closeForm}>Cancel</button>
{/if}
<button type="submit" class="primary" disabled={saving}>
{saving ? 'Saving…' : editing ? 'Save changes' : 'Add account'}
</button>
</div>
</form>
{/if}
</div>
<style>
.accounts {
overflow-y: auto;
height: 100%;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1.25rem 1.25rem 0;
}
h2 {
margin: 0;
font-size: 1.1rem;
}
h3 {
grid-column: 1 / -1;
margin: 0 0 0.25rem;
font-size: 0.95rem;
}
.hint,
.error {
padding: 0 1.25rem;
font-size: 0.82rem;
color: var(--primary);
max-width: 48rem;
}
.error {
color: var(--accent);
}
ul {
list-style: none;
margin: 0;
padding: 0 1.25rem 1rem;
display: flex;
flex-direction: column;
gap: 0.4rem;
}
li {
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.7rem 0.75rem;
border: 1px solid var(--secondary);
border-radius: 0.45rem;
}
.row-actions {
display: flex;
gap: 0.4rem;
}
.body {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 0.15rem;
}
.detail {
font-size: 0.78rem;
color: var(--primary);
overflow-wrap: anywhere;
}
.status {
font-size: 0.82rem;
}
.status.state-error {
color: var(--accent);
}
.last-error {
font-family: ui-monospace, monospace;
font-size: 0.75rem;
color: var(--accent);
overflow-wrap: anywhere;
}
.dot {
flex-shrink: 0;
width: 0.6rem;
height: 0.6rem;
margin-top: 0.35rem;
border-radius: 50%;
border: 1px solid var(--primary);
}
.dot.state-idle {
background: var(--primary);
}
.dot.state-syncing {
border-style: dashed;
}
.dot.state-error {
background: var(--accent);
border-color: var(--accent);
}
form {
display: grid;
grid-template-columns: minmax(0, 1fr) 6rem;
gap: 0.6rem 0.75rem;
margin: 0 1.25rem 1.25rem;
padding: 1rem;
max-width: 34rem;
border: 1px solid var(--secondary);
border-radius: 0.45rem;
}
form .hint,
form .error {
padding: 0;
margin: 0;
}
.wide {
grid-column: 1 / -1;
}
label {
display: flex;
flex-direction: column;
gap: 0.25rem;
font-size: 0.8rem;
color: var(--primary);
}
.optional {
font-size: 0.72rem;
}
input {
font: inherit;
font-size: 0.88rem;
color: var(--text);
background: var(--background);
border: 1px solid var(--secondary);
border-radius: 0.3rem;
padding: 0.35rem 0.5rem;
}
.actions {
display: flex;
justify-content: flex-end;
gap: 0.4rem;
}
button {
font: inherit;
font-size: 0.82rem;
color: var(--text);
background: none;
border: 1px solid var(--secondary);
border-radius: 0.3rem;
padding: 0.25rem 0.6rem;
cursor: pointer;
}
button:disabled {
opacity: 0.4;
cursor: default;
}
.primary {
background: var(--accent);
border-color: var(--accent);
font-weight: 600;
}
</style>
+39 -3
View File
@@ -29,6 +29,7 @@
import ThreadView from './ThreadView.svelte';
import OutboxView from './OutboxView.svelte';
import RulesView from './RulesView.svelte';
import AccountsView from './AccountsView.svelte';
import ActionMenu from './ActionMenu.svelte';
import Compose from './Compose.svelte';
import ShortcutHelp from './ShortcutHelp.svelte';
@@ -48,7 +49,7 @@
let nextCursor = $state<string | null>(null);
let loadingMore = $state(false);
let outbox = $state<OutboxItem[]>([]);
let section = $state<'mail' | 'outbox' | 'rules'>('mail');
let section = $state<'mail' | 'outbox' | 'rules' | 'accounts'>('mail');
let mailView = $state<MailView>({ kind: 'inbox' });
let selected = $state<ThreadSummary | null>(null);
let threadMessages = $state<MessageDetail[]>([]);
@@ -64,6 +65,9 @@
let liveStatus = $state<LiveStatus>('connecting');
let alerts = $state<AlertState>(alertState());
let rulesReloadKey = $state(0);
let accountsReloadKey = $state(0);
/** Accounts have been fetched at least once (so "none" means none). */
let accountsLoaded = $state(false);
/** In-page notices for new mail; OS alerts replace them while the tab is hidden. */
let toasts = $state<{ key: number; threadId: string | null; from: string; subject: string }[]>([]);
let toastSeq = 0;
@@ -138,6 +142,15 @@
[folders, tags] = await Promise.all([listFolders(), listTags()]);
}
async function refreshAccounts() {
try {
accounts = await listAccounts();
accountsLoaded = true;
} catch {
// Non-critical here; the Accounts screen shows its own errors.
}
}
async function refreshOutbox() {
try {
outbox = await listOutbox();
@@ -148,7 +161,7 @@
function reloadAll() {
refreshMeta().catch(() => {});
listAccounts().then((a) => (accounts = a)).catch(() => {});
refreshAccounts();
refreshList();
refreshOutbox();
rulesReloadKey++;
@@ -181,7 +194,10 @@
outboxChanged = true;
break;
case 'config_changed':
if (e.data.what === 'accounts') listAccounts().then((a) => (accounts = a)).catch(() => {});
if (e.data.what === 'accounts') {
refreshAccounts();
accountsReloadKey++;
}
else if (e.data.what === 'rules') rulesReloadKey++;
else {
refreshMeta().catch(() => {});
@@ -545,6 +561,7 @@
<div class="bottom">
<button class:active={section === 'rules'} onclick={() => { section = 'rules'; selected = null; }}>Rules</button>
<button class:active={section === 'accounts'} onclick={() => { section = 'accounts'; selected = null; }}>Accounts</button>
{#if alerts === 'on' || alerts === 'off'}
<button class="help-hint" onclick={toggleAlerts} title="OS notifications for new mail while this tab is open">
{alerts === 'on' ? 'Desktop alerts: on' : 'Enable desktop alerts'}
@@ -565,6 +582,10 @@
<section class="wide-pane">
<RulesView {folders} {tags} reloadKey={rulesReloadKey} />
</section>
{:else if section === 'accounts'}
<section class="wide-pane">
<AccountsView reloadKey={accountsReloadKey} onChanged={() => { refreshAccounts(); refreshList(); }} />
</section>
{:else}
<section class="list-pane">
{#if section === 'outbox'}
@@ -574,6 +595,12 @@
{#if error}<p class="note error">{error}</p>{/if}
{#if loading}
<p class="note">Loading…</p>
{:else if accountsLoaded && accounts.length === 0}
<p class="note">
No mailbox connected yet.
<button class="link" onclick={() => { section = 'accounts'; selected = null; }}>Connect one</button>
and its mail will show up here.
</p>
{:else if threads.length === 0}
<p class="note">
{mailView.kind === 'inbox' ? 'Inbox zero.' : 'Nothing here.'}
@@ -823,6 +850,15 @@
color: var(--primary);
font-size: 0.9rem;
}
.link {
background: none;
border: none;
padding: 0;
font: inherit;
color: var(--accent);
text-decoration: underline;
cursor: pointer;
}
.error {
color: var(--accent);
}
+53 -1
View File
@@ -4,6 +4,13 @@
const SESSION_KEY = 'tern-session-token';
/**
* Where tern-server lives, fixed at build time (VITE_TERN_API). Deployed,
* the webapp and the API are separate origins; in development it's empty
* and Vite's proxy forwards /api on the same origin.
*/
export const API_ORIGIN = (import.meta.env.VITE_TERN_API ?? '').replace(/\/+$/, '');
export function getSessionToken(): string | null {
return localStorage.getItem(SESSION_KEY);
}
@@ -18,7 +25,7 @@ export function clearSessionToken(): void {
async function request<T>(path: string, init?: RequestInit): Promise<T> {
const token = getSessionToken();
const res = await fetch(`/api${path}`, {
const res = await fetch(`${API_ORIGIN}/api${path}`, {
...init,
headers: {
'Content-Type': 'application/json',
@@ -165,6 +172,34 @@ export interface Account {
username: string;
email_address: string | null;
display_name: string | null;
imap_host: string;
imap_port: number;
smtp_host: string;
smtp_port: number;
created_at: string;
/** Null until the sync engine first touches the account. */
sync: AccountSync | null;
}
export interface AccountSync {
status: 'pending' | 'syncing' | 'idle' | 'error';
last_error: string | null;
updated_at: string;
/** The first full pass over the mailbox has finished. */
caught_up: boolean;
messages: number;
}
export interface NewAccount {
name: string;
imap_host: string;
imap_port: number;
smtp_host: string;
smtp_port: number;
username: string;
password: string;
email_address: string | null;
display_name: string | null;
}
export type OutboxStatus = 'draft' | 'pending' | 'sending' | 'sent' | 'failed';
@@ -197,6 +232,23 @@ export function listAccounts(): Promise<Account[]> {
return request('/accounts');
}
export function createAccount(account: NewAccount): Promise<Account> {
return request('/accounts', { method: 'POST', body: JSON.stringify(account) });
}
/**
* Replaces an account's settings. Leave `password` empty to keep the
* stored one. The server restarts the account's sync with the new settings.
*/
export function updateAccount(id: string, account: NewAccount): Promise<Account> {
return request(`/accounts/${id}`, { method: 'PUT', body: JSON.stringify(account) });
}
/** Removes the account and every message synced from it. */
export function deleteAccount(id: string): Promise<{ ok: boolean }> {
return request(`/accounts/${id}`, { method: 'DELETE' });
}
export function markThreadRead(threadId: string): Promise<{ messages: number }> {
return request(`/threads/${threadId}/read`, { method: 'POST' });
}
+2 -2
View File
@@ -2,7 +2,7 @@
// polling the same event log while it isn't. Both carry the same cursor,
// so switching between them neither drops nor repeats a change.
import { getSessionToken, pollEvents, type LiveEvent } from './api';
import { API_ORIGIN, getSessionToken, pollEvents, type LiveEvent } from './api';
export type LiveStatus = 'connecting' | 'live' | 'polling';
@@ -55,7 +55,7 @@ export function startLive(handlers: LiveHandlers): () => void {
return;
}
handlers.onStatus(cursor === null ? 'connecting' : 'polling');
const url = new URL('/api/ws', location.href);
const url = new URL('/api/ws', API_ORIGIN || location.href);
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = new WebSocket(url);
socket = ws;
+5
View File
@@ -1,2 +1,7 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />
interface ImportMetaEnv {
/** tern-server's origin, e.g. https://tern-api.mtps.pl. Empty: same origin. */
readonly VITE_TERN_API?: string;
}