Skip to content

feat(prompts): show a tracked Improve action under the Work chip - #2471

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:feat/prompts-work-improving-link
Nov 17, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:feat/prompts-work-improving-link

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

On Prompts › Tracked Prompts, a row whose prompt has an Improve action that is still being tracked now shows a small link under its Work chip, for example "AC-12 · Improving". Clicking it opens the same right-side positions panel the row menu's Improve position… opens, on its Improve tab. Rows without such an action look exactly as before, and the Work chip ("Done" / "Set status ⌄") is unchanged. There is no new column.

"Still being tracked" is the rule the panel's "Improving" chip already uses (PROMPT-008, pickImprovingAction). Both the panel and the table now read it through one shared helper.

Changes

  • web/src/lib/improving-actions.ts (new, plain module): readImprovingActions(supabase, brandId, promptIds). It reads the actions table once for up to 100 prompt ids (one table page) and gives each prompt its newest Improve action that is still tracked, using pickImprovingAction. The query skips rows that rule never picks: statuses outside new / in progress / on hold / completed, and completed actions whose final read is recorded. The server's daily sweep filters the same way, so old final reads can't fill the row limit.
  • web/src/lib/improve-outcome.ts: exports the tracked statuses (IMPROVE_TRACKED_STATUSES) so the query and pickImprovingAction share one list.
  • web/src/lib/actions/prompt-positions.ts:
    • getPromptPositions (the panel) reads its chip through the shared helper. As before, a failed read shows no chip and does not fail the panel.
    • New read-only server action getImprovingPrompts(brandId, promptIds): one call for a page of rows. It validates the ids (UUIDs, at most 100). It only exports async functions.
  • web/src/app/[locale]/(dashboard)/dashboard/prompts/_improving-link.tsx (new):
    • useImprovingPrompts: one read for the rows on screen. It reads again when the positions panel closes, so an Improve sent from the panel shows up on its row. It shows nothing until the read returns or if it fails.
    • ImprovingLink: a real <button> with an accessible name and a tooltip ("Open the Improve tab · AC-12 is still being tracked"). It is capped at max-w-24 and wraps under the chip, so it does not widen the column.
  • page.tsx: the Work cell adds the link under the existing chip and cited-URL count, and calls the existing openPositionsPanel(p.id, 'improve'). Nothing else in the table changes.
  • web/messages/en.json: prompts.columns.improving.{label,title,aria}.
  • Help: one line in help/prompts/tracked-prompts.md ("Open a prompt or act on it"), regenerated approved-articles.json.

Safety

  • Scoping: every read goes through the caller's own RLS client (dbClient). The actions query filters on brand_id. The actions and brands RLS policies only allow brands in the caller's organisation and brand access. getImprovingPrompts also reads the brand row through RLS and returns nothing if the brand isn't visible. The helper ignores any returned row whose brand_id or prompt id wasn't asked for, so another brand's action can never show.
  • Query count: one actions query per table page (up to 100 ids in one in filter, the same size prompt-positions already uses per request), plus one single-row brands read in parallel. It is never one query per row. It doesn't touch prompt_results. The filter brand_id = … and status in (…) uses the existing actions_brand_status_idx. There is no migration, new index or RPC.
  • The new server action is read-only, so the subscription guard coverage test is unaffected. use-server-exports passes.
  • One behaviour change in the panel: it used to look at the prompt's newest 10 Improve actions of any status. It now looks at every tracked, non-final one. This only differs if a prompt has more than 10 newer dismissed or final actions, and the new behaviour is the correct one there.

How to test

  1. On a brand with Tracked Prompts, open a prompt's row menu › Improve position…, generate suggestions and Send Actions. Close the panel.
  2. That row's Work cell now shows "↗ AC-NN · Improving" (the action's real code) under the status chip. Other rows are unchanged.
  3. Hover it: "Open the Improve tab · AC-NN is still being tracked". Click it, or Tab to it and press Enter: the positions panel opens on the Improve tab. Its header still shows the existing "Improving · AC-NN" chip linking to Action Center.
  4. Dismiss the action in Action Center and reload Tracked Prompts: the link is gone.
  5. Switch brand: no link from the other brand's actions appears.

Checks

  • npx tsc --noEmit -p . in web/: clean.
  • Vitest: prompts page and components (including the panel), prompt-improve*, improve-outcome, new improving-actions and actions/prompt-positions tests, src/lib/help, src/i18n, use-server-exports, subscription-guard and subscription-guard-coverage, embed-hints, actions/read-only: 38 files, 409 tests passed.
  • New tests cover:
    • The batched read returns improving only for the right prompts.
    • It is scoped to brand and organisation: another brand's action never shows.
    • It uses one actions query for 100 rows.
    • It agrees with the panel's chip for each prompt.
    • The Work cell shows the link only on those rows, from a single read.
    • Clicking the link opens the panel on the Improve tab.
  • ESLint and Prettier: clean on the changed source files. The help article and approved-articles.json are left as the generator writes them; Prettier would reflow the article's front matter.

Generated by Claude Code

On Tracked Prompts, a row whose prompt has an Improve action still being
tracked (PROMPT-008) now shows a small "AC-12 · Improving" link under its
Work chip. It opens the same positions panel the row menu opens, on its
Improve tab. Rows without one look as before; the chip is unchanged.

- lib/improving-actions.ts: readImprovingActions, the one read both the
  panel's "Improving" chip and the table use. One actions query for up to
  a page of prompt ids, scoped to the brand (and the caller's organisation
  through RLS), by pickImprovingAction's rule; the query leaves out
  statuses and final reads that rule never picks, as the server sweep does.
- getPromptPositions reads its chip through it; getImprovingPrompts (a
  read-only server action next to it) gives a page of rows in one call.
- The Work cell reads it once per page, again when the panel closes.
- Help: one line in the Tracked Prompts article.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 17, 2026
The folded usage cards used to say "46 / 50 prompt locations" in amber
or red in the Tracked Prompts bar; with the bar gone that warning was
only inside the "…" menu. The table's status line now also says
"● 46 / 50 prompt locations used · Plan & usage" when the plan's prompt
locations are nearly (amber) or fully (red) used, beside the
not-analyzed line, wrapping when both show. Plan & usage goes where the
menu's does. The menu keeps its copy.

Help: tracked-prompts says where the warning shows. Its last "Export
CSV downloads the list" line is back as it was (the new section says
where Export CSV is), which keeps it clear of ansvisor#2471's paragraph next to
it. Approved articles regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@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. Minor: the Work-cell link refreshes only when the positions panel closes, so an Improve action made in the Action Center shows after the next page change.

@gkhngyk
gkhngyk merged commit 0ea6fc7 into ansvisor:main Nov 17, 2026
13 checks passed
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.

3 participants