Skip to content

feat(prompts): let a person show, hide and order the Tracked Prompts columns, and share them with the brand (PROMPT-015, part 1) - #1655

Merged
gkhngyk merged 7 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompts-table-columns
Oct 28, 2026
Merged

gkhngyk merged 7 commits into
ansvisor:mainfrom
cihan-gyk:feature/prompts-table-columns

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

PROMPT-015, part 1 of 6: a Columns panel for Tracked Prompts. People can show, hide and order the table's columns, and share their columns with the brand.

  • A Columns button sits beside the table's search. It can show or hide every column except Prompt, and reorder them by dragging or with the arrow buttons (so it works from the keyboard).
  • The choice is saved per person and per brand in a new table, prompt_table_views (migration 00363, with RLS):
    • a member writes only their own row;
    • only an admin or manager writes the brand's row (user_id null);
    • nobody reads or writes another organisation's rows.
  • Share with everyone on (admins and managers): their columns become the brand's view. Everyone sees it until they change their own. Reset goes back to the brand's view, or to the default.
  • Pre-push review fix (d6b7e93): someone viewing the brand's shared view without a view of their own used to change the brand's view on every click.
    • A member got "Only admins and managers can share…" errors.
    • A manager hiding one column changed it for everyone.
    • Now a change updates the brand's view only when an admin or manager shared their own view, and sharing also saves it as theirs.
  • Nothing changes for someone who never opens Columns: the default is today's columns in today's order.

Where people see it: Prompts › Tracked Prompts, the Columns button above the table.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Apply 00363. Open Tracked Prompts › Columns. Hide a column and move another one; reload, and the table keeps them.
  2. As an admin, tick Share with everyone. As a member, the same view shows. Hide a column as the member: it changes only for them, with no error. Reset brings back the brand's view.
  3. As a manager with no view of their own, hide a column: only the manager's view changes.
  4. cd web && npx vitest run src/app/[locale]/(dashboard)/dashboard/prompts/_columns-panel.test.tsx src/lib/prompt-table-columns.test.ts

Browser check: local, 1024 px, light and dark.

Related issue

PROMPT-015 (location matrix and custom columns), spec and mockup in Drive › Prompt. No GitHub issue.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Full checks at the top of the stack (part 6, 29f649d):

  • server format, lint and npm test: 248 files, 3,364 tests passed;
  • web format, lint (0 errors; 7 warnings already on main), typecheck, vitest (453 files, 4,403 tests) and build: all pass;
  • schema.sql matches build-schema.sh.

A pre-push review found 9 issues; all are fixed in this stack (the fix(...) commits). Migrations 00363 and 00364 are applied on the dev database.

Follow-ups, not in this stack:

🤖 Generated with Claude Code

cihan-gyk and others added 4 commits October 28, 2026 03:46
…columns, and share them with the brand (PROMPT-015, part 1)

PROMPT-015a. A Columns panel beside the table's search:
- show or hide every column but Prompt, and reorder them by dragging or with
  the arrows;
- saved per person and brand (00363 prompt_table_views, RLS);
- an admin or manager can share their columns with everyone on the brand,
  who see them until they change their own;
- Reset goes back to the brand's view, or the default.

Nobody who never opens Columns sees a change: the default is today's
columns in today's order. The table builds its header and cells by column
id, unchanged inside.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… brand (PROMPT-015, part 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…their own view with the brand (PROMPT-015, part 1)

Someone looking at the brand's shared view without one of their own
changed it with every click: a member got "Only admins and managers can
share" errors, and a manager hiding one column changed it for everyone.
Changes now update the brand's view only after an admin or manager
shared their own, which sharing now also saves as theirs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…able (PROMPT-015, part 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit ba07b83.

Approve preview

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main forward (8356ba3) through the stack; supabase/schema.sql rebuilt. Typecheck and lint pass on the chain tip.

@gkhngyk gkhngyk 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.

Looks good, with follow-ups.

Nothing blocks the merge. Apply 00363 before this merges; the web goes out on merge.

What I checked

  • Own diff. 3f6a4d4b..293a00b2: 00363 with schema.sql and supabase.ts, prompt-table-views.ts and prompt-table-columns.ts with their tests, the Columns panel, the page's column rendering, en.json and the guide. The branch starts from an older main. On 8356ba3 only supabase/schema.sql conflicts; rebuild it. page.tsx, en.json, supabase.ts and the guide auto-merge.
  • 00363.
    • The number is free: nothing on main or in another open PR uses 00363.
    • RLS is on. anon has no grant; authenticated gets select/insert/update/delete, all filtered by the two policies.
    • Read: your own row and the brand's row (user_id null), only for a brand in your organization.
    • Write: your own row in your organization's brands; the brand's row only as an admin or manager. The with check repeats the using, so a row can't be moved to another person, another brand or another organization by an update.
    • Idempotent: create table if not exists, drop policy if exists before each policy. A new, empty table, so no locks on anything big and no backfill.
    • unique nulls not distinct (brand_id, user_id) gives one brand row per brand, serves the reads, and is what upsert(..., { onConflict: 'brand_id,user_id' }) lands on.
    • The columns check (object, at most 8 KB) bounds what a client can store.
    • bash supabase/build-schema.sh reproduces the committed schema.sql.
  • Server actions. Every read and write goes through the caller's own client, so RLS decides. The brand id is checked as a UUID, and the view is checked against the known column ids with a length cap. A write RLS filters to nothing comes back as forbidden, not as a silent success.
  • Behaviour. Someone without a view of their own sees the brand's view, and changing it saves only theirs (d6b7e93). The brand's view changes only while an admin's or manager's own view matches it. With no rows, the columns and their order are today's. Unknown ids in a stored view are dropped, and a column added later goes back to its default place.
  • Tests and checks. The PR's tests pass (_columns-panel, prompt-table-columns, prompt-table-views, and the rest of the prompts folder: 10 files, 66 tests). Web tsc is clean. eslint and prettier are clean on the touched files.

Follow-ups

  1. "Shared" is inferred, not stored. _columns-panel.tsx:65 treats an admin's or manager's view as linked to the brand's whenever the two are equal. A second manager whose own view happens to match the brand's (for example after undoing a change) then updates the brand's view on every later click, without having ticked Share. Store who shared it (updated_by on the brand row is there) and link only that person, or keep an explicit flag.
  2. updated_by is client-supplied. The policies don't check it, so a member can write any user id there on their own row. Nothing reads it today; if it's ever shown ("Shared by …"), set it in a trigger from auth.uid().
  3. Two saves, no rollback. A change while shared saves your row and the brand's separately. If one fails, the toast shows, but the two silently diverge and the link drops. Low impact; a single RPC would keep them together.

Rollout

Apply 00363 before merging. Without the table, the page shows today's columns (the read is caught), but every change in Columns shows "Couldn't save your columns."

@gkhngyk
gkhngyk merged commit 615656b into ansvisor:main Oct 28, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants