#624

refactor(linear): split the workspace fetch from the per-pane board (OPS-286 prep)

Openwiiiimmwants to merge intofrom

Refs OPS-286 · Part of OPS-282

Summary

Prep for sharing one Linear fetch across several linear panes. It changes nothing on screen.

  • one_pass() used to fetch and count in one go. It is now three steps:
    • fetch_board() fetches teams, open issues, active cycles and projects. This half does not depend on the window.
    • fetch_flow() fetches issues created and completed since the window began.
    • derive() is a pure function. From those two readings, the pane's team filter and a clock, it builds the same State the screen already draws.
  • The raw readings are Board and Flow. They hold the nodes unfiltered, plus every cap flag (teams_capped, open_capped, cycles_capped, projects_capped, created_capped, completed_capped) and a fetch time. Both convert to and from serde_json::Value, ready to become two shared readings in OPS-286. A reading with a missing field is refused rather than read as an empty workspace.
  • graphql() now calls tc::post_answer and returns a Failure. A Failure keeps the exact message shown today and adds a RateLimit: the HTTP status, a limited flag (429 or a RATELIMITED code), Retry-After, X-RateLimit-Requests-Remaining and X-RateLimit-Requests-Reset. These are read by new always-compiled parse_* functions in widgets/src/widgets/linear/parse.rs. Nothing backs off yet.
  • one_pass() still puts the team list on screen as soon as it arrives, so the first frame leaves "collecting…" at the same point as before.
  • fetch_project, keys, footers and docs are untouched.

Evidence

  • cargo test from the root: all suites pass, including widgets/tests/check.rs. The linear tests went from 31 to 41:
    • four parse_* tests;
    • derive tests for team filtering, a named team beating an exclusion, cap flags, an empty board, and the JSON round trip;
    • a test that a Failure still reads as the same message.
    • The fixtures use made-up teams and issues.
  • Live run against a real workspace: I built release binaries of main and this branch and ran them side by side in a 130×60 pty, then compared the screen text.
    • Board: identical except "updated Ns ago" and the requests-left count. Those moved by a second or two in both directions across runs, because two processes were polling at once.
    • Cycle detail screen (tab, then enter): identical.

Merge Danger

Low. This change only touches the linear widget.

  • State.fetched is the later of the two fetch times, which matches today's "when the pass finished". Once the two halves are shared and fetched apart, the older time is the more honest figure. OPS-286 should decide.
  • Issue ages are now measured from when the board is derived, after both fetches, instead of just after the open-issue walk. That is a few seconds' difference on figures shown in hours or days.
  • Failure.limit, RateLimit and the to_value/from_value methods are not used outside tests yet. They carry #[allow(dead_code)] until OPS-286 uses them.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Activity

6
linear-code[bot]13d ago
coderabbitai[bot]13d ago

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Linear request failures now retain available rate-limit and retry information, making it easier to understand when requests are limited.
    • Team names can appear sooner while board data loads.
    • Board and activity data now reflect the selected time window and team filters more consistently.

Walkthrough

The Linear widget now parses rate-limit metadata from responses and retains it with request failures. Its polling path separates board data from window-specific flow data, derives pane state from those readings and supports JSON conversion and validation for both.

Changes

Rate-limit response handling

Layer / File(s)Summary
Rate-limit parsing
widgets/src/widgets/linear/parse.rs
Adds parsers and data types for retry delays, remaining requests, reset times and rate-limit detection. Tests cover valid and invalid inputs.
GraphQL rate-limit handling
widgets/src/widgets/linear/main.rs
GraphQL requests use post_answer and attach parsed rate-limit data to HTTP, JSON-parsing and GraphQL failures. Successful responses update quota from the parsed remaining allowance.

Board and flow polling

Layer / File(s)Summary
Board and flow readings
widgets/src/widgets/linear/main.rs
Adds separate Board and Flow readings with fetch timestamps, page-cap flags and JSON conversion. fetch_board retrieves teams, open issues, cycles and projects. fetch_flow retrieves created and completed issues for the selected window.
Pane state derivation
widgets/src/widgets/linear/main.rs
Team filtering and state derivation now use the readings. one_pass fetches both readings, publishes filtered teams and replaces shared state. Cycle caps remain separate from the general truncation flag.
Reading and failure tests
widgets/src/widgets/linear/main.rs
Tests cover derivation, team filtering, cap handling, empty readings, JSON round-trips, incomplete readings and failure-message conversion.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant one_pass
  participant fetch_board
  participant fetch_flow
  participant Linear
  participant derive
  participant SharedState
  one_pass->>fetch_board: Fetch board reading
  fetch_board->>Linear: Request teams
  Linear-->>fetch_board: Return teams
  fetch_board->>one_pass: Publish team nodes
  fetch_board->>Linear: Request open issues, cycles and projects
  Linear-->>fetch_board: Return board data
  one_pass->>fetch_flow: Fetch window-specific flow
  fetch_flow->>Linear: Request created and completed issues
  Linear-->>fetch_flow: Return flow data
  one_pass->>derive: Build state from Board and Flow
  derive-->>one_pass: Return State
  one_pass->>SharedState: Replace state
Merge Risk: Minimal · up to b5123

This refactor splits the Linear fetch into board and flow readings and keeps rate-limit details on request failures. The screen is intended to stay the same, and the author reports matching output against a live workspace. I found no concrete merge-blocking risk. The only changes are a slightly later "fetched" time and issue ages measured a few seconds later, both disclosed.

Security architecture risk: Minimal · up to b5123

The refactor preserves the Linear credentials, request destination, and polling ownership. Shared storage and automated backoff are not activated. No introduced or worsened risk materially affecting security, failure containment, rollback, or ownership was identified.

Retained concerns No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected change does not enlarge the workspace exposure authorized by the configured Linear key. Both versions fetch workspace data before local team selection; team selection remains a presentation filter rather than an authorization boundary. The new raw readings are not yet shared between panes or written to storage.

Trust Boundaries and Controls

  • observed — Remote status, headers, and GraphQL error codes become diagnostic RateLimit values. They do not control retries, request timing, credentials, or persistence in this PR. The remaining-count header updates the existing in-process quota counter on successful HTTP responses and is rendered as a quota indicator.

Resilience and Maintainability Implications

  • observed — Both readings must complete before the derived State replaces the previous aggregate under one mutex. A fetch failure returns before replacement, and the poller records its error before waiting or handling another refresh. The early team-list update can still accompany older aggregates after failure, but that intermediate state already existed at the base. No reservation, persistent mutation, or new recovery obligation is introduced by the split.
Pre-merge checks: 4

Check nameStatusExplanation
Title checkThe title names the main change: the workspace fetch is split from the per-pane board in the Linear widget. The changeset matches this. The title also includes a ticket reference and a conventional-co…
Description checkThe description is directly related to the changeset. It explains the split of one_pass() into fetch_board(), fetch_flow() and derive(), the Board and Flow readings, the Failure type with RateLimit me…
Linked Issues checkCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkCheck skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the workspace fetch is split from the per-pane board in the Linear widget. The changeset matches this. The title also includes a ticket reference and a conventional-commit prefix, which are acceptable. The title is specific and concise.

Full details: Description check

Explanation

The description is directly related to the changeset. It explains the split of one_pass() into fetch_board(), fetch_flow() and derive(), the Board and Flow readings, the Failure type with RateLimit metadata, and the new parse_* functions in parse.rs. It also gives validation evidence and caveats.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

NOTE

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

I’m a rabbit with ears tuned to the quota’s reply,
I read retry times as they hop by.
Board and flow take their separate tracks,
Then state gathers their facts in its stacks.
I thump at the tests: each reading comes through,
And nibble a carrot to celebrate too!

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bd9bcffe-a7db-4751-ba75-b5f51eff90dc
Commits

Reviewing files that changed from the base of the PR and between 29bb6795041fb08137659587869a77c52e1ea872 and b51230b86ad157dc85c0c394b7ceb3921c59b75c.

Files selected for processing: 2

  • widgets/src/widgets/linear/main.rs
  • widgets/src/widgets/linear/parse.rs

Limit details: You’ve used all 8 included reviews currently available. Your 58 included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.

Recent review details

Additional context used

Code guidelines: 4

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
.agents/skills/principle-boundary-discipline/SKILL.md — Agent Skill
.agents/skills/principle-minimize-reader-load/SKILL.md — Agent Skill
Skipped guideline sources: 8

Not read for this review (the limit of 100 guideline files per review was reached): 8 files
  .agents/skills/wait-what/SKILL.md
  .agents/skills/wayfinder/SKILL.md
  .agents/skills/why/SKILL.md
  .agents/skills/wizard/SKILL.md
  .agents/skills/writing-beats/SKILL.md
  .agents/skills/writing-for-agents/SKILL.md
  .agents/skills/writing-fragments/SKILL.md
  .agents/skills/writing-shape/SKILL.md
Path-based instructions: 4

Source excerpt: Every widget is one folder under `widgets/src/widgets//`, containing its `main.rs`, `help.txt`, `README.md`, `CONFIGURE.md`, and `settings.json` when configurable.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • widgets/src/widgets/linear/main.rs
Source excerpt: **`cfg` decides where bytes come from; nothing else.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • widgets/src/widgets/linear/parse.rs
Source excerpt: Place validation, type narrowing, and error handling at system boundaries.

CodeRabbit inference engine (.agents/skills/principle-boundary-discipline/SKILL.md)

Files:

  • widgets/src/widgets/linear/main.rs
  • widgets/src/widgets/linear/parse.rs
Source excerpt: Maintainability is the work a reader must do to understand code.

CodeRabbit inference engine (.agents/skills/principle-minimize-reader-load/SKILL.md)

Files:

  • widgets/src/widgets/linear/main.rs
  • widgets/src/widgets/linear/parse.rs
Learnings: 2

Learning: 2026-11-12T09:02:12.093Z

Learnt from: CR
Repo: stealth-factory/opscope PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-12T09:02:12.093Z
Learning: Applies to widgets/src/widgets/*/parse.rs : Source excerpt:
# Working on opscope

## Conventions

- **`cfg` decides where bytes come from; nothing else.** Three tiers, because
  gating a parser with `cfg(target_os)` hides its tests from the macOS CI
  run and a broken Linux parser sits behind a green build:
  1. **Always compiled, always tested — every parser.** Pure functions from
     text or bytes to values, named `parse_*`, taking a `&str`. They live
     in `widgets/src/widgets/<widget>/parse.rs` so they compile on every target.
     The cost is a few KB of unused parser in each binary. Worth it.
  2. **`cfg(target_os)` — acquisition only.** Which file to open, which
     command to spawn, a call into a platform C API. `linux.rs` / `macos.rs`
     beside `main.rs` in the widget's package folder, gated on `mod host`.
     Shared wording lives in
     `opscope-core`: `unsupported()` is `does not run on {os}`, drawn by
     `cannot_start_because()`.
  3. **Runtime detection — anythin...

Applied to files:

  • widgets/src/widgets/linear/parse.rs
Learning: 2026-11-04T08:22:40.853Z

Learnt from: CR
Repo: stealth-factory/opscope PR: 0
File: wiki/making-a-widget.md:0-0
Timestamp: 2026-11-04T08:22:40.853Z
Learning: Applicability reference:
AGENTS.md: # Working on opscope
For a new widget, follow the ordered contributor guide in
[`wiki/making-a-widget.md`](wiki/making-a-widget.md). It is the source of truth
for the owned folder, launcher registration, settings, platform split, tests,
manual smoke test, and release handoff.

Source excerpt:
# Making a widget

## Platforms: `cfg` decides where bytes come from

Keep the parser visible to every build. The platform split has three tiers:

1. **Parsers are always compiled and always tested.** Put pure functions from
   text or bytes to values in `parse.rs`, name them `parse_*`, and take the
   input as `&str`. Never put a parser, its module, or its tests behind
   `cfg(target_os)`: the macOS CI build would otherwise never compile a Linux
   parser or its tests, so broken Linux code could sit behind a green build.

Applied to files:

  • widgets/src/widgets/linear/parse.rs

chatgpt-codex-connector[bot]12d ago
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

ReviewStatusCommitReview trigger
📝 Code Review✅ Completed 2026-11-16T06:17:45.911319Zb51230bDraft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

coderabbitai[bot]approved changes12d ago