From 63c8b44761517b947d3ac9eedf3f3a630153a22b Mon Sep 17 00:00:00 2001
From: mapxn <16299874+mapxn@users.noreply.github.com>
Date: Mon, 30 Nov 2026 12:49:34 +0800
Subject: [PATCH 1/2] chore: checkpoint sc_a8ZQmr9SlKt9x4j1IS
---
web/src/components/ConnectionStringFields.tsx | 30 ++++++++++++++
web/src/components/DatabaseForm.tsx | 9 ++++
.../__tests__/connectionStringFields.test.tsx | 13 ++++++
web/src/lib/__tests__/databaseForm.test.ts | 41 +++++++++++++++++++
web/src/lib/api.ts | 2 +
web/src/lib/database-form.ts | 22 ++++++++--
web/src/lib/translations.ts | 4 ++
web/src/types.ts | 2 +
8 files changed, 119 insertions(+), 4 deletions(-)
diff --git a/web/src/components/ConnectionStringFields.tsx b/web/src/components/ConnectionStringFields.tsx
index 190677c5..d43d820e 100644
--- a/web/src/components/ConnectionStringFields.tsx
+++ b/web/src/components/ConnectionStringFields.tsx
@@ -24,6 +24,8 @@ interface Props {
historyUrl?: string
/** Spark only: optional History Server platform token. */
historyPlatformToken?: string
+ /** Spark only: optional Worker UI publish link (the full `?_token=` link). */
+ workerUrl?: string
testState: ConnectionTestState
/** Error text of a failed test, shown verbatim unless it carries a translatable code. */
testError: string
@@ -38,6 +40,7 @@ interface Props {
onLivyPlatformTokenChange?: (token: string) => void
onHistoryUrlChange?: (url: string) => void
onHistoryPlatformTokenChange?: (token: string) => void
+ onWorkerUrlChange?: (url: string) => void
onTest: () => void
/**
* Editing a saved registration: the stored values never come back, so every field starts empty
@@ -56,6 +59,7 @@ type Field =
| 'livyPlatform'
| 'historyUrl'
| 'historyPlatform'
+ | 'workerUrl'
function RevealToggle({ revealed, label, onToggle }: { revealed: boolean; label: string; onToggle: () => void }) {
return (
@@ -88,6 +92,7 @@ export default function ConnectionStringFields({
livyPlatformToken = '',
historyUrl = '',
historyPlatformToken = '',
+ workerUrl = '',
testState,
testError,
testInfo,
@@ -100,6 +105,7 @@ export default function ConnectionStringFields({
onLivyPlatformTokenChange,
onHistoryUrlChange,
onHistoryPlatformTokenChange,
+ onWorkerUrlChange,
onTest,
editing = false,
}: Props) {
@@ -114,6 +120,7 @@ export default function ConnectionStringFields({
livyPlatform: false,
historyUrl: false,
historyPlatform: false,
+ workerUrl: false,
})
const toggle = (field: Field) => setRevealed((current) => ({ ...current, [field]: !current[field] }))
const testing = testState === 'testing'
@@ -395,6 +402,29 @@ export default function ConnectionStringFields({
{t('admin_db.history_pair_hint')}
)}
+
+
+
+
+ onWorkerUrlChange?.(e.target.value)}
+ placeholder={t(editing ? 'admin_db.connection_unchanged' : 'admin_db.worker_url_placeholder')}
+ autoComplete="off"
+ spellCheck={false}
+ />
+ toggle('workerUrl')}
+ />
+
+
>
)}
diff --git a/web/src/components/DatabaseForm.tsx b/web/src/components/DatabaseForm.tsx
index 7bb1365a..7d12d88c 100644
--- a/web/src/components/DatabaseForm.tsx
+++ b/web/src/components/DatabaseForm.tsx
@@ -63,6 +63,7 @@ export default function DatabaseForm({ mode, database, available, onSaved, onCan
const [livyPlatformToken, setLivyPlatformToken] = useState('')
const [historyUrl, setHistoryUrl] = useState('')
const [historyPlatformToken, setHistoryPlatformToken] = useState('')
+ const [workerUrl, setWorkerUrl] = useState('')
const [testState, setTestState] = useState('idle')
const [testedSignature, setTestedSignature] = useState(null)
const [testError, setTestError] = useState('')
@@ -93,6 +94,7 @@ export default function DatabaseForm({ mode, database, available, onSaved, onCan
setLivyPlatformToken('')
setHistoryUrl('')
setHistoryPlatformToken('')
+ setWorkerUrl('')
invalidateTest()
setFormError('')
}
@@ -136,6 +138,10 @@ export default function DatabaseForm({ mode, database, available, onSaved, onCan
setHistoryPlatformToken(next)
}
+ function changeWorkerUrl(next: string) {
+ setWorkerUrl(next)
+ }
+
async function testConnection() {
if (testState === 'testing' || !isConnectionKind(activeKind)) return
const signature = connectionSignature({ kind: activeKind, url, platformToken, appToken })
@@ -174,6 +180,7 @@ export default function DatabaseForm({ mode, database, available, onSaved, onCan
livyPlatformToken,
historyUrl,
historyPlatformToken,
+ workerUrl,
}
const canSave = canSaveForm({
mode,
@@ -286,6 +293,7 @@ export default function DatabaseForm({ mode, database, available, onSaved, onCan
livyPlatformToken={livyPlatformToken}
historyUrl={historyUrl}
historyPlatformToken={historyPlatformToken}
+ workerUrl={workerUrl}
editing={editing}
testState={testState}
testError={testError}
@@ -299,6 +307,7 @@ export default function DatabaseForm({ mode, database, available, onSaved, onCan
onLivyPlatformTokenChange={changeLivyPlatformToken}
onHistoryUrlChange={changeHistoryUrl}
onHistoryPlatformTokenChange={changeHistoryPlatformToken}
+ onWorkerUrlChange={changeWorkerUrl}
onTest={testConnection}
/>
) : (
diff --git a/web/src/lib/__tests__/connectionStringFields.test.tsx b/web/src/lib/__tests__/connectionStringFields.test.tsx
index 73df0a75..338ef2bb 100644
--- a/web/src/lib/__tests__/connectionStringFields.test.tsx
+++ b/web/src/lib/__tests__/connectionStringFields.test.tsx
@@ -68,6 +68,9 @@ describe('ConnectionStringFields', () => {
expect(html).toContain('id="db-history-platform-token" type="password"')
expect(html).toContain(t('admin_db.history_url'))
expect(html).toContain(t('admin_db.history_platform_token'))
+ // Worker UI publish link
+ expect(html).toContain('id="db-worker-url" type="password"')
+ expect(html).toContain(t('admin_db.worker_url'))
// No SQL connection-string copy leaks into the Spark form
expect(html).not.toContain(t('admin_db.connection_url_hint'))
expect(html).not.toContain('type="password" data-reveal')
@@ -79,12 +82,14 @@ describe('ConnectionStringFields', () => {
expect(pgHtml).not.toContain('id="db-spark-ui-platform-token"')
expect(pgHtml).not.toContain('id="db-history-url"')
expect(pgHtml).not.toContain('id="db-history-platform-token"')
+ expect(pgHtml).not.toContain('id="db-worker-url"')
const mysqlHtml = render({ kind: 'mysql', url: 'mysql://u:p@host/db' })
expect(mysqlHtml).not.toContain('id="db-spark-ui-url"')
expect(mysqlHtml).not.toContain('id="db-spark-ui-platform-token"')
expect(mysqlHtml).not.toContain('id="db-history-url"')
expect(mysqlHtml).not.toContain('id="db-history-platform-token"')
+ expect(mysqlHtml).not.toContain('id="db-worker-url"')
})
it('masks the Spark UI publish address in edit mode and offers a reveal toggle', () => {
@@ -93,6 +98,14 @@ describe('ConnectionStringFields', () => {
expect(html).toContain('id="db-spark-ui-platform-token" type="password"')
expect(html).toContain('id="db-history-url" type="password"')
expect(html).toContain('id="db-history-platform-token" type="password"')
+ expect(html).toContain('id="db-worker-url" type="password"')
+ })
+
+ it('masks the Worker UI publish link because it carries the token', () => {
+ const html = render({ kind: 'spark', workerUrl: 'https://worker-ui.example.com/?_token=secret' })
+ expect(html).toContain('id="db-worker-url" type="password"')
+ expect(html).toContain(t('admin_db.show_connection_url'))
+ expect(html).toContain(t('admin_db.worker_url'))
})
it('shows pair validation alert only when exactly one History Server field is filled', () => {
diff --git a/web/src/lib/__tests__/databaseForm.test.ts b/web/src/lib/__tests__/databaseForm.test.ts
index c97a988a..fa64f680 100644
--- a/web/src/lib/__tests__/databaseForm.test.ts
+++ b/web/src/lib/__tests__/databaseForm.test.ts
@@ -10,6 +10,7 @@ import {
sparkLivyTouched,
sparkUiPairValid,
sparkUiTouched,
+ workerUrlTouched,
} from '../database-form'
import { connectionSignature } from '../connection-string'
@@ -63,6 +64,17 @@ describe('sparkHistoryTouched', () => {
})
})
+describe('workerUrlTouched', () => {
+ it('is false while the publish link stays blank', () => {
+ expect(workerUrlTouched(untouched)).toBe(false)
+ expect(workerUrlTouched({ ...untouched, workerUrl: ' ' })).toBe(false)
+ })
+
+ it('is true once the publish link has text', () => {
+ expect(workerUrlTouched({ ...untouched, workerUrl: 'https://worker-ui.example.com/?_token=t' })).toBe(true)
+ })
+})
+
describe('sparkUiPairValid', () => {
it('is true when both are empty or undefined', () => {
expect(sparkUiPairValid()).toBe(true)
@@ -484,6 +496,35 @@ describe('connectionPatch', () => {
})
).toBe(null)
})
+
+ it('includes the trimmed Worker UI publish link when present', () => {
+ expect(
+ connectionPatch('spark', {
+ url: 'https://spark.example.com',
+ platformToken: 'p',
+ appToken: 'a',
+ workerUrl: ' https://worker-ui.example.com/?_token=t ',
+ })
+ ).toEqual({
+ connection_url: 'https://spark.example.com',
+ platform_token: 'p',
+ app_token: 'a',
+ worker_url: 'https://worker-ui.example.com/?_token=t',
+ })
+ })
+
+ it('sends only the Worker UI publish link in edit mode when the connection is untouched', () => {
+ expect(
+ connectionPatch('spark', {
+ url: '',
+ platformToken: '',
+ appToken: '',
+ workerUrl: 'https://worker-ui.example.com/?_token=t',
+ })
+ ).toEqual({
+ worker_url: 'https://worker-ui.example.com/?_token=t',
+ })
+ })
})
describe('providerPrefill', () => {
diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts
index c363b307..29c670ca 100644
--- a/web/src/lib/api.ts
+++ b/web/src/lib/api.ts
@@ -511,6 +511,7 @@ export const adminApi = {
livy_platform_token?: string
history_url?: string
history_platform_token?: string
+ worker_url?: string
cf_database_id?: string
name?: string
description?: string
@@ -533,6 +534,7 @@ export const adminApi = {
livy_platform_token?: string
history_url?: string
history_platform_token?: string
+ worker_url?: string
}
) => apiFetch<{ message: string }>(`/admin/databases/${id}`, { method: 'PATCH', body: JSON.stringify(body) }),
deleteDatabase: (id: string) => apiFetch<{ message: string }>(`/admin/databases/${id}`, { method: 'DELETE' }),
diff --git a/web/src/lib/database-form.ts b/web/src/lib/database-form.ts
index 9f17f93f..b83b8070 100644
--- a/web/src/lib/database-form.ts
+++ b/web/src/lib/database-form.ts
@@ -31,6 +31,8 @@ export interface ConnectionValues {
historyUrl?: string
/** Spark only: optional History Server platform token. */
historyPlatformToken?: string
+ /** Spark only: optional Worker UI publish link (the full `?_token=` link; the worker splits it). */
+ workerUrl?: string
}
/**
@@ -63,6 +65,11 @@ export function sparkHistoryTouched(values: ConnectionValues): boolean {
return [values.historyUrl, values.historyPlatformToken].some((v) => (v?.trim() ?? '') !== '')
}
+/** Whether the admin typed the Worker UI publish link. */
+export function workerUrlTouched(values: ConnectionValues): boolean {
+ return (values.workerUrl?.trim() ?? '') !== ''
+}
+
/**
* Spark UI publish address and platform token travel as a pair: both filled, or both left blank.
* Filling only one is an incomplete pair that the server refuses with 400.
@@ -141,21 +148,24 @@ export interface ConnectionPatch {
livy_platform_token?: string
history_url?: string
history_platform_token?: string
+ worker_url?: string
}
/**
* The connection part of an edit's PATCH body, or null when every field was left blank (the stored
- * registration stays as it is). Spark's three connection values travel as one group, and its two
- * optional UI values travel as another group; a partial fill in either group yields null — the form's
- * gate already refuses to save that.
+ * registration stays as it is). Spark's three connection values travel as one group, each optional
+ * UI endpoint (Spark UI, Livy, History Server) travels as its own URL/token pair, and the Worker UI
+ * travels as a single publish link; a partial fill yields null — the form's gate already refuses to
+ * save that.
*/
export function connectionPatch(kind: ConnectionKind, values: ConnectionValues): ConnectionPatch | null {
const touched = connectionTouched(values)
const uiTouched = kind === 'spark' && sparkUiTouched(values)
const livyTouched = kind === 'spark' && sparkLivyTouched(values)
const historyTouched = kind === 'spark' && sparkHistoryTouched(values)
+ const workerTouched = kind === 'spark' && workerUrlTouched(values)
- if (!touched && !uiTouched && !livyTouched && !historyTouched) return null
+ if (!touched && !uiTouched && !livyTouched && !historyTouched && !workerTouched) return null
if (touched && connectionSignature({ kind, ...values }) === null) return null
if (uiTouched && !sparkUiPairValid(values.uiUrl, values.uiPlatformToken)) return null
if (livyTouched && !sparkLivyPairValid(values.livyUrl, values.livyPlatformToken)) return null
@@ -186,5 +196,9 @@ export function connectionPatch(kind: ConnectionKind, values: ConnectionValues):
result.history_platform_token = values.historyPlatformToken.trim()
}
+ if (workerTouched && values.workerUrl) {
+ result.worker_url = values.workerUrl.trim()
+ }
+
return result
}
diff --git a/web/src/lib/translations.ts b/web/src/lib/translations.ts
index e1f8e4da..1fd5f8f3 100644
--- a/web/src/lib/translations.ts
+++ b/web/src/lib/translations.ts
@@ -337,6 +337,8 @@ export const translations: Record> = {
'admin_db.history_url_placeholder': 'https://your-history-server.example.com',
'admin_db.history_platform_token': 'History Server platform token',
'admin_db.history_pair_hint': 'History Server publish address and platform token must both be provided.',
+ 'admin_db.worker_url': 'Worker UI publish link',
+ 'admin_db.worker_url_placeholder': 'https://your-worker-ui.example.com/?_token=…',
'admin_db.register_title_spark': 'Register a SparkSQL data source',
'admin_db.register_desc_spark':
'The whole SparkSQL service is one data source. Paste its publish address and the two tokens; it is tested live before it is stored, and a failed test saves nothing.',
@@ -920,6 +922,8 @@ export const translations: Record> = {
'admin_db.history_url_placeholder': 'https://你的-history-server-服务地址',
'admin_db.history_platform_token': 'History Server 平台令牌',
'admin_db.history_pair_hint': 'History Server 发布地址与平台令牌需同时填写。',
+ 'admin_db.worker_url': 'Worker UI 发布链接',
+ 'admin_db.worker_url_placeholder': 'https://你的-worker-ui-服务地址/?_token=…',
'admin_db.register_title_spark': '登记 SparkSQL 数据源',
'admin_db.register_desc_spark':
'整个 SparkSQL 服务就是一个数据源。粘贴发布地址与两枚令牌,保存前会实连测试一次,测试不通过不会落库。',
diff --git a/web/src/types.ts b/web/src/types.ts
index 18bf1c79..eb021f76 100644
--- a/web/src/types.ts
+++ b/web/src/types.ts
@@ -33,6 +33,7 @@ export interface Database {
has_spark_ui?: boolean
has_livy?: boolean
has_history_server?: boolean
+ has_worker_ui?: boolean
}
// A registered database as the admin API returns it
@@ -52,6 +53,7 @@ export interface AdminDatabase {
has_spark_ui?: boolean
has_livy?: boolean
has_history_server?: boolean
+ has_worker_ui?: boolean
}
export interface LivyBatch {
From 23c439140a4994045ecc31e52601a0e8dc5a731d Mon Sep 17 00:00:00 2001
From: mapxn <16299874+mapxn@users.noreply.github.com>
Date: Mon, 30 Nov 2026 13:05:52 +0800
Subject: [PATCH 2/2] chore: checkpoint xDqUBd47KSqAiHtQQX7lz
---
web/src/lib/__tests__/databaseForm.test.ts | 4 ++--
web/src/lib/api.ts | 4 ++--
web/src/lib/database-form.ts | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/web/src/lib/__tests__/databaseForm.test.ts b/web/src/lib/__tests__/databaseForm.test.ts
index fa64f680..124cb504 100644
--- a/web/src/lib/__tests__/databaseForm.test.ts
+++ b/web/src/lib/__tests__/databaseForm.test.ts
@@ -509,7 +509,7 @@ describe('connectionPatch', () => {
connection_url: 'https://spark.example.com',
platform_token: 'p',
app_token: 'a',
- worker_url: 'https://worker-ui.example.com/?_token=t',
+ worker_ui_url: 'https://worker-ui.example.com/?_token=t',
})
})
@@ -522,7 +522,7 @@ describe('connectionPatch', () => {
workerUrl: 'https://worker-ui.example.com/?_token=t',
})
).toEqual({
- worker_url: 'https://worker-ui.example.com/?_token=t',
+ worker_ui_url: 'https://worker-ui.example.com/?_token=t',
})
})
})
diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts
index 29c670ca..45df1b9a 100644
--- a/web/src/lib/api.ts
+++ b/web/src/lib/api.ts
@@ -511,7 +511,7 @@ export const adminApi = {
livy_platform_token?: string
history_url?: string
history_platform_token?: string
- worker_url?: string
+ worker_ui_url?: string
cf_database_id?: string
name?: string
description?: string
@@ -534,7 +534,7 @@ export const adminApi = {
livy_platform_token?: string
history_url?: string
history_platform_token?: string
- worker_url?: string
+ worker_ui_url?: string
}
) => apiFetch<{ message: string }>(`/admin/databases/${id}`, { method: 'PATCH', body: JSON.stringify(body) }),
deleteDatabase: (id: string) => apiFetch<{ message: string }>(`/admin/databases/${id}`, { method: 'DELETE' }),
diff --git a/web/src/lib/database-form.ts b/web/src/lib/database-form.ts
index b83b8070..cf182c5f 100644
--- a/web/src/lib/database-form.ts
+++ b/web/src/lib/database-form.ts
@@ -148,7 +148,7 @@ export interface ConnectionPatch {
livy_platform_token?: string
history_url?: string
history_platform_token?: string
- worker_url?: string
+ worker_ui_url?: string
}
/**
@@ -197,7 +197,7 @@ export function connectionPatch(kind: ConnectionKind, values: ConnectionValues):
}
if (workerTouched && values.workerUrl) {
- result.worker_url = values.workerUrl.trim()
+ result.worker_ui_url = values.workerUrl.trim()
}
return result