Skip to content

Ask AI: say when the browser blocks the docs site from reaching localhost - #16

Merged
dandydarshan merged 1 commit into
mainfrom
fix/chat-local-network-permission
Nov 7, 2026
Merged

dandydarshan merged 1 commit into
mainfrom
fix/chat-local-network-permission

Conversation

@dandydarshan

@dandydarshan dandydarshan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

On a GitHub Pages site, Chrome asks the user before the page may reach 127.0.0.1 (Local Network Access). If that's denied, every probe fails exactly as if codewiki serve weren't running, so the chat said "Chat needs CodeWiki running on your machine" even when it was running.

 findChatServer
   probe ports 8765–8774 for this repo's server
+  none found at all → navigator.permissions.query({name: 'local-network-access'})
+                      'denied' → chatAccessDenied
 renderChatOffline
-  "Chat needs CodeWiki running on your machine." + serve command
+  denied: "Your browser is blocking this page from reaching CodeWiki on your machine.
+           To allow it, click the icon left of the address bar, turn on Local network access
+           for this site, and reopen this panel."  + serve command (in case it isn't running)
+  otherwise: unchanged

Browsers without this permission (Firefox, Safari) make the query throw, so they keep the old message. Safari keeps its existing hint about opening the docs from the local server.

Evidence

  • Real GitHub Pages (a throwaway repo, since deleted), Chrome 155:
    • default: the probe is blocked with "Permission was denied for this request to access the loopback address space", and the permission state is denied;
    • allowed: it connects and the state is granted.
  • Reproduced locally with --ip-address-space-overrides=<site>=public: same states, same block.
  • test_chat_says_when_the_browser_blocks_localhost:
    permission denied             → "Your browser is blocking…"      (old template: "Chat needs CodeWiki running…")
    permission allowed, no server → "Chat needs CodeWiki running…"
    
  • 501 tests pass.

Merge Danger

Door: two-way

Blast Radius: chat offline message

It only adds a message when no server answered and Chrome reports the permission as denied. The wording names Chrome's Local network access setting; other Chromium browsers may label it differently.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CXRqeijND7XPq2srGHndRd

Base automatically changed from fix/serve-artifacts-and-ports to main November 7, 2026 01:42
…host

On GitHub Pages, Chrome asks before a public site may reach this machine
(Local Network Access). Once denied, every probe fails exactly as if
`codewiki serve` were not running, and the chat said "Chat needs CodeWiki
running" while it was. When no server is found and
navigator.permissions reports local-network-access as denied, the panel
now says the browser is blocking it and how to allow it, keeping the
serve command below. Browsers without the permission are unaffected.

Browser test with Chromium's --ip-address-space-overrides making the test
site a public origin: denied → the blocking message; allowed with no
server → the usual one. The old template shows the misleading message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CXRqeijND7XPq2srGHndRd
@dandydarshan
dandydarshan force-pushed the fix/chat-local-network-permission branch from 4b09125 to f1e6d68 Compare November 7, 2026 01:53
@dandydarshan
dandydarshan merged commit 24a53e0 into main Nov 7, 2026
14 checks passed
@dandydarshan
dandydarshan deleted the fix/chat-local-network-permission branch November 7, 2026 03:14
@dandydarshan
dandydarshan restored the fix/chat-local-network-permission branch November 7, 2026 03:14
@dandydarshan
dandydarshan deleted the fix/chat-local-network-permission branch November 7, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant