Skip to content

refactor: tidy the assistant transport and slim requestRaw - #565

Merged
caitlon merged 6 commits into
devfrom
refactor/assistant-transport-tails
Oct 11, 2026
Merged

caitlon merged 6 commits into
devfrom
refactor/assistant-transport-tails

Conversation

@caitlon

@caitlon caitlon commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Problem

requestRaw in lib/api.ts was above Sonar's cognitive complexity limit (17 of 15). A Retry-After sent as an HTTP date parsed to NaN. The assistant stream left an abort listener on the caller's signal after the request settled. A few review leftovers in the chat hook had no test that would catch their removal, and the composer textarea was 2 px short of its content, which shows a scrollbar on Windows from the second line.

Change

  • requestRaw: the 401 refresh-and-retry branch moves to a private refreshOrExpire (17 -> 10). Behaviour unchanged.
  • parseRetryAfter: delta-seconds as before, an HTTP date becomes the seconds until it, anything else is undefined, so a date value no longer reaches the assistant as NaN.
  • The stream request removes its abort listener when it settles; the redundant pending.catch is gone.
  • Chat hook: storage key versioned as assistant-chat:v1 (sign-out still clears every assistant-chat: key); one shared isRecord; a redundant array check in loadMessages and an extra write bump in restoreDraft removed (both covered by tests); expected refusals (404, 422, 429, 503) log as warnings, everything else as errors; tests that fail when either conversation-switch guard is removed.
  • Composer height includes the border.

Verification

  • npm run lint, npm run typecheck, npm run test:coverage (thresholds held).
  • Complexity measured with eslint-plugin-sonarjs: requestRaw 17 -> 10, send 13 -> 10.

Migrations

None.

Screenshots

None.

@caitlon caitlon added this to the v1.1-polish milestone Oct 11, 2026
@caitlon caitlon added type:tech-debt Code quality improvement area:frontend React frontend labels Oct 11, 2026
@caitlon caitlon self-assigned this Oct 11, 2026
@greptile-apps

greptile-apps Bot commented Oct 11, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository.

@github-actions github-actions Bot added the size:M 300 to 600 changed lines. The target size. label Oct 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

@caitlon
caitlon merged commit 8a7d3f4 into dev Oct 11, 2026
20 of 24 checks passed
@caitlon
caitlon deleted the refactor/assistant-transport-tails branch October 11, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend React frontend size:M 300 to 600 changed lines. The target size. type:tech-debt Code quality improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant