From 48360631e25dc782251aaf8c73d5bb8359d5a2d4 Mon Sep 17 00:00:00 2001 From: HugoXK <87640074+HugoXK@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:34:04 +0800 Subject: [PATCH 1/2] docs(site): move the chat footer to a risk notice and add Stop/Retry The chat footer now says what a reader needs (third-party, model-generated, verify the source) instead of "MCP setup"; MCP lives behind the header info icon and the /deepwiki/ page. Follow-ups include the last two Q/A turns, the typing state can be stopped, failures can be retried, and the composer respects the mobile safe area. --- docs/assets/deepwiki.css | 26 ++++++++++++++---- docs/assets/deepwiki.js | 58 +++++++++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 14 deletions(-) diff --git a/docs/assets/deepwiki.css b/docs/assets/deepwiki.css index 31056049..840449b2 100644 --- a/docs/assets/deepwiki.css +++ b/docs/assets/deepwiki.css @@ -95,6 +95,7 @@ body:has(.experience[data-theme="dark"]) .dw-panel { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--dw-muted); display: grid; place-items: center; cursor: pointer; + text-decoration: none; } .dw-icon-btn:hover { background: var(--dw-soft); color: var(--dw-ink); } .dw-icon-btn svg { width: 16px; height: 16px; } @@ -114,7 +115,7 @@ body:has(.experience[data-theme="dark"]) .dw-panel { .dw-log { flex: 1; min-height: 200px; max-height: 430px; overflow: auto; display: flex; flex-direction: column; gap: .75rem; - padding: .9rem; scroll-behavior: smooth; + padding: .9rem; scroll-behavior: smooth; overscroll-behavior: contain; } .dw-empty { padding: .35rem .2rem; text-align: left; } @@ -191,7 +192,13 @@ body:has(.experience[data-theme="dark"]) .dw-md a { color: var(--dw-accent); } border-left: 2px solid #9ec363; color: var(--dw-muted); } -.dw-thinking .dw-bubble { display: flex; align-items: center; gap: .45rem; color: var(--dw-muted); } +.dw-thinking .dw-bubble { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; color: var(--dw-muted); } +.dw-stop { + margin-left: auto; padding: 0; border: 0; background: transparent; + color: var(--dw-muted); font: 600 .58rem/1.2 inherit; + text-decoration: underline; cursor: pointer; +} +.dw-stop:hover { color: var(--dw-ink); } .dw-dots { display: inline-flex; gap: 3px; } .dw-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dw-blink 1.2s infinite; } .dw-dots i:nth-child(2) { animation-delay: .15s; } @@ -202,6 +209,13 @@ body:has(.experience[data-theme="dark"]) .dw-md a { color: var(--dw-accent); } body[data-md-color-scheme="slate"] .dw-error, body:has(.experience[data-theme="dark"]) .dw-error { color: #ff9d8a; } .dw-error a { color: inherit; font-weight: 700; } +.dw-retry { + margin-top: .45rem; padding: .3rem .55rem; + border: 1px solid var(--dw-line); border-radius: 6px; + background: var(--dw-paper); color: var(--dw-ink); + font: 650 .62rem/1.2 inherit; cursor: pointer; +} +.dw-retry:hover { border-color: #8aaa4c; } .dw-form { padding: .65rem .9rem .55rem; border-top: 1px solid var(--dw-line); background: var(--dw-paper); } .dw-input-wrap { @@ -223,10 +237,11 @@ body:has(.experience[data-theme="dark"]) .dw-error { color: #ff9d8a; } .dw-send:disabled { opacity: .45; cursor: wait; } .dw-send svg { width: 15px; height: 15px; } .dw-hint { - display: flex; justify-content: space-between; gap: .5rem; - padding: .4rem .1rem 0; color: var(--dw-muted); font-size: .58rem; line-height: 1.4; + display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .35rem .5rem; + padding: .4rem .1rem 0; color: var(--dw-muted); font-size: .58rem; line-height: 1.45; } -.dw-hint a { color: inherit; text-decoration: underline; } +.dw-hint span { max-width: 32em; } +.dw-hint a { color: inherit; text-decoration: underline; white-space: nowrap; } /* Never float over Material's search overlay. */ body:has(#__search:checked) .dw-launcher, @@ -236,6 +251,7 @@ body:has(#__search:checked) .dw-panel { display: none !important; } body:has(.experience) .md-top { display: none !important; } @media (max-width: 650px) { + .dw-form { padding-bottom: calc(.55rem + env(safe-area-inset-bottom)); } .dw-launcher { right: .75rem; bottom: .75rem; width: 54px; height: 54px; padding: 0; justify-content: center; border-radius: 50%; diff --git a/docs/assets/deepwiki.js b/docs/assets/deepwiki.js index d9621021..fba64eff 100644 --- a/docs/assets/deepwiki.js +++ b/docs/assets/deepwiki.js @@ -11,7 +11,8 @@ spark: '', refresh: '', close: '', - send: '' + send: '', + info: '' }; var launcher = document.createElement('button'); @@ -35,6 +36,7 @@ '
', '
DeepWiki' + REPO + '
', '
', + '' + icons.info + '', '', '', '
', @@ -57,7 +59,7 @@ '', '', '', - '
Enter to send \u00b7 model-generatedMCP setup
', + '
DeepWiki is third-party and model-generated. Verify load-bearing answers against the source.Caveats
', '' ].join(''); @@ -72,6 +74,8 @@ var newChat = panel.querySelector('#dw-new'); var emptyTemplate = log.querySelector('.dw-empty').cloneNode(true); var busy = false; + var history = []; + var controller = null; function scroll() { log.scrollTop = log.scrollHeight; } function openPanel() { @@ -93,6 +97,8 @@ }); } function resetChat() { + if (controller) { controller.abort(); controller = null; } + history = []; while (log.firstChild) log.removeChild(log.firstChild); var empty = emptyTemplate.cloneNode(true); log.appendChild(empty); @@ -240,18 +246,29 @@ function thinking() { var row = document.createElement('div'); row.className = 'dw-msg dw-bot dw-thinking'; - row.innerHTML = 'DW
Searching the index\u2026
'; + row.innerHTML = 'DW
Searching the index\u2026
'; log.appendChild(row); scroll(); return row; } - function error(text) { + function error(text, question) { var row = message('bot', text); row.querySelector('.dw-bubble').classList.add('dw-error'); var link = document.createElement('p'); link.innerHTML = 'Open the DeepWiki page \u2197'; row.querySelector('.dw-md').appendChild(link); + if (question) { + var retry = document.createElement('button'); + retry.type = 'button'; + retry.className = 'dw-retry'; + retry.textContent = 'Retry'; + retry.addEventListener('click', function () { + row.remove(); + ask(question); + }); + row.querySelector('.dw-md').appendChild(retry); + } scroll(); } @@ -273,7 +290,7 @@ return last; } - function call(question) { + function call(question, signal) { var body = { jsonrpc: '2.0', id: 1, @@ -286,7 +303,8 @@ return fetch(ENDPOINT, { method: 'POST', headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream' }, - body: JSON.stringify(body) + body: JSON.stringify(body), + signal: signal }).then(function (response) { if (!response.ok) throw new Error('DeepWiki returned HTTP ' + response.status); return response.text(); @@ -309,13 +327,35 @@ if (empty) empty.remove(); message('user', question); var pending = thinking(); - call(question).then(function (result) { + var stop = pending.querySelector('.dw-stop'); + if (stop) stop.addEventListener('click', function () { + if (controller) controller.abort(); + }); + var context = history.slice(-2).map(function (item) { + return 'Q: ' + item.q + '\nA: ' + item.a.slice(0, 900); + }).join('\n\n'); + var prompt = context + ? 'Previous conversation for context:\n' + context + '\n\nNew question: ' + question + : question; + controller = ('AbortController' in window) ? new AbortController() : null; + call(prompt, controller ? controller.signal : undefined).then(function (result) { if (pending.parentNode) pending.remove(); - if (result.ok) message('bot', result.text); else error(result.text); + if (result.ok) { + history.push({ q: question, a: result.text }); + if (history.length > 4) history.shift(); + message('bot', result.text); + } else { + error(result.text, question); + } }).catch(function (failure) { if (pending.parentNode) pending.remove(); - error('DeepWiki is unavailable right now: ' + failure.message); + if (failure && failure.name === 'AbortError') { + error('Stopped. Ask again when you are ready.', question); + } else { + error('DeepWiki is unavailable right now: ' + failure.message, question); + } }).then(function () { + controller = null; busy = false; send.disabled = false; input.focus(); From befe7053e08d4e46ed4bf6abbc4eaf7abf094ceb Mon Sep 17 00:00:00 2001 From: HugoXK Date: Thu, 19 Nov 2026 10:00:35 +0000 Subject: [PATCH 2/2] fix(docs): derive the DeepWiki caveats link from the script URL GitHub Pages serves the docs under /agentdescent/, while CI and a local build serve them at /. The chat panel's header info link and footer "Caveats" link were root-absolute (/deepwiki/), so they 404 on Pages and no local run can see it. Take the site root from the loaded assets/deepwiki.js script instead and build /deepwiki/ from it, so both links resolve under a subpath and at the root. Without a script element there is no safe base, so the two anchors are omitted rather than pointed at a literal that 404s. Only the link base changes: no credentials are added, and the escaping order in inline()/escapeHtml is untouched. --- docs/assets/deepwiki.js | 13 +++++++++++-- tests/test_site_navigation.py | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/assets/deepwiki.js b/docs/assets/deepwiki.js index fba64eff..0145b609 100644 --- a/docs/assets/deepwiki.js +++ b/docs/assets/deepwiki.js @@ -5,6 +5,15 @@ var REPO = 'ThinkFlowLab/agentdescent'; var ENDPOINT = 'https://mcp.deepwiki.com/mcp'; var PAGE = 'https://deepwiki.com/' + REPO; + + // GitHub Pages serves this site under /agentdescent/, a local build sits at /, + // and only Pages punishes a root-absolute href. Derive the base from this + // script's own URL so the in-panel links resolve in both places. With no + // script element there is no safe base, so the two anchors are left out + // instead of falling back to a literal that 404s on Pages. + var SELF = document.currentScript || document.querySelector('script[src$="assets/deepwiki.js"]'); + var GUIDE = SELF ? new URL('../deepwiki/', SELF.src).href : null; + var icons = { chat: '', logo: '', @@ -36,7 +45,7 @@ '
', '
DeepWiki' + REPO + '
', '
', - '' + icons.info + '', + (GUIDE ? '' + icons.info + '' : ''), '', '', '
', @@ -59,7 +68,7 @@ '', '', '', - '
DeepWiki is third-party and model-generated. Verify load-bearing answers against the source.Caveats
', + '
DeepWiki is third-party and model-generated. Verify load-bearing answers against the source.' + (GUIDE ? 'Caveats' : '') + '
', '' ].join(''); diff --git a/tests/test_site_navigation.py b/tests/test_site_navigation.py index d5cb6cfd..a1ae7f48 100644 --- a/tests/test_site_navigation.py +++ b/tests/test_site_navigation.py @@ -56,6 +56,17 @@ def test_header_breakpoint_keeps_the_drawer_as_the_mobile_route(): assert '{{ nav.homepage.url | url }}#demo' in header +def test_deepwiki_links_derive_their_base_from_the_script_url(): + # The site is published under /agentdescent/ but served at / locally, so a + # root-absolute href works in CI and 404s on Pages. Both in-panel links must + # take the base from the loaded script instead, and with no script element + # they are left out rather than pointed at a literal that 404s. + js = (ROOT / "docs" / "assets" / "deepwiki.js").read_text() + assert 'href="/deepwiki/"' not in js + assert "new URL('../deepwiki/', SELF.src).href : null" in js + assert js.count('href="\' + GUIDE + \'"') == 2 + + def verify_rendered_site(site): cfg = config() destination = cfg["site_url"] + "#demo"