Skip to content

refactor(libs): remove ~9,000 lines of dead and duplicated code - #653

Merged
MrYuion merged 17 commits into
developfrom
refactor/libs-cleanup
Nov 2, 2026
Merged

MrYuion merged 17 commits into
developfrom
refactor/libs-cleanup

Conversation

@MrYuion

@MrYuion MrYuion commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The libs had built up a lot of code that nothing uses, plus several copies of the same logic. I went through all 12 libs to remove and merge what I could. The work also found two small bugs.

Solution

One commit per block, so each can be reviewed alone. The branch removes about 9,650 lines and adds about 1,050.

  • Bug fixes. The catering select modal saved favourite menu items under the desk favourites key. The explore desk tooltip retried its position lookup every 200 ms with no limit.

  • Dead code. I removed components, pipes, services and functions with no references in apps/ or libs/, including a 608-line copy of maps-indoors, the upload permission modal (switched off since f6aa2e0), settings.interfaces.ts, DesksService, and mock endpoints that no app calls.

  • Shared helpers. toggleListItem() for 14 favourite toggles. One cached hidden asset type lookup for desks, lockers, parking and catering. uploadAttachment(), which also drops the blob-util dependency. compact-counter is now <a-counter [compact]="true">. provideValueAccessor() for 29 provider blocks. Plus a table-driven asset CRUD mock and a few smaller helpers.

  • Time zones. timezones.ts is now built from Intl.supportedValuesOf('timeZone'), plus UTC and the Etc/GMT fixed-offset zones. Chrome and Safari return some legacy names (for example Asia/Calcutta), so a small map changes them to the current IANA names (Asia/Kolkata). It was 983 lines and is now 62.

  • Desk asset work from fix: desk assets support in workplace and concierge #656 and fix(desks): CSV import no longer erases desk data #657. The branch is rebased onto it. The new *InZone queries for desks, lockers and parking use one queryTypeAssetsInZone() helper, and the per-zone queries now use the same paged query. The concierge desk CSV import is now one DesksStateService.importDesksCsv(). The code flow and the desk flow share queryDeskAssetByLegacyId(). I also removed desks-topbar, which no template renders.

Behavior changes

  • AssetStateService no longer loads an asset list and asset bookings that nothing read, so each options change sends two fewer requests. A loading entry now covers the availability request.
  • Hidden asset type lookups no longer treat a failed list request as an empty list. That could create a duplicate type and hide existing desks or lockers until reload. They also no longer cache failures, so the next call retries.
  • Time zone pickers now offer zones the old static list did not have, such as Asia/Ho_Chi_Minh and Europe/Kyiv. The list follows the browser's time zone data, so it can change between browsers. Stored values still show and save.
  • Existing catering favourites saved under the desk key by the modal are not migrated.

Not done

I left these out on purpose. The desk, locker and parking list fields and select modals could be merged, but the result needs many config inputs and is harder to read than the separate components. Also open: libs/bookings/src/lib/parking.service.ts:57 drops the result of list.map(...) and its region check looks inverted. Someone who knows the parking region rules should look at that.

Verification

  • nx affected -t test passes for 30 projects. Under parallel load, two signage-manager specs ("searches without a parent selection") can fail because they wait 450 ms of real time for a debounce. They pass when run alone, and this branch does not change signage-manager. nx affected -t build passes for 19 apps. A workplace development build compiles the mocks.
  • New focused specs for the bugs that review found. Each fails without its fix.
  • oxlint and ESLint (templates) are clean.

Reviewed with sol-loop: 16 rounds over the first 12 blocks with gpt-6.1-sol on xhigh. Sol verdict: approved

Changes made by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3 Code. The first audit used Claude subagents. GPT-6.1 Sol (Codex) reviewed each block.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
frontend-templates Ignored Ignored Preview Nov 2, 2026 1:19am UTC

@MrYuion MrYuion left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Claude Opus 5.5 responding on behalf of Alex Sorafumo

One real issue: the time zone list built from Intl.supportedValuesOf drops current IANA names in Chrome and Safari. See the inline comment.

What I checked at 1947249119:

  • Every removed export, selector and pipe name: no remaining uses in apps/, libs/, e2e/ or tools/. Matches that remain are local copies that already existed (MapPolygonData, EventNote, TimePeriod, RecurrenceDetails and others in @placeos/common).
  • ngc --noEmit with strictTemplates for all 19 apps, tsc for all 30 spec tsconfigs, and e2e:typecheck. All clean.
  • nx test for common, assets, form-fields, mocks and catering. All pass.
  • The merged code keeps its behaviour: a-counter [compact] matches the old compact-counter class and template, ensureHiddenCategory/ensureAssetType use the raw ts-client queries like the old copies, the CRUD mock helper keeps the old ids and PUT/DELETE semantics, and the removed /api/staff/v1/signage* mocks have no callers.

Nit (file not in the diff): the comment at e2e/support/concierge/locker.seed.ts:16 still names queryLockerBankAssets, which this PR removes.

Comment thread libs/common/src/lib/timezones.ts Resolved
@MrYuion
MrYuion force-pushed the refactor/libs-cleanup branch from 1947249 to 71b658b Compare November 2, 2026 01:04
@MrYuion

MrYuion commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Note

🤖 Claude Opus 5.5 responding on behalf of Alex Sorafumo

The locker.seed.ts nit is fixed in 71b658b. The comment now names queryLockerBankAssetsForZones. The branch is also rebased onto the latest develop.

…ltip retries

The catering select modal saved favourite menu items under the desk
favourites key, so they mixed into desk favourites. Both catering views
now use SETTING_KEYS.FAVORITE_CATERING.

ExploreDeskInfoComponent retried its position lookup every 200 ms with
no limit when its parent element was missing. It now stops after 10
tries.
… wiring

Removes components, pipes, a guard and a directive in libs/components
and libs/form-fields that nothing imports or renders (including the old
608-line indoor-maps copy of maps-indoors), inputs that no caller binds,
and the upload permissions modal path. The app-level provider for that
modal was removed in f6aa2e0, so the component-level providers never
reached the root UploadsService and the modal could not open.

authenticated-image.pipe.ts is renamed authenticated-image.ts as it no
longer holds a pipe.
Removes settings.interfaces.ts (imported nowhere), the Vorlon and
keep-alive services, the unused feature guard, a spec helper that pulled
@ngneat/spectator/jest into the production barrel, unused general.ts
helpers (including a buggy mapLastValueFrom), unused guest/staff
functions, the user label modal, and unused Stripe types and members.
…d events

Removes DesksService and its confirm modal, about 25 unused query and
helper functions, the asset group pipe, the catering order options
modal, unused members and inputs, and the events copies of interfaces
and helpers that had drifted from @placeos/common.

AssetStateService no longer loads an asset list and asset bookings that
nothing read, which saves two requests on every options change. A
loading entry now covers the availability request instead.
Removes the signage staff API mock handlers (no app calls those paths),
unused mock data helpers, src/mocks.ts, and a few unused map-editor
exports.
Fourteen components wrote their own "add the ID or remove it" code
before saving a favourites setting. They now use toggleListItem() from
@placeos/common.
The desk, locker, parking and catering asset files each had a copy of
the code that finds or creates their hidden asset category and type.
assets.fn.ts now has one cached version. It retries after a create
collision and shares the category and type lists, so fewer duplicate
requests go out.

A failed list request now rejects and is not cached. Before, it was
treated as an empty list, which could create a duplicate type and hide
existing resources until reload.
upload-file-field and upload-list-field had the same upload method. It
is now uploadAttachment(), which passes the File straight to
uploadFiles, so the blob-util dependency is removed.

compact-counter was a copy of a-counter with another layout. It is now
the `compact` input of a-counter.
The 16 show/create/update/delete handlers in assets.mock.ts now come
from one helper. Also removes the empty metadata fields from mock
endpoints and merges the identical display and microphone modules.
Catering and assets each had the same cached zone rules loader, and
bookings and events each had the same app name and version stamp. Each
is now one helper. Also removes padString, which copied padLength, and
simplifies padLength and flatten with native methods.
Replaces 29 copies of the NG_VALUE_ACCESSOR provider block with
provideValueAccessor(() => Component) from @placeos/common.
Replaces the 983-line hand-written time zone table with
Intl.supportedValuesOf('timeZone'), plus UTC and the Etc/GMT
fixed-offset zones. Deprecated aliases such as Asia/Saigon are no longer
suggested, but stored values still show and save.
Chrome and Safari return legacy names such as Asia/Calcutta from
Intl.supportedValuesOf. Map them to the current IANA names so that
searches for Kolkata, Kyiv or Ho Chi Minh find a match.
No template renders desks-topbar. Only its own spec and a mock in the
desks component spec referenced it.
The desks view and the desk manager parsed the CSV and gave new rows an
id in two copies. DesksStateService.importDesksCsv now does both.
The code flow and the desk flow both queried the org's desk assets and
matched the legacy id. queryDeskAssetByLegacyId now does this.
queryAllAssetPages is private again, because only assets.fn.ts uses it.
@MrYuion
MrYuion force-pushed the refactor/libs-cleanup branch from 71b658b to 0966141 Compare November 2, 2026 01:51
@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

Deployment failed for project frontend-templates with the following error:

Resource is limited - try again in 1 day (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/placeos?upgradeToPro=build-rate-limit

@MrYuion
MrYuion merged commit 2aa1da3 into develop Nov 2, 2026
44 of 45 checks passed
@MrYuion
MrYuion deleted the refactor/libs-cleanup branch November 2, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant