Skip to content

Serialize make-me-rich settings updates without eager refresh#1518

Open
KillariDev wants to merge 3 commits into
mainfrom
t3code/83482476
Open

Serialize make-me-rich settings updates without eager refresh#1518
KillariDev wants to merge 3 commits into
mainfrom
t3code/83482476

Conversation

@KillariDev

@KillariDev KillariDev commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Serialize make-me-rich settings updates so concurrent popup and background writes do not overwrite or duplicate fixed rich-list entries.
  • Make fixed-address updates idempotent while preserving list order and collapsing existing duplicates.
  • Reuse the same rich-list update logic for optimistic Home UI updates and background storage changes.
  • Avoid an immediate full popup visualization refresh when rich mode changes, while keeping the next simulation input and balance queries up to date.
  • Add focused coverage for serialization, ordering, deduplication, optimistic updates, and next-simulation visibility.
  • Merge the latest main and preserve its initial-load safeguards for rich-list controls.

Validation

  • bun test — 618 passed, 0 failed
  • bun run setup-chrome
  • bun run typecheck
  • bun run lint

@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

No issues found across all review agents.

@KillariDev KillariDev changed the title Serialize make-me-rich setting updates Serialize and dedupe make-me-rich setting updates Jul 10, 2026
@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

1 similar comment
@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

The hand-rolled element-by-element equality check in updateFixedMakeMeRichList is a maintainability concern: if RichListElement gains a new field in the future, the comparison will not account for it, causing the function to incorrectly report no change and skip the storage write.

return await makeMeRichSettingsSemaphore.execute(async () => {
const previous = await getFixedAddressRichList()
const next = update(previous)
if (previous.length === next.length && previous.every((element, index) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maintainability concern: the hand-rolled element-by-element equality check only compares address, makingRich, and type. If RichListElement gains a new field, this comparison must be manually updated — otherwise a real change in the new field would be missed, causing the function to return false (no change) and skip the storage write. Consider a more robust comparison approach that automatically covers all fields.

@KillariDev KillariDev changed the title Serialize and dedupe make-me-rich setting updates Make rich-mode toggles fast and serialized Jul 10, 2026
@KillariDev KillariDev force-pushed the t3code/83482476 branch 8 times, most recently from 6ea82dd to 861e022 Compare July 10, 2026 09:48
- add atomic settings updates for rich-list state
- preserve concurrent user edits while tracking previous active address
- make repeated rich-address adds idempotent without reordering entries
- avoid full popup visualization refreshes when rich mode changes
- keep new rich balance overrides visible to the next simulation input
@KillariDev KillariDev changed the title Make rich-mode toggles fast and serialized Serialize rich-mode toggles without eager refresh Jul 10, 2026
@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

The equality comparison infrastructure introduced in settings.ts is over-abstracted and fragile. The ComparableRichListElement mapped type is structurally identical to RichListElement (an identity type adding indirection with no benefit), and the comparableRichListElement function manually copies only the three current fields of RichListElement. When RichListElement (defined as a funtypes.ReadonlyObject schema in storageUtils.ts) gains a new field in the future, this manual copy will silently drop it, causing richListElementsEqual to incorrectly consider two elements equal. This has a real consequence: updateFixedMakeMeRichList uses richListElementsEqual to decide whether to skip writing to storage — a silently incorrect equality result would skip a necessary storage write, leaving persisted state stale and difficult to trace. Consider simplifying to direct field comparison or reusing the existing arePropValuesEqual utility from typed-arrays.ts (which would need to be exported first).

}

function comparableRichListElement(element: RichListElement): ComparableRichListElement {
return {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comparableRichListElement function manually copies three fields (address, makingRich, type) from RichListElement. Since RichListElement is defined as a funtypes.ReadonlyObject schema in storageUtils.ts, adding a new field to that schema in the future would cause this function to silently drop it. richListElementsEqual (line 181) would then incorrectly consider two elements equal even when they differ in the new field. This has a real consequence: updateFixedMakeMeRichList (line 187) uses richListElementsEqual to decide whether to skip writing to storage (return false means no write), so a silently incorrect equality result would skip a necessary storage write, leaving persisted state stale. The ComparableRichListElement mapped type (line 169) is also an identity type — [Key in keyof RichListElement]: RichListElement[Key] produces a type structurally identical to RichListElement, adding indirection with no benefit. Consider direct field comparison (first.address === second.address && first.makingRich === second.makingRich && first.type === second.type) or reusing the existing arePropValuesEqual utility from typed-arrays.ts (currently not exported).

# Conflicts:
#	app/ts/background/popupMessageHandlers.ts
#	app/ts/components/pages/Home.tsx
@KillariDev KillariDev changed the title Serialize rich-mode toggles without eager refresh Serialize make-me-rich settings updates without eager refresh Jul 16, 2026
@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

The Architect agent identified an over-abstraction concern in the new equality-checking code in settings.ts. The other three agents (Security, Bug Hunter, Defender) found no issues.

Comment thread app/ts/background/settings.ts Outdated

type ComparableRichListElement = {
[Key in keyof RichListElement]: RichListElement[Key]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The ComparableRichListElement mapped type is structurally identical to RichListElement ({ [Key in keyof RichListElement]: RichListElement[Key] } produces the same type), and comparableRichListElement reconstructs an object with the same three fields. This adds a type, a function, and an indirection layer for zero architectural benefit. Additionally, richListElementsEqual relies on Object.values enumeration order for correctness — while stable in V8 for string-keyed properties, it is not guaranteed by the type system or the RichListElement schema. If RichListElement gains a new field, this function will silently compare it with ===, failing for non-primitive types. A direct field-by-field comparison would be explicit and resilient to schema evolution. This also introduces a third change-detection strategy (deep comparison via Object.values) alongside the existing reference-equality approach used in updateWebsiteAccess, growing inconsistency in the semaphore-protected-update pattern.

@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

No issues found across all review agents.

@KillariDev KillariDev requested a review from MicahZoltu July 16, 2026 12:26
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