Frontend: share formatters and move large pages to useReducer (series of PRs)

Open
#546 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sisantaChhatoi is already working on this.

Since Nov 30, 2026.

  • #710 by @sisantaChhatoi — open
  • #926 by @sisantaChhatoi — open
  • #927 by @sisantaChhatoi — open
  • #928 by @sisantaChhatoi — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
nextjs, react, typescript
Domain
frontend

Research direction

Start with the linked formatter PR and read web/src/lib/format.ts and web/src/lib/status.ts, then inspect the listed branches and their page _state/ folders. Run the relevant test:* scripts and npm run test:reducers; each step should also pass tsc --noEmit and next build. The series is already underway in the author's fork, and the issue invites maintainers to decide whether to accept its proposed split.

Written by the indexing model from the issue text.

Description

Proposal: frontend state refactor, split into a short series of PRs

Several large pages in web/ manage their state with many separate useState calls (up to ~40 in one component). Rules that span fields, like "a filter change goes back to the first page and clears the selection", are spread across handlers and effects, which makes these pages hard to change safely. Small helpers (byte/token/time formatters, the HTTP status colour) are also copied across many files with slightly different behaviour.

Following CONTRIBUTING.md (one focused change per PR, list queued changes in one issue), I'd like to submit this as a stacked series. Each step builds on the previous one, and each branch is already pushed to my fork if you want to look ahead:

  1. ✅ Shared display formatters and status colours, merged in #547. src/lib/format.ts (formatBytes, formatTokens, formatDurationMs, formatShortDateTime) and httpStatusTone in src/lib/status.ts, replacing ~30 copies in 21 files. Small visible normalizations: sizes over 1 GiB show as GB, token counts show 25k / 2.5M everywhere.
  2. ✅ Shared reducer slices + useReducer for the function pages, landed in 58bb812 (#692): small pure slices in src/lib/reducers/ (pagination, list, request, selection) and one reducer per page for commands, findings, traffic, assets, LLM records, sync and workspace. Adds npm run test:reducers (node --test, with a tiny loader for the @/ alias).
  3. useReducer for the remaining components, split into page-group PRs of under 15 files / 2,500 lines each, per the review on #710:
    • #928: tasks list page (replaces #710)
    • ✅ #861: task detail sessions tab (merged)
    • ✅ #862: task detail page, overview and broadcast tabs (merged)
    • ✅ #868: task detail assets, credentials, retests and coverage tabs (merged)
    • ✅ #913: system LLM, tools and agents (merged)
    • ✅ #914: system intercept and notify (merged)
    • ✅ #915: system skills, settings, logs, MCP and chat bridge (merged)
    • ✅ #916: chat, dashboard, shared browser and auth (merged)
    • #926: agent editor, approval records and intercept card
    • #927: traffic picker, link-traffic dialog, finding traffic panel and task templates

Scope rules I followed:

  • Only components with 5+ related states were converted; smaller ones stay on useState.
  • No intended behaviour change beyond the formatter normalizations in step 1. In step 2, the traffic page's six separate debounce timers become one, so edits to several filters within 300 ms produce one fetch instead of several.
  • Each reducer lives in a _state/ folder next to its component. Tests cover the shared slices and the reducers with real logic (cross-field rules, merging, debouncing), not plain setters.

Verified on every step: tsc --noEmit, the existing test:* scripts, the new reducer tests, and next build.

If you'd prefer a different split or would rather not take parts of this, let me know before I open the next PRs.

Dominant language
Go
Stars
18.7k
Forks
7k
Avg merge
10h 57m
Merged PRs (30d)
494

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BaaRai/ARTEX

All issues in BaaRai/ARTEX

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.