Skip to content

Commit 9894984

Browse files
Address copilot pass 3 on #2
- doctor.js: snippet target shown to the user is the document URL (fragmentless) — that's the actual PUT/PATCH target. The VM's controller still uses the WebID-with-fragment. Threaded docUrl through renderSnippet alongside webId. - doctor.js: clearSignerOutput now resets the connect-button label and copy status, so a re-run of diagnostics doesn't leave stale "Reconnect signer" / copy text behind. - doctor.css: dropped dead "#snippet pre" rule (snippet IS the code inside the pre, so the descendant selector matches nothing).
1 parent 1b7f0ce commit 9894984

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

doctor.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,6 @@ a { color: var(--accent); }
300300
white-space: pre;
301301
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
302302
}
303-
#snippet pre, .add-key pre {
303+
.add-key pre {
304304
margin: 0;
305305
}

doctor.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const copyButton = document.getElementById('copy-snippet');
3030
const copyStatus = document.getElementById('copy-status');
3131

3232
let lastWebId = null;
33+
let lastDocUrl = null;
3334

3435
// Allow ?webid=… in the URL to pre-fill (handy for sharing / bookmarks).
3536
const params = new URLSearchParams(window.location.search);
@@ -53,10 +54,11 @@ form.addEventListener('submit', async (e) => {
5354
results.hidden = false;
5455

5556
try {
56-
const { checks, profileFetched, webId } = await runAll(url);
57+
const { checks, profileFetched, webId, docUrl } = await runAll(url);
5758
renderChecks(checks);
5859
if (profileFetched && webId) {
5960
lastWebId = webId;
61+
lastDocUrl = docUrl;
6062
revealAddKeySection();
6163
} else {
6264
hideAddKeySection();
@@ -178,12 +180,9 @@ function revealAddKeySection() {
178180

179181
function hideAddKeySection() {
180182
addKeySection.hidden = true;
181-
signerOutput.hidden = true;
182-
pubkeyHexEl.textContent = '';
183-
pubkeyMbEl.textContent = '';
184-
snippetEl.textContent = '';
185-
snippetTarget.textContent = '';
183+
clearSignerOutput();
186184
lastWebId = null;
185+
lastDocUrl = null;
187186
}
188187

189188
function clearSignerOutput() {
@@ -192,6 +191,8 @@ function clearSignerOutput() {
192191
pubkeyMbEl.textContent = '';
193192
snippetEl.textContent = '';
194193
snippetTarget.textContent = '';
194+
connectButton.textContent = 'Connect signer';
195+
copyStatus.textContent = '';
195196
}
196197

197198
function detectSigner() {
@@ -219,23 +220,25 @@ connectButton.addEventListener('click', async () => {
219220
if (!/^[0-9a-f]{64}$/i.test(xOnlyHex)) {
220221
throw new Error(`Signer returned an unexpected pubkey: ${xOnlyHex}`);
221222
}
222-
renderSnippet(xOnlyHex, lastWebId);
223+
renderSnippet(xOnlyHex, lastWebId, lastDocUrl);
223224
signerOutput.hidden = false;
224225
setSignerStatus('ready', 'Connected. The snippet below is ready to paste into your profile.');
226+
connectButton.textContent = 'Reconnect signer';
225227
} catch (err) {
226228
clearSignerOutput();
227229
setSignerStatus('error', `Could not read pubkey: ${err.message || err}`);
228230
} finally {
229-
connectButton.textContent = 'Reconnect signer';
230231
connectButton.disabled = false;
231232
}
232233
});
233234

234-
function renderSnippet(xOnlyHex, webId) {
235+
function renderSnippet(xOnlyHex, webId, docUrl) {
235236
const vm = buildNostrVerificationMethod({ webId, xOnlyHex });
236237
pubkeyHexEl.textContent = xOnlyHex;
237238
pubkeyMbEl.textContent = vm.publicKeyMultibase;
238-
snippetTarget.textContent = vm.controller;
239+
// Write target is the document URL (no fragment) — you can't PUT/PATCH
240+
// a fragment URI. The VM's `controller` keeps the WebID-with-fragment.
241+
snippetTarget.textContent = docUrl;
239242

240243
// Show the three additions a CID v1 profile needs together: the
241244
// verificationMethod itself, plus authentication / assertionMethod

0 commit comments

Comments
 (0)