Skip to content

Refactor template-search tab preference infra to export only a factory - #1467

Merged
marcuscastelo merged 3 commits into
rc/v0.16.0from
copilot/marcuscastelo-encapsulate-infra-exports
Mar 24, 2026
Merged

marcuscastelo merged 3 commits into
rc/v0.16.0from
copilot/marcuscastelo-encapsulate-infra-exports

Conversation

Copilot AI commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

The template-search infrastructure was exposing its localStorage implementation details directly. This refactor narrows the public surface to a single factory and updates consumers to depend on the adapter shape instead of file-level helpers.

  • Infrastructure encapsulation

    • Replaced direct exports from templateSearchTabPreference.ts with a single createTemplateSearchTabPreference() factory.
    • Kept DEFAULT_TAB, validation, and localStorage load/save helpers file-local.
  • Call-site update

    • Updated TemplateSearchModal to consume the factory-backed preference adapter.
    • Reused one adapter instance instead of importing persistence helpers directly.
  • Test alignment

    • Reworked the dedicated infrastructure tests to verify behavior through the exported factory only.
    • Removed assertions tied to non-public internals like DEFAULT_TAB.

Example of the new public API:

import { createTemplateSearchTabPreference } from '~/modules/template-search/infrastructure/templateSearchTabPreference'

const tabPreference = createTemplateSearchTabPreference()

const persistedTab = tabPreference.loadTabPreference()
tabPreference.saveTabPreference('favoritos')

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • test.supabase.co
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/macroflows/macroflows/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development /home/REDACTED/work/macroflows/macroflows/node_modules/.pnpm/tinypool@1.1.1/node_modules/tinypool/dist/entry/process.js flint /usr/local/bin/ps k/macroflows/macsort (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>template-search: Encapsulate infra exports — export only factories</issue_title>
<issue_description>## Summary

Refactor the template-search module infrastructure to encapsulate implementation details: export only factory functions and keep helper functions file-local.

Part of #1403

Scope / Representative files

  • src/modules/template-search/infrastructure/templateSearchTabPreference.ts

Deliverables & Acceptance Criteria

  • Only factories exported, call-sites updated, TypeScript/lint/tests pass.
    </issue_description>

<agent_instructions>pnpm check always green</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel

vercel Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
macroflows Ready Ready Preview, Comment Mar 24, 2026 8:52pm

Copilot AI and others added 2 commits March 24, 2026 20:45
Copilot AI changed the title [WIP] Refactor template-search module to encapsulate infra exports Refactor template-search tab preference infra to export only a factory Mar 24, 2026
Copilot AI requested a review from marcuscastelo March 24, 2026 20:50
@marcuscastelo
marcuscastelo marked this pull request as ready for review March 24, 2026 20:52
Copilot AI review requested due to automatic review settings March 24, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the template-search tab preference persistence infrastructure to encapsulate localStorage details behind a single exported factory, updating the UI consumer and tests to interact only through that public API.

Changes:

  • Replaced direct exports (loadTabPreference, saveTabPreference, DEFAULT_TAB) with a single createTemplateSearchTabPreference() factory.
  • Updated TemplateSearchModal to use a factory-created adapter instance for loading/saving the selected tab.
  • Updated infrastructure tests to validate behavior only via the exported factory.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/sections/search/components/TemplateSearchModal.tsx Switches from direct helper imports to a factory-created preference adapter instance.
src/modules/template-search/infrastructure/templateSearchTabPreference.ts Makes persistence helpers file-local and exposes only createTemplateSearchTabPreference() as the public API.
src/modules/template-search/infrastructure/tests/templateSearchTabPreference.test.ts Refactors tests to exercise persistence behavior exclusively via the factory-created adapter.

@marcuscastelo
marcuscastelo merged commit 88ef4b7 into rc/v0.16.0 Mar 24, 2026
11 checks passed
@marcuscastelo
marcuscastelo deleted the copilot/marcuscastelo-encapsulate-infra-exports branch March 24, 2026 21:15

This branch was successfully deployed

1 active deployment
Preview — 5a980855 Deployed Mar 24, 2026 by vercel[bot]
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.

template-search: Encapsulate infra exports — export only factories

3 participants