Skip to content

Latest commit

 

History

History
206 lines (147 loc) · 7.84 KB

temporary-code.md

File metadata and controls

206 lines (147 loc) · 7.84 KB

Temporary code cleanup

This document tracks code that is intentionally temporary and is expected to be removed once a specific dependency, platform constraint, or migration window goes away.

Each section should name:

  • what is temporary
  • where it currently lives
  • what removes the need for it
  • what should stay after the cleanup

Temporal polyfill

The task scheduling layer uses @js-temporal/polyfill today, not because the app wants an abstraction over Temporal, but because the repo still needs a portable implementation that works across the current browser and runtime set.

The goal is to keep Temporal-based code and remove only the polyfill once the app can rely on native Temporal everywhere it cares about.

Current temporary dependency

  • package dependency: @js-temporal/polyfill
  • current import site: src/lib/task-schedule.ts

If more files start importing the polyfill directly, add them to this list so the eventual cleanup stays explicit.

What to remove when native Temporal is enough

  1. Remove @js-temporal/polyfill from package.json.

  2. Update the lockfile by running the normal package-manager uninstall flow.

  3. Replace imports shaped like:

    import { Temporal } from '@js-temporal/polyfill';

    with code that reads Temporal from the native global instead.

  4. Remove any compatibility comments that exist only to explain the polyfill.

  5. Re-run the full verification loop, including any browsers the project still supports in Playwright.

What should stay

  • The Temporal-based scheduling model itself.
  • The owner-local wall-clock storage model.
  • The task timezone ownership rules.
  • Any tests that pin recurrence behavior, DST handling, or timezone-relative scheduling outcomes.

The cleanup is specifically polyfill removal, not a rewrite away from Temporal.

Kink list fantasy and doing as numbers

The kink list's into it as a fantasy and into actually doing it were 0–4 sliders during development, and are now levels on the answer's own scale (docs/kink-list.md). Lists saved in between still hold the numbers.

Current temporary code

  • OLD_INTEREST_STEPS and the z.preprocess in detailSchema, in src/lib/kink-list/answers.ts, which read a number as the nearest level.

What removes the need for it

The kink list has never been deployed, so only development databases and devices hold a number. Once every list there has been saved again (any answer change rewrites it in the new shape), or before the first deploy at the latest, nothing holds one.

What to remove

The preprocess and OLD_INTEREST_STEPS; fantasy and doing go back to z.enum(LEVELS).optional(), and the test that reads old numbers goes.

What should stay

The schema refusing anything that is not a level.

Kink list own kinks

Kink lists once held kinks of the person's own, from an import's unmatched rows: answers under custom:<random> keys and a custom record. They were removed (docs/kink-list.md), and lists saved in development may still hold some.

Current temporary code

  • withoutOwnKinks and the z.preprocess on answers and skipped in listPayloadSchema, in src/lib/kink-list/answers.ts, which drop those keys as a list is read. custom itself needs nothing: the schema does not name it, so Zod drops it.

What removes the need for it

The kink list has never been deployed, so only development databases and devices hold one. Once every list there has been saved again, or before the first deploy at the latest, nothing does.

What to remove

withoutOwnKinks and both preprocesses, and the test that reads a list with own kinks in it.

What should stay

The schema refusing a key that is not a catalogue id.

Server settings from the environment

The server's secrets, email and model providers moved from environment variables into the database (docs/server-settings.md). So that existing deployments carry over — production's BETTER_AUTH_SECRET above all, since a new one signs everyone out and stops every recovery escrow working — each setting that has no row yet is copied once from its old variable, and the variable is ignored from then on.

Where it lives

  • src/lib/server/settings/legacy-env.ts — the import itself (legacyEnvSettings) and legacyEnvStillSet, which the admin page uses to say which old variables are still set.
  • src/lib/server/settings/index.ts — fillsFor calls legacyEnvSettings before generating anything.
  • src/routes/(auth-required)/(app)/admin/server/ — the legacyEnv load field and the envNote snippet that renders it.
  • src/app.d.ts — the old names in App.Platform['env'], under a TEMPORARY comment.
  • docker-compose.yml — the optional pass-through lines, so an upgraded self-hoster's .env is read on the first start.
  • src/lib/server/settings/index.test.ts — the "the one-time import from the environment" tests.

What removes the need for it

Production (and its previews) having started once on this build, with the admin page no longer listing any old variable as still set — at which point delete them (wrangler secret delete …, and the Preview base config's) — and enough time passed that self-hosters have upgraded through it.

Removing it

  1. Delete legacy-env.ts, and in fillsFor the loop over legacyEnvSettings.
  2. Drop the legacyEnv load field, the stillInEnv helper, the envNote snippet and each {@render envNote(…)} on the settings page.
  3. Drop the old names from App.Platform['env'] (keep OPENROUTER_BASE_URL and RUNWARE_BASE_URL, which are test seams) and the pass-through block from docker-compose.yml.
  4. Delete the import tests, and the paragraph about it in docs/server-settings.md and docs/self-hosting.md.

What stays: everything else in src/lib/server/settings/, including generating the secrets — a new server still needs nothing set.

The /home redirect

/home was the signed-in app until the Dashboard became Today, at /today (section-widgets.md). Every other old page address under /home and /partner/[id] simply 404s now, with no redirect: the worst case there is an old bookmark or notification landing on the error page and navigating on. /home itself is the one exception, and it is a 307 to /today (the query string kept). Grep for LEGACY-SPACES.

Why it is kept

An app added to the iOS Home Screen keeps the start_url it was installed with and never refetches the manifest. Every install from before the move launches at /home, so without the redirect each launch would be a 404 that reloading cannot fix — which fails the "worst case is a reload" rule the other removals were judged by. A 307 rather than a 308, so no browser caches it for good: this one is meant to go.

Where it lives

  • src/routes/home/+server.ts — the redirect, a GET with no page, so it runs no layout loads and answers before the sign-in guard.
  • src/routes/home/server.test.ts — its test, and the /home checks in e2e/today.spec.ts ("an app installed on the home screen before the move").

static/site.webmanifest's start_url is already /today, so a fresh install never touches it.

What removes the need for it

The user and their partner (production's two accounts) have removed the app from their Home Screens and added it again, so both installs start at /today. There is no server-side query for this: the server cannot see which start_url an install launches with, beyond a /home request arriving.

What to remove

  1. src/routes/home/ (the route and its test).
  2. The two /home tests in e2e/today.spec.ts, keeping the "old pages are gone" one with /home added to its list of 404s.
  3. This section, and the mentions of the redirect in docs/section-widgets.md, docs/contexts.md and AGENTS.md.

What should stay

/today as the start URL and the post-sign-in default.