Skip to content

fix(signals): label each figure with the window its detector reads - #1069

Merged
gkhngyk merged 24 commits into
ansvisor:mainfrom
cihan-gyk:fix/signal-change-periods
Oct 17, 2026
Merged

gkhngyk merged 24 commits into
ansvisor:mainfrom
cihan-gyk:fix/signal-change-periods

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #1066, which sits on #1065, #1064, #1063, #1061, #1060, #1059 and #1058. Please review the last commit, fix(signals): label each figure with the window its detector reads, or merge those first.

The signal drawer's What changed block labelled some traffic findings with the wrong period. The detectors read three window lengths:

Read Window Findings
ctx.gsc() (ae_gsc_queries) last 28 days against the 28 before gsc_demand_gap, search_ai_misalignment, gsc_low_ctr, gsc_risk, gsc_decline; search clicks on cross_channel_risk
ctx.traffic() (TRAFFIC_WINDOW_DAYS) last 14 days against the 14 before AI sessions on ai_traffic_drop, cross_channel_risk, visibility_traffic_loss
ctx.dimensions() (library.windowDays) last 7 days against the 7 before mentions on visibility_traffic_loss

What was wrong:

  • The five Search Console findings fell through to the counted fallback and read "Last 7 days".
  • cross_channel_risk and visibility_traffic_loss read "Last 7 days against the 7 days before" for every figure, although one finding mixes two windows.
  • The before and after boxes said "previous 7 days" / "last 7 days" whatever the period, so even the AI-traffic drop fixed in feat(signals): show where a page's AI visits come from and its prompts #1066 still showed 7 days in its boxes.

What changed (web/ only):

  • Two new periods: four_weeks_over_four_weeks ("Last 28 days against the 28 days before") and last_four_weeks ("Last 28 days"). They follow the fortnight_over_fortnight / last_fortnight pattern.
  • Search Console findings are labelled last_four_weeks.
  • Where one finding mixes windows, each figure can carry its own period:
    • The change's period comes from its AI sessions (always 14 days).
    • Search clicks carry four_weeks_over_four_weeks.
    • Mentions carry week_over_week.
    • The drawer prints a figure's own period above its row when it differs.
  • Before and after labels now take the period's days: "previous {days} days", "last {days} days".
  • list_signals returns each figure's period, falling back to the change's, and its description says so.

Related issue

None. Follow-up to #1060 and #1066.

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. Open Action Center → Signals with a cross_channel_risk signal. For a local test row, use payload {"entity":"pages","targets":[{"id":"site","label":""}],"clicksBefore":900,"clicksNow":600}, previous 120 and current 80.
  2. Open its drawer. What changed shows:
    • "Last 14 days against the 14 days before", with "AI referral sessions · previous 14 days" and "· last 14 days".
    • Under it, "Last 28 days against the 28 days before", with "Search clicks · previous 28 days" and "· last 28 days".
  3. Open a Search Console finding such as gsc_decline (entity queries). It reads "Last 28 days".
  4. Open any 7-day finding, such as a platform drop. It still reads "Last 7 days against the 7 days before" and "previous 7 days" / "last 7 days".

I checked steps 1–4 in the browser at 1024px, in light and dark, against temporary demo rows that I deleted afterwards. At that width the AI sessions row wraps onto two lines. It did that before this change too, with the 7-day labels.

Tests:

  • detail.test.ts: the Search Console periods, the per-figure periods of both cross-channel findings, and each figure's period from the API.
  • signal-detail-blocks.test.tsx: the drawer names both windows of a cross-channel finding.

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

yarn test passes (621 tests). yarn build passes with CI's placeholder STRIPE_SECRET_KEY.

🤖 Generated with Claude Code

cihan-gyk and others added 9 commits October 15, 2026 14:20
…ls by platform

The Signals list never said which AI platform or location a signal was
about, and named platforms by their raw ids ("Visibility dropped on
gemini-web", "Weak in JP"). Part one of AC-002:

- Each row's Affected cell gets a line with the engines and locations the
  signal is about: from the payload for platform and country signals, and
  from the prompts' tracked platforms and locations for prompt and topic
  signals. A line rather than a column keeps the table within the page
  beside a pinned sidebar.
- Platforms and locations read as people know them ("Gemini", "Japan").
- Descriptions carry the measured fact instead of a generic sentence, e.g.
  "Your mention rate fell from 34% to 18% against the week before."
- A Platform filter, search over platform and location names, and
  platforms and locations columns in the CSV export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A brand can track the same prompt text as several prompts, and the
detectors write one signal per prompt: on production one pass wrote ten
identical "Citations lost for '…'" rows, which read as duplicates and
inflated every count. Part two of AC-002:

- Signals of one kind, about one prompt text (case, spacing and the
  closing "?" ignored), found in one pass are one row with a "×N grouped"
  toggle. Opened, it lists each copy with its topic, place and status; each
  copy keeps its own drawer and menu, and the group's menu acts on the
  copies it applies to.
- The category tabs, the tab badge and the summary cards count groups.
  Migration 00141 adds signal_group_key (the same rule as
  lib/signals/group.ts), counts signals_summary over groups, where a group
  is resolved only once every copy is, and adds signals_new_count for the
  badge.
- A drawer opened from a link to a copy opens its group.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hat it rests on

The signal drawer showed bare numbers ("0 → 251 +167") and no platform,
location, page or action. Part one of AC-001: the drawer has three blocks.

- Where: the fields the spec asks per category (prompt, topic, platforms,
  locations, domain, competitor, pages, queries, and for a lost citation
  the page cited before and who is cited now). A field no detector records
  yet says "Not available"; platforms read from a signal's prompts say
  "Tracked on".
- What changed: every figure with its metric, whose or which window, and
  unit, over its period: "Mention rate · previous 7 days 34% → last 7 days
  18%, −16 pts". A source domain's three counts are named instead of read
  as a before and after. A fall in the brand's own numbers is red, a
  competitor's rise too (the old colouring showed drops as good news).
- Evidence and links: the page behind the signal (the prompt's answers, the
  topic, Citations…), first and last detection, and the actions using it.

MCP list_signals returns the same detail per signal (where, change,
evidence, used_by_actions) beside the raw row, from lib/signals/detail.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A lost citation was recorded with its prompt only, so the drawer could not
say which page lost its citation, where, or who replaced it. Part two of
AC-001, for lost citations:

- The recorder reads the lost prompts' answers back (server
  signals/lost-citation-evidence.js) and writes, with the signal: the
  platforms and locations it was lost on, the brand's page cited before
  with its position and last cited date, the pages cited in the quiet
  answers with their position and how many of the answers read cite them,
  and its cited days before and since. Best effort, and a night whose read
  fails keeps the evidence an earlier night recorded.
- The drawer shows them: Platforms and Locations (where it was lost),
  "Your page cited before", "Cited now", and "Cited days · earlier 9 / 11
  → latest 0 / 3". A loss on one platform names it in the title ("Citations
  lost on ChatGPT for …"), and the row says which page is no longer cited.
- MCP list_signals returns the same evidence.
- ownDomainMatcher is the own-domain rule countOwnDomainCitations already
  used, now shared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A competitor signal named the competitor and one number, so the drawer had
"Not available" for positions by prompt and the sources behind its wins.
Part two of AC-001, for competitor signals (leads, gaining, surge,
crossed, overtaken, citation gap):

- Migration 00142 adds ae_competitor_positions: per competitor, the prompts
  and platforms where it is level with or ahead of the brand, with both
  positions this week and last, from the daily rollups (harmonic mean of
  mention positions). Service role only, like the other detector reads.
- The recorder writes, with each competitor signal, those positions and the
  domains most cited in the latest answers the competitor wins (named, the
  brand not). Best effort, and an earlier night's evidence is kept when a
  read fails.
- The drawer shows "Positions by prompt" ("ChatGPT · Profound #1 ↑2 · You
  #3 ↓1", "You — lost"), coloured as news for the brand, the platforms it
  leads on, and "Sources behind their wins". MCP list_signals returns them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The "Brand mentioned without citation" signal listed prompt ids only, so
the drawer had "Not available" for the mention's platform, position,
sentiment and excerpt. Part two of AC-001, for mention signals:

- The detector lists its prompts most mentioned first (prompt id breaks
  ties), and the recorder describes the first five: the platforms whose
  answers name the brand without citing it, the brand's median position,
  the answers' most common sentiment, how many answers, and a quote of the
  newest answer that names the brand (trying the next two if it doesn't).
  Best effort; a failed text read keeps the rest, and an earlier night's
  evidence is kept when a read fails.
- mentionExcerpt quotes an answer around the brand's first mention with the
  mention count's own matching, without links or markdown marks, cut on
  whole words.
- The drawer lists "Mentions by prompt" (prompt, platforms, #position,
  sentiment, answers, the quote and where it is from). Platforms and
  locations are each labelled by what they say: the platforms that mention
  the brand, the locations where the prompts are tracked. MCP list_signals
  returns the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts on

The audits family now records, per page, each failed check's label and
evidence. The AI bot access check names the bots robots.txt blocks, read
group by group: the old text-window scan took the next group's rules for
an allowed bot's. The drawer shows the issue, the affected crawlers for a
blocked-crawler finding, and what each check found, page by page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Traffic signals now record, for their first pages, AI-referred visits
by platform over the last 14 days against the 14 before, and the active
prompts that name any of their pages as the target URL; site-wide ones
record the site's visits by platform. One read (ae_page_traffic_evidence)
matches the detector's pages as written and a page opportunity's as a
path. The drawer shows both, and the AI-traffic findings now say they
compare 14 days.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The What changed block said "Last 7 days" for findings read over longer
windows. The Search Console findings (gsc_demand_gap,
search_ai_misalignment, gsc_low_ctr, gsc_risk, gsc_decline) count queries
over the last 28 days, and the cross-channel findings read AI sessions over
14 days against 14, search clicks over 28 against 28 and mentions over 7
against 7.

Add the 28-day periods, give a figure its own period where it differs from
the change's, name the days in the before and after labels, and return
each figure's period from list_signals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 15, 2026
cihan-gyk and others added 15 commits October 15, 2026 19:50
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00128 migration as well
as the stack's 00141-00143.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00129 migration as well
as the stack's 00141-00143. web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00123, 00124, 00130 and
00147 migrations as well as the stack's 00141-00143. web/messages/en.json
and web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00131 and 00149
migrations as well as the stack's 00141-00143. web/messages/en.json and
web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00132 migration as well
as the stack's 00141-00143. web/messages/en.json and
web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00133 migration as well
as the stack's 00141-00143. web/messages/en.json and
web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00134 migration as well
as the stack's 00141-00143.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00135 and 00148
migrations as well as the stack's 00141-00143. web/messages/en.json and
web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflict in supabase/schema.sql by regenerating it with
supabase/build-schema.sh, so it now holds main's 00136 migration as well
as the stack's 00141-00143. web/messages/en.json and
web/src/types/supabase.ts merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iods

Built on ansvisor#1068 and ansvisor#1075 as well as the stack below, so it merges last; the detail test keeps both the traffic pages and the Search Console windows blocks.
…iods

main now carries ansvisor#1068 and ansvisor#1075 as squashes; the tree is the one CI passed.
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026

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

Thanks, approving. This branch was built on #1066 only, so I put its commit on top of #1068 and #1075. detail.test.ts keeps both the traffic pages block from #1068 and this branch's Search Console windows block. Against main the diff is only this PR's commit, and CI is green on this tree.

@gkhngyk
gkhngyk merged commit 9767ed8 into ansvisor:main Oct 17, 2026
4 of 5 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.

2 participants