fix(pulse): declare runtime deps + show error state when /api/wiki fails#1261
Open
atabisz wants to merge 3 commits into
Open
fix(pulse): declare runtime deps + show error state when /api/wiki fails#1261atabisz wants to merge 3 commits into
atabisz wants to merge 3 commits into
Conversation
…pi/wiki fails The /docs page rendered "Loading..." forever when the wiki API returned an error (e.g. when the Pulse wiki module failed to load minisearch and all /api/wiki/* routes 404'd). The useQuery hooks ignored isError, so a failed fetch was indistinguishable from a pending fetch. Surface isError + error from both queries and render a WikiErrorState component with the HTTP status, a hint, and a Retry button. The doc-detail query gets the same treatment. No behavioural change on the success path.
modules/wiki.ts imports minisearch but the dep was never declared anywhere in the release. Fresh installs of PAI 5.0.0 silently fail to load the wiki module, which makes /api/wiki return 404 and (combined with the missing React Query error branch) leaves the /docs page stuck on Loading... forever. Add a PULSE-local package.json so 'bun install' in PAI/PULSE/ resolves the dep alongside the daemon that uses it. Installer wiring (running bun install during PAI bootstrap) is left to a follow-up PR.
pulse.ts, lib.ts, pulse-unified.ts, and checks/github-work.ts all import smol-toml to parse PULSE.toml. Same defect class as minisearch: not declared anywhere in the release, so a fresh install would crash on startup before the wiki module even loads. Optional module deps (grammy, jose, @anthropic-ai/claude-agent-sdk) are deliberately deferred to a follow-up PR — they need an optionalDependencies design discussion, not a blanket addition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A fresh PAI 5.0.0 install hits two compounding defects when loading the Pulse
/docspage:minisearch(inmodules/wiki.ts) andsmol-toml(inpulse.ts,lib.ts, and others — to parsePULSE.toml), but neither is declared as a dependency anywhere in the release.pulse.logshowsResolveMessage: Cannot find package 'minisearch'andpulse.tsswallows the error, so/api/wiki/*falls through to Pulse's 404 handler.smol-tomlwould crash startup outright.docs/page.tsxdestructures onlydatafromuseQuery. When the fetch errors,dataisundefined— indistinguishable from the pending state — so the component falls through to theLoading...branch forever. The user sees an infinite spinner with no error and no console hint.Either fix alone would mask the other.
Changes
1. Declare Pulse runtime dependencies
Releases/v5.0.0/.claude/PAI/PULSE/package.jsondeclaringminisearch ^7.2.0andsmol-toml ^1.6.1.pulse.tsso deps live next to the daemon that uses them.bun installinPAI/PULSE/is sufficient.Scope note: the daemon also has optional imports for
grammy,jose, and@anthropic-ai/claude-agent-sdk(used by the telegram, github-work, and imessage modules respectively, all wrapped in try/catch). These are deliberately not declared in this PR — they need anoptionalDependenciesvs. plaindependenciesdesign decision and belong in a follow-up.grammyalready shows up inpulse.logas a missing-package warning today; this PR doesn't change that.Installer follow-up needed: the installer (
install.sh/PAI-Install/engine/actions.ts) doesn't currently runbun installinPAI/PULSE/. That's a separate PR — declaring the deps is the prerequisite.2. Surface fetch errors in the React UI
WikiErrorStatecomponent — title, message, optional hint, retry button.useQueryhooks now propagateisError,error, andrefetchto the UI.HTTP 404instead of a generic string.Verification
/api/wiki→ 404,/docsstuck onLoading...forever./docsnow renders "Couldn't load the wiki — Failed to fetch wiki index (HTTP 404)" with a hint pointing topulse.logand a Retry button.minisearch(mirroring what the newpackage.jsondeclares), restarted Pulse: wiki module loads,/api/wiki/searchreturns 200,/docsrenders normally.smol-tomlis imported by 4 daemon files (pulse.ts,lib.ts,pulse-unified.ts,checks/github-work.ts) — load-bearing for PULSE.toml parsing.Notes
Cannot find module 'react'TypeScript diagnostics in this directory are unrelated —Releases/v5.0.0/ships withoutnode_modules. Not introduced here.