[#196] Add active OWS wallet selection#489
Conversation
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
PR #489 covers most active-wallet routing, but the AI writer/link-status cache still mixes global agent metadata with the currently selected wallet. That breaks issue #196's requirement that dashboard/account/AI writer flows reflect the selected wallet and that switching wallets does not mix context.
Findings
- [high]
/api/settings/link-statusreturns the cachedconfig.agentIdfor whichever wallet is currently active, without proving that cached agent belongs to that wallet. After registering or caching Agent A for Wallet A, switching to Wallet B makes this branch returnlinked: true, Agent A's id, and Wallet B's address before any wallet-specific RPC check runs. The same global config metadata is also included in/generate-binding, so binding UI can carry stale agent data across wallet switches.- File:
app/routes/settings.ts:207 - Suggestion: key cached agent/link metadata by active wallet address/name, or only use the cache when it is explicitly associated with the active wallet. Otherwise fall through to
agentIdByWallet(address)/ ownership checks and update wallet-scoped cache entries. Add a regression test for two fake active wallets where switching from a registered/cached wallet to an unregistered wallet reports unlinked and does not return the first wallet's agent metadata.
- File:
Decision
Request changes at 1fe9d32fec6da6b4bff5093efdfe47abb37d7027. Live CI lint-and-typecheck is green, and the rest of the resolver/API/UI direction looks aligned, but this cache bug is a blocking acceptance-criteria miss for active-wallet switching.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
PR #489 moves the main wallet discovery/signing paths toward an explicit active wallet, but AI writer link status still uses a global agent cache. After switching wallets, the UI/API can report the newly selected wallet as linked to the previously selected wallet's agent, which violates #196's requirement that account/AI writer views reflect the selected wallet and not mix context across switches.
Findings
- [high]
link-statustrusts the global cachedconfig.agentIdbefore checking whether it belongs to the active wallet.- File:
app/routes/settings.ts:207 - Details:
register-agentwritesagentIdinto a sharedconfig.jsoncache, andlink-statusimmediately returnslinked: truewhenever that cache exists, using the current active wallet address in the response. With wallet A registered/cached, switching to wallet B will still return wallet A'sagentIdas linked for wallet B without callingagentIdByWallet(B). This directly mixes AI writer/account state across active-wallet switches. - Suggestion: Scope cached agent metadata by active wallet identity/address, or only use the cache when it records the same active wallet address. Otherwise fall through to the on-chain
agentIdByWallet/ownership checks and update the cache under that wallet-specific key.
- File:
Decision
Requesting changes. I reviewed live PR #489 at 1fe9d32fec6da6b4bff5093efdfe47abb37d7027, issue #196, and live checks. CI was still pending (lint-and-typecheck) at review time.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The requested active-wallet fix is in place at d9ca926cee7a4b67a56b3f25782080b13b86a982. Cached AI writer/agent metadata is now scoped to the active wallet, and stale Wallet A metadata is not reused after switching to Wallet B.
Findings
- No blocking findings.
Decision
Approved. I re-reviewed the live PR diff, issue #196, and the current settings/cache changes. app/routes/settings.ts now validates cached agent metadata against active wallet address/id/name before using it, writes wallet-scoped metadata after registration/RPC discovery, and app/routes/settings.test.ts covers the two-fake-wallet stale-cache regression for both link-status and generate-binding. CI was still pending when I checked the current commit.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The requested active-wallet cache fix is in place. AI writer agent metadata is now scoped to the active wallet identity, and stale Wallet A agent metadata is no longer reused after switching to Wallet B.
Findings
- No blocking findings.
Decision
Approved at d9ca926cee7a4b67a56b3f25782080b13b86a982, pending the new live CI run. I reviewed the updated settings.ts logic and the added settings.test.ts regression: cached agent metadata is trusted only when it matches the active wallet address/id/name, otherwise link-status falls through to wallet-specific on-chain checks, and generate-binding omits stale cached agent fields for the newly active wallet. This resolves my prior request-change finding for #196.
Summary
Settingtable, with one-wallet auto-selection and explicit selection required for ambiguous multi-wallet installs.plotlink-writer-Nwallet creation that makes the new wallet active.plotlink-writer*wallet.Verification
npm run typecheckTMPDIR=/home/quadwork/plotlink-ows-dev/.tmp/vitest npm test -- app/lib/active-wallet.test.ts app/routes/settings.test.ts app/routes/publish.test.ts app/routes/upload-cover.test.tsnpm run lint(passes; existing unrelated warnings remain)npm run app:buildFixes #196