Skip to content

MWE ungroup: apply user MWE overrides to preview summaries - #699

Merged
mircealungu merged 1 commit into
masterfrom
wt/mwe-summaries
Aug 13, 2026
Merged

MWE ungroup: apply user MWE overrides to preview summaries#699
mircealungu merged 1 commit into
masterfrom
wt/mwe-summaries

Conversation

@mircealungu

Copy link
Copy Markdown
Member

Problem

PR #698 added per-level tappable preview summaries (article_level_summary table + ArticleLevelSummary context type). Tapping a word in a summary translates/bookmarks fine, but the "ungroup a multi-word expression (MWE)" action did nothing on summaries.

Root cause: UserMweOverride clearing was only applied to the article body (the tokenized_fragments block in UserArticle.user_article_info, guarded by if with_content:). Summaries — both the per-level preview summaries and the article's own summary — never got that treatment.

Change

  1. Batched override fetchUserMweOverride.get_disabled_mwes_for_user_articles(user_id, article_ids) returns {article_id: {sentence_hash: [expressions]}} in one query (mirrors the existing single-article method).

  2. Shared apply helperUserArticle._apply_mwe_overrides_to_summary_tokens(summary_tokens, overrides_by_hash) walks a summary's paragraphs -> sentences (one fewer loop than the body version, which also has the outer fragment wrapper) and clears disabled MWE metadata in place. Applied in:

    • user_article_summary_info — for both the level-summary path and the fallback article.summary path (this also fixes the pre-existing gap for the original summary). Override lookup uses the parent article.id; summary sentence text differs from body sentences so the sentence hash still scopes the override to the summary.
    • _apply_simplified_display_overlay (feed overlay) — batch-fetches overrides for all candidate articles and applies to each interactiveSummary.
  3. article_id carry — the ARTICLE_LEVEL_SUMMARY ContextIdentifier now also passes article_id (in both _level_matched_summary_payload and the overlay). The bookmark mapping still keys on article_level_summary_id (create_context_mapping switches on context_type); article_id is only for the client's MWE-ungroup path. This was reverted from On-demand simplification: assess-only crawl + per-level preview summaries #698 because it was inert without this task.

  4. Tests — extended test_article_level_summary.py: MWE metadata cleared on a served level summary when an override exists, the untouched-token sanity case, and the article_id carry on the context identifier.

Notes

Tests

test_article_level_summary.py — 7 passed.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

ArchLens detected architectural changes in the following views:
diff

@mircealungu
mircealungu marked this pull request as ready for review August 13, 2026 06:34
The "ungroup a multi-word expression" action only affected the article body:
UserMweOverride clearing was applied to tokenized_fragments but never to the
per-level ArticleLevelSummary previews (nor to the article's own summary),
so tapping "ungroup" on a summary word had no effect.

- UserMweOverride.get_disabled_mwes_for_user_articles(user_id, article_ids):
  batched {article_id: {sentence_hash: [expressions]}} in one query.
- UserArticle._apply_mwe_overrides_to_summary_tokens(): shared helper that
  walks a summary's paragraphs -> sentences and clears disabled MWE metadata.
  Applied in user_article_summary_info (both the level-summary and the
  fallback own-summary paths) and in the feed overlay
  _apply_simplified_display_overlay (batched, no N+1).
- Carry article_id on the ARTICLE_LEVEL_SUMMARY ContextIdentifier so the
  client's ungroup path can address the override by parent article id; the
  bookmark mapping still keys on article_level_summary_id.
- Tests for override clearing on a level summary and the article_id carry.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mircealungu
mircealungu changed the base branch from wt/on-demand-simplify to master August 13, 2026 06:39
@mircealungu
mircealungu merged commit 1219cbd into master Aug 13, 2026
1 of 2 checks passed
mircealungu added a commit that referenced this pull request Aug 13, 2026
MWE-on-summaries review fixes (follow-up to #699)
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