oliver-zehentleitner / maity

clean-up: web team/agents: shared cycle check and chat rule, fewer repeated reads, runner poll, leftovers

Sign in to report

tsk-3jt5w07yskb6 Open

From the web clean-up audit, area 17 (tsk-hgnbapyw7hnh), read at 80647565 (findings sent to lotse, seq 125484). Line numbers are from 80647565, so re-check them on current main.

#24 Team / join / org / paths: the cycle check, boss labels and isConsent are copied (duplication).

  • The reporting-line cycle check exists three times: members.js:547-556 (circle in reportsToPart), members.js:824-833 (closesCircle) and join.js:301-308 (closesCircle). Two of the three are in the same file.
  • org.js:36-66 (buildTree) and paths.js:104-121 (tree) do a similar cycle-breaking walk.
  • The boss labels at join.js:273-276 (ownBoss/bossLabel) repeat members.js:559-564.
  • isConsent (members.js:123) is written inline again at join.js:519.
  • Proposal: one closesCircle, one isConsent and one boss-option builder, shared from dom.js or trust.js.
  • Effort S. Risk low.

#25 Team / member page: the Chat button rule differs between the two pages, and one branch is dead (design/debt).

  • Where: members.js:958-965 and member-page.js:98-101.
  • Team requires M.groupChat and excludes "archived". The member page skips the M.groupChat check and excludes "accepted" and "archived".
  • "accepted" is not a project state: hub policy.py:7 lists plan, build, review, launch and archived.
  • Proposal: one M.dom.chatHref(ctx, m) for both pages, without "accepted".
  • Effort S. Risk low.

#26 Agents / placements / invite: the same lists are read again and again (slow path).

  • agents-page.js:243-250 (memberViews) reads the full member list of every project any profile is in. On the Agents page of one project, reload() (:633-638) repeats this after every save, though only that project is needed.
  • Opening a row on /agents calls M.projectContext (agents-page.js:283, app.js:1978), which reads the same members again. M.membersOnce (app.js:1963) exists for this but is not used.
  • On /agents/placements, M.placements.section calls GET /runners once per project (placements.js:296).
  • invitations.js:31-46 reads the context of each governed project one after another, and again whenever the chosen project changes.
  • Proposal: use M.membersOnce, read only this project on its Agents page, read GET /runners once in placementsTab, and cache the panels per project on /invite.
  • Effort M. Risk low-medium: stale data after a save.

#27 Agents / org / join: leftovers, filters the hub already applies, swallowed errors (debt).

  • GET /agents returns only the profiles of the caller that are not deleted (hub routes/agents.py:133-134). The client filters again by owner_id and deleted_at at:
  • agents-page.js:369, :430 and :629 (the copies at :430 and :629 duplicate the ownProfiles helper at :369)
  • inbox.js:695
  • join.js:129
  • Dead or trivial code:
  • titled (agents-page.js:509, :520) is only ever false when read.
  • redrawing (:426, :446) is an alias.
  • bringing (:542) only wraps M.bringing.
  • M.org exports buildTree and contains (org.js:226), with no caller outside org.js.
  • members.js:21-23 has the same comment twice.
  • Swallowed errors: empty callbacks at agents-page.js:485, :580 and :820.
  • Proposal: delete these or reuse the helper. Give the three swallowed errors a status line.
  • Effort S. Risk low.

#28 Runners (account and project): the card head and the poll are duplicated, and only one poll has an overlap guard (duplication).

  • runners.js:287-290 builds the same card head as project-runners.js:56-60.
  • runners.js:396-401 and :426-437 guard the 30 s poll against overlap. project-runners.js:157 has no guard, so a slow reload can be overtaken by the next one.
  • On first draw, project-runners.js reads /runners only after the attachments (:24, then :155).
  • Smaller copies:
  • three presence word tables: members.js:14, agents.js:26, member-page.js:20
  • the projectContext chat-link callback: agents-page.js:283, :325, :385 and invitations.js:35
  • two identical member-event redraw handlers: org.js:219-223 and agents-page.js:595-599
  • a hand-built tab bar at member-page.js:279-280 instead of M.tabBar (page-head.js:14)
  • Proposal: a shared runner head and guarded poll, the presence words in presence.js, one projectChatLink, and M.tabBar on the member page.
  • Effort S-M. Risk low.

Order: the person-page work (tsk-zrjxhxanfwzd, PR #1738) touches member-page.js. Rebase on it.