Skip to content

refactor(llc/frontend): consolidate duplicated tree-build, status-color, and run-status mapping in LLC views #9909

Description

@mrveiss

Discovered during

LLC ship (#9861 / PR #9902) — retrospective review of the touched LLC views surfaced copy-paste duplication across autobot-frontend/src/views/llc/.

Duplication (file:line)

  1. markExpanded() — identical recursive tree-expander duplicated:
    • GoalTree.vue:76
    • SubCompanyTree.vue:71
  2. Build-forest-from-parent — same "group children under parent pointer" logic:
    • GoalTree.vue:31 (buildGoalTree, parent_goal_id)
    • SubCompanyTree.vue (mapNode recursion)
    • (backend mirror: companies.py get_org_chart forest assembly via reports_to — cross-language, can't share, but the FE copies can.)
  3. statusColor() — identical status → tailwind bg-* map duplicated 3×:
    • OrgTreeNode.vue:27, CompanyTreeNode.vue:30, CompanyDashboard.vue:149
  4. Agent run-status → display-status mapping — LLCRunStatus value translation duplicated:
    • CompanyDashboard.vue:84 (runStatusToAgentStatus) and :108 (mapRun, completed→done)
    • drift risk against the backend's _heartbeat_status_to_org_status (companies.py).
  5. Status vocabulary 'active' | 'idle' | 'error' | 'paused' hand-typed in OrgTreeNode.vue:12, CompanyDashboard.vue:28 (should derive from generated API types or a shared const).

Suggested consolidation

  • composables/llc/useLlcTree.ts — markExpanded + buildTreeFromParent(items, idKey, parentKey).
  • composables/llc/llcStatus.ts — the status union type, statusColor(), and runStatusToDisplayStatus() (single source aligned with LLCRunStatus).

Non-blocking; no behavior change. Filed per "every duplication is an issue".

Activity

  1. mrveiss commented on Jun 11, 2026

    @mrveiss
    OwnerAuthor

    Closed — merged to Dev_new_gui via PR #9969 (squash commit 4f31b36b0).

    Criteria met:

    • markExpanded + forest-build consolidated into composables/llc/useLlcTree.ts (markExpanded, buildTreeFromParent, mapTree)
    • status union + color maps + run-status mappings consolidated into composables/llc/llcStatus.ts — CompanyTreeNode's genuinely-different map preserved as separate companyStatusColor() with a divergence-pinning test
    • 5 consumer views rewired; grep audit confirms only shared modules + import sites remain in LLC code
    • 30/30 new composable tests; vue-tsc zero new errors (2 pre-existing TS2440 fixed); independent code-review verdict APPROVE with line-by-line parity verification

    Discoveries: pre-existing LLC type errors left untouched (no-behavior-change PR): GoalTree TS2352 as Goal cast (literal lacks level/owner), SubCompanyTree TS2741 (agent_count missing from constructed CompanyNode — renders empty ' agents'). Filing follow-up issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions