Skip to content

refactor(web): the Crew request poll uses the shared visible-refresh hook - #351

Merged
bryantderosier merged 1 commit into
j5/mainfrom
j5/crew-requests-poll-simplify
Sep 29, 2026
Merged

bryantderosier merged 1 commit into
j5/mainfrom
j5/crew-requests-poll-simplify

Conversation

@bryantderosier

Copy link
Copy Markdown
Collaborator

Problem

After #309 merged, the Crew seat-approval poll still had a hand-written lifecycle: module-level consumer counting, a poll key, start/stop functions, and a startVisibleRefresh export. Jackson's review on #309 pointed out that the gating atom already does the gating, so none of that was needed.

What I changed

  • apps/web/src/j5/crew/crewRuntimeRequestsClient.ts: useCrewRuntimeRequestsRefresh is now createVisibleRefreshHook(refreshPolledEnvironments, CREW_RUNTIME_REQUESTS_POLL_INTERVAL_MS). The removed pieces are consumers, polledKey, stopPoll, syncPoll, the consumer-count and key effects, and the useEffect import.
  • apps/web/src/j5/useVisibleRefresh.ts: the startVisibleRefresh export is gone, and the file is back to its shape before feat(crews): answer a Crew thread's provider approvals and questions from the Inbox #309.
  • refreshCrewRuntimeRequests, the forced re-read after an answer, is unchanged.

Why this shape

  • polledCrewRuntimeRequestsAtom (apps/web/src/j5/state.ts) only mounts an environment's query while that environment has a pending approval.
  • A newly mounted query fetches on its own, because J5 queries are Atom.swr({ revalidateOnMount: true }).
  • refreshPolledEnvironments sends nothing while no environment is polled.

So the shared hook gives the same result with far less code.

Invariants

  • With nothing pending, a tick sends zero requests.
  • An answer still forces an immediate re-read.

Surfaces

Surface Decision
Entry points Unaffected.
Clients (web, desktop, mobile) Web and desktop; mobile has no Crew Inbox.
Providers Unaffected.
Contracts Unaffected.
Reverse states Not applicable.
Connection modes Unaffected.
Upstream files / FORK.md None.
Docs Unaffected.

Out of scope

Upgrade and data

None.

Verification

  • apps/web typechecks (exit 0).
  • vp test run apps/web/src/j5: 329 passed. The pure crewApprovalPollPlan tests still cover the gating decision.
  • Lint and format are clean.

Review focus

  • The tradeoff Jackson named: a second approval on an environment that's already polled now shows on the next 7.5s tick instead of immediately, the same latency as every other J5 poll.

Claude Opus 5.5 via Claude Code in J5 Code

🤖 Generated with Claude Code

…hook

The gating atom already skips environments with no pending seat approval,
and a newly polled environment's query fetches on mount, so the
hand-written poll lifecycle was redundant. The Crew request poll now uses
createVisibleRefreshHook like every other J5 poll; each tick sends nothing
while no approval is pending. startVisibleRefresh is private again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@bryantderosier bryantderosier added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. jackson-direct Taken by Jackson + Astra outside the fleet methodology; lanes never staff these labels Sep 28, 2026
@bryantderosier bryantderosier self-assigned this Sep 28, 2026
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: Jacksondr5/j5code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 46554b8e-f25d-421e-b7e3-1b09a4473642


Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:M 30-99 effective changed lines (test files excluded in mixed PRs). label Sep 28, 2026
@bryantderosier
bryantderosier merged commit 24f4180 into j5/main Sep 29, 2026
35 checks passed
@bryantderosier
bryantderosier deleted the j5/crew-requests-poll-simplify branch September 29, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jackson-direct Taken by Jackson + Astra outside the fleet methodology; lanes never staff these size:M 30-99 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant