Skip to content

Commit 17e22b3

Browse files
grauxmusicclaude
andcommitted
fix(companion-win): register watermorph:// protocol + handle open-url
- app.setAsDefaultProtocolClient('watermorph') for runtime registration - electron-builder protocols config for NSIS installer registry write - handle watermorph:// deep-link in second-instance + open-url events Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2c81627 commit 17e22b3

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

CompanionWin/main.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const kUA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (
1717
const gotLock = app.requestSingleInstanceLock()
1818
if (!gotLock) { app.quit(); process.exit(0) }
1919

20+
// Register watermorph:// protocol handler (runtime fallback — installer also handles this)
21+
app.setAsDefaultProtocolClient('watermorph')
22+
2023
// ── State ────────────────────────────────────────────────────────────────────
2124

2225
let win = null
@@ -213,10 +216,22 @@ app.whenReady().then(() => {
213216
registerAutostart()
214217
})
215218

216-
app.on('second-instance', () => {
219+
app.on('second-instance', (_event, argv) => {
220+
// Handle watermorph:// deep-link from second instance
221+
const url = argv.find((a) => a.startsWith('watermorph://'))
222+
if (url) handleProtocolUrl(url)
217223
if (win) { win.show(); win.focus() }
218224
})
219225

226+
app.on('open-url', (_event, url) => {
227+
handleProtocolUrl(url)
228+
})
229+
230+
function handleProtocolUrl(url) {
231+
if (!url.startsWith('watermorph://')) return
232+
if (win) { win.show(); win.focus() }
233+
}
234+
220235
app.on('window-all-closed', (e) => {
221236
e.preventDefault() // Keep running in tray
222237
})

CompanionWin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"appId": "ai.95ent.watermorph.helper",
1313
"productName": "Water Morph",
1414
"publish": null,
15+
"protocols": [
16+
{ "name": "Water Morph", "schemes": ["watermorph"] }
17+
],
1518
"win": {
1619
"target": [{ "target": "nsis", "arch": ["x64"] }],
1720
"artifactName": "Water_Morph_1.0.0_Windows.exe"

0 commit comments

Comments
 (0)