Skip to content

feat(columns): one-click JSON export of cached column items - #56

Merged
aaronjmars merged 1 commit into
mainfrom
feat/column-data-export
Jun 1, 2026
Merged

aaronjmars merged 1 commit into
mainfrom
feat/column-data-export

Conversation

@aaronjmars

Copy link
Copy Markdown
Collaborator

What

Adds a "Download items (JSON)" entry to every column's More-menu dropdown. Click it and the column's cached items array is serialized to pretty-printed JSON and saved via the browser's native download dialog — no server round-trip, no new schema, no migration.

Why

  • Repo-actions idea Add Rednote (Xiaohongshu) column type #5 from 2026-05-30
  • 47+ column types now ship (crypto prices, GitHub signals, social feeds, news, DeFi TVL). Power users and analysts using minitor as a monitoring hub frequently want the raw fetched data for spreadsheets, re-processing, archiving, or sharing — but there was no export path. Data was effectively trapped in the browser.
  • Zero infrastructure cost: items are already in the Zustand store, the export is pure client-side blob → object URL → synthetic <a download> click.

Changes

  • lib/store/use-deck-store.ts (+58):
    • New downloadColumnItems(columnId: string): number store action — reads columns[columnId].items from store state, serializes a versioned envelope (schema: "minitor.column-export.v1", exportedAt, column: {id, typeId, title}, itemCount, items), creates a Blob with application/json, triggers a synthetic download, revokes the object URL immediately after the click. Returns the item count so the caller can surface a toast.
    • Returns 0 when there are no cached items — the menu entry should be disabled in that case (column-card.tsx does this), but the store guards against an unexpected call anyway.
    • SSR-safe: bails immediately if typeof window === "undefined".
  • components/column/column-card.tsx (+17):
    • Added Download icon import from lucide-react.
    • Added downloadColumnItems selector + hasItems derived flag.
    • New <DropdownMenuItem> between Rename and Delete: disabled when !hasItems (label reads "No items loaded yet" in that state, "Download items (JSON)" otherwise), triggers a success toast on download.

Filename format

{title-slug}-{YYYY-MM-DD}.json — e.g. defillama-tvl-2026-05-31.json. Slug is the column title lowercased, non-alphanumerics collapsed to -, trimmed, capped at 64 chars; falls back to column for titles that slug to empty.

What's NOT in this PR

  • CSV export — the FeedItem shape is plug-in-specific (meta?: TMeta), so a generic CSV flattener would either drop meta or smear shapes. JSON-first lets the existing items round-trip losslessly; CSV is a follow-up when there's a concrete use case naming a specific plugin.
  • Schema validation on re-import — this is a one-way export. Reading exports back in is a separate (and more dangerous) story; deliberately out of scope.

Built autonomously by Aeon — feature skill, 2026-05-31

@aaronjmars
aaronjmars force-pushed the feat/column-data-export branch from 969263c to 0955500 Compare June 1, 2026 13:02
@aaronjmars
aaronjmars merged commit 584f712 into main Jun 1, 2026
1 check passed
@aaronjmars
aaronjmars deleted the feat/column-data-export branch June 1, 2026 13:02
aaronjmars added a commit that referenced this pull request Jun 4, 2026
…tings (#60)

* feat(columns): per-column duplicate — clone a column with all its settings

Adds a "Duplicate" entry to every column's More-menu dropdown. Click →
the source column's persisted settings (typeId, config, alertKeywords,
notifyWebhookUrl, refreshIntervalSeconds, filterKeywords, excludeKeywords,
tabGroup) clone into a new column titled "<source> (copy)" inserted
immediately after the source in the same deck.

What it pairs with
==================
6th rung on the per-column UX axis:
  May-29 tab groups (#53)        — "which group am I looking at"
  May-30 collapse (#55)           — "how prominent within the group"
  May-31 JSON export (#56)        — "get the data out"
  Jun-02 quick-search (#58)       — "find an item in this column"
  Jun-03 pin-to-front (#59)       — "always visible regardless of tab"
  Jun-04 **duplicate (this PR)**  — "fork this column to view it twice"

The common operator move: maintain two CoinGecko columns for BTC and ETH,
two GitHub repo columns for two different repos, two RSS columns with
different include filters. Before this PR the operator had to add a
brand-new column and re-enter every config field. After this PR: 1 click,
optionally tweak in Configure, done. The Configure dialog is exactly
where the operator drifts to next — the existing config form needed no
changes to support this flow.

Implementation
==============

**Server (`app/actions.ts`, +77).** New `duplicateColumn(sourceId,
newId, newTitle)` server action:
- captureDeckSnapshot before the structural mutation — same reversibility
  contract as createColumn / deleteColumn / reorderColumnsInDeck. Version
  history catches an accidental duplicate
- Shifts every column with `position > src.position` right by 1
  (`UPDATE columns SET position = position + 1`) so the duplicate can
  land at `src.position + 1` without renumbering the whole deck
- Inserts the new row inheriting every persisted setting. Inherits
  `notifyWebhookUrl` (this is an in-install copy not an export, so the
  secret stays inside the trust boundary it was already configured
  within). Pinned is deliberately NOT inherited
- Title `.trim().slice(0, 256)` — same 256-char cap as renameColumn so
  a long-source title can't silently expand on copy
- Returns `ImportedDeckColumn | null` — the shape importDeck already
  emits, so the store layer can rehydrate optimistic state from the same
  type that round-trips through every other column-create path

**Store (`lib/store/use-deck-store.ts`, +69).** New `duplicateColumn`
zustand action:
- Reads source from state, locates the owning deck by scanning
  `decks[*].columnIds` (columns are a flat map across decks — no
  parent-deck field on the column itself)
- Generates a new id via nanoid and a title of `"<source> (copy)"`
  identical to the server cap
- Optimistic state: inserts the new column right after the source in
  `decks[deckId].columnIds[]` so the visual order matches where it will
  land server-side after the position shift + insert
- Fires the server action via the same `fireAndLog` pattern as every
  other mutation; the returned `ready` promise lets autoFetchColumn
  wait for the FK to exist before persisting feed_items (same race
  guard addColumn already needs)
- Returns `{ id, ready } | null` so callers can decide whether to
  surface the new column on creation (consistent with addColumn's
  return shape)

**UI (`components/column/column-card.tsx`, +14).** "Duplicate" entry
in the More dropdown, between Rename and Download (item) — natural
ordering: rename in place, then a structural action that creates a new
column with the existing config, then the read-only export. Uses the
lucide-react `Copy` icon (newly imported alongside the existing pin /
download / settings glyphs). Toast on success names the new column so
the operator can spot which row appeared mid-deck.

Decisions
=========

1. **Insert after source, not at end.** Inserting at end forces the
   operator to drag-scroll to find their copy in a 15-column deck — the
   opposite of what a duplicate action is for. The position-shift is one
   extra UPDATE; the UX cost of "where did my copy go" dwarfs the SQL
   cost.

2. **Inherit notifyWebhookUrl, drop pinned.** Pinning is a deliberate
   "this is a primary column" decision; mirroring PR #59's "DnD across
   pin/unpin no-op — Pin checkbox is the explicit boundary affordance"
   rule, crossing the pinned boundary always requires the operator's
   explicit say-so. notifyWebhookUrl is install-private and we're staying
   inside the same install — duplicate is not an export, the secret never
   leaves the trust boundary.

3. **Title `"(copy)"` not `"Copy of X"`.** Same as finders + most cloud
   doc apps — postfix reads better mid-deck because the column header
   shows the original title first and the disambiguator second. Operator
   can rename via the existing Rename action.

4. **No DB schema change.** Reuses the existing columns table — same
   pattern as PR #58 (quick-search, view-state only) but persistent
   instead of ephemeral. No migration. No version-bump. No round-trip
   risk: a duplicated column is just a new column row, exported and
   imported identically to any other.

Could NOT run Next 16 build/typecheck (offline sandbox — same constraint
as PRs #49/#50/#51/#52/#53/#55/#56/#58/#59). Manual review against the
existing column-card / use-deck-store / actions patterns only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(columns): wrap duplicate shift+insert in a transaction; copy config

The position-shift UPDATE and the INSERT were two separate awaited
statements — a crash between them left later columns shifted right with no
duplicate filling the gap. Wrap both in db.transaction(), mirroring importDeck.
Also shallow-copy config in the optimistic store insert so the clone never
shares the source's config object reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: aeonframework <aeonframework@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@aaronjmars aaronjmars mentioned this pull request Jun 5, 2026
7 tasks
aaronjmars added a commit that referenced this pull request Jun 5, 2026
* feat: per-column color labels

7th rung on the per-column UX axis after tab groups (PR #53) → collapse
(PR #55) → JSON export (PR #56) → quick-search (PR #58) → pin (PR #59)
→ duplicate (PR #60) → **color labels (this PR)**.

Per-column 6-hex color label (e.g. #f97316). When set, the column
renders a small color dot beside its title in the expanded header and
replaces the brand accent gradient at the top of the collapsed strip
with the operator's chosen color. Lets operators apply a group-level
color code at a glance (DeFi orange, GitHub repos blue, social purple,
news yellow) for instant deck scanning at 10–15 columns per deck.

Independent of tab groups (hide/show) and pin (reorder): color is the
"what kind of column is this" marker layered on top of both. A pinned
collapsed orange column stays pinned + collapsed + orange.

10 files +205:
  - drizzle/0008_column_color.sql + meta/0008_snapshot.json + journal
    (additive nullable text column; existing rows backfill to NULL =
    no color = default brand accent — no churn on existing decks)
  - lib/db/schema.ts: text("color") field
  - lib/columns/types.ts: Column.color?: string with full doc on the
    visual semantics + server-side hex normalization rule
  - lib/deck-templates.ts: DeckTemplateColumn.color?: string so starter
    decks can ship pre-colored lanes
  - app/actions.ts: COLOR_HEX_RE + normalizeColumnColor() canonical
    server-side validator (lowercased, 6-hex only — 3-hex shorthand
    and named colors deliberately rejected so the stored form is
    canonical); updateColumnColor() server action; importedColumnSchema
    Zod regex + importDeck re-validates through the normalizer (drop
    invalid like notifyWebhookUrl's SSRF guard, never abort the
    import); exportDeck emits when set; duplicateColumn inherits
    color (unlike pinned which doesn't — color is a labeling decision,
    pin is a routing decision); loadSnapshot maps the field through
    to the wire shape
  - lib/store/use-deck-store.ts: updateColor() optimistic action
    mirroring server normalization; importedDeckPatch + duplicateColumn
    optimistic mirror; serverUpdateColor + normalizeColumnColor imports
  - components/column/configure-column-dialog.tsx: new "Color label"
    field with 8 preset swatches (orange/green/blue/purple/pink/yellow/
    cyan/slate) + Clear button + freeform hex input with live
    validation; invalid hex shows inline error and disables save until
    cleared or fixed
  - components/column/column-card.tsx: (a) expanded header — 10px
    circular color dot next to the title when set; (b) expanded header
    accent gradient at top uses column.color when set, falls back to
    type.accent; (c) collapsed strip accent gradient same fallback —
    a collapsed column with color set is instantly identifiable as
    "that orange one" without reading the rotated title

Three key design decisions:
  1. **Color IS inherited on duplicate; pinned is NOT.** Color = visual
     labeling ("what kind of column?"); pin = routing ("is this a
     primary column?"). Duplicating a DeFi-orange column should give
     you another DeFi-orange column. Mirrors the cleaner version of
     PR #59/#60's pin/lane distinction.
  2. **Server-authoritative hex regex.** /^#[0-9a-f]{6}$/i applied at
     both updateColumnColor and importDeck normalization, lowercased,
     6-hex only. A tampered or hand-edited export can never smuggle a
     non-canonical color (named CSS colors, 3-hex shorthand,
     non-hex input, JS expressions in style) into the DB.
  3. **Round-trips through export / import / share links + snapshots.**
     Same shape as PR #59's pinned (DB-backed, not view-state) because
     color is a persistence decision about the deck's identity — view-
     state would re-create the problem the feature exists to solve.
     Deck snapshots already serialize via exportDeck so version history
     restores colors with no migration on existing snapshot rows.

Could NOT run Next 16 build/typecheck (offline sandbox — same constraint
as PRs #49/#50/#51/#52/#53/#55/#56/#58/#59/#60). Manual review only.

* fix(import): don't abort deck import on a malformed column color

importedColumnSchema validated `color` with .regex(COLOR_HEX_RE), so a single
bad color in a hand-edited or shared payload failed safeParse and threw,
aborting the entire deck import — the opposite of the documented "dropped, not
fatal" contract, and inconsistent with how notifyWebhookUrl is handled.

Relax the Zod field to a loose .max(64) bound (mirroring notifyWebhookUrl) and
let the imperative normalizeColumnColor(c.color) in importDeck drop invalid
values to null. Behavior now matches the inline comments and the graceful
degradation the PR describes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: aeonframework <aeon@aeonframework.dev>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aaronjmars added a commit that referenced this pull request Jun 7, 2026
…-column UX axis (#63)

Per-column three-step width override: narrow (240px), normal (360px,
historical default), wide (480px). Selectable from each column's
More-menu dropdown — three entries between Download items and Delete,
each showing a Check icon next to the active width. Width is view-state
only, NOT persisted (same lifetime as collapsedColumnIds and
searchByColumn) — reload returns every column to 360px, deck export /
import / share-links carry no width data.

A crypto price column is densest narrow (~180px content fits at 240);
a news feed reads best wide (headline text wraps badly at 360). Three
discrete sizes cover the real spread without a drag-resize handle that
would compound poorly with collapse (PR #55) and pin (PR #59).

8th rung on the per-column UX axis (tab groups May-29 PR #53 → collapse
May-30 PR #55 → JSON export May-31 PR #56 → quick-search Jun-02 PR #58
→ pin Jun-03 PR #59 → duplicate Jun-04 PR #60 → color Jun-05 PR #61 →
width).

Key design decisions:
  1. View-state, not DB-backed — matches the rule used for collapse /
     search / selected tab. Going DB-backed would mean a migration,
     server action, DECK_EXPORT_VERSION bump, round-trip through every
     export/import/share-link/snapshot path — none of that pays for
     itself for an ergonomic-only knob.
  2. Three steps, not a drag-resize handle — continuous resize compounds
     poorly with collapse (where does collapse expand restore to?), pin,
     and color label affordances.
  3. Default unchanged — null branch is character-identical to the prior
     single class. Every existing column renders pixel-identical until
     the operator opts in.
  4. Mobile clamps regardless of width override — a 480px wide column
     would overflow a phone viewport; mobile keeps the min(360, vw-1rem)
     clamp on narrow + wide too.
  5. Collapse owns its 48px strip — width re-applies on expand from the
     in-memory map.
  6. Same-width re-click is a no-op (returns prior state object) so
     React skips re-render on a hot menu path.

2 files +109/-2. NO DB schema, NO migration, NO server round-trip, NO
plugin contract touched, NO version bump on DECK_EXPORT_VERSION.

Could NOT run Next 16 build/typecheck (offline sandbox — same constraint
as PRs #49/#50/#51/#52/#53/#55/#56/#58/#59/#60/#61/#62).

Co-authored-by: Aeon <aeon@aeonframework.dev>
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