Skip to content

feat: add Gemini display labels (#362) - #362

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/gemini-display-labels
Apr 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/gemini-display-labels

Conversation

@Sinity

@Sinity Sinity commented Apr 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add deterministic display labels for Gemini conversations whose imported titles are empty, id-like, or fallback-only. The raw provider title remains stored as the conversation title, while provider_meta.display_label gives search and summary surfaces a more recognizable presentation label.

Problem

Closes #221

Gemini payloads often have weak top-level titles or only fallback identifiers. Since CLI, API, and MCP surfaces present display_title, those conversations could appear as opaque ids even when the first user prompt or attached Drive document name provided better human context.

Solution

  • Add a Gemini assembly spec that derives display labels from the first substantive user prompt and attachment names only when the imported title is weak.
  • Preserve raw title fidelity by keeping ParsedConversation.title unchanged and storing title_source, display_label, and display_label_source in provider metadata.
  • Update conversation and summary display-title precedence to prefer user metadata, then provider display labels, then raw title, then id fallback.
  • Cover parser provenance, assembly heuristics, emitter enrichment, CLI JSON output, MCP list output, and domain display-title behavior.
  • Document the Gemini metadata and display precedence.

Verification

  • ruff format polylogue/lib/conversation_runtime.py polylogue/lib/conversation_summary_runtime.py polylogue/sources/assembly.py polylogue/sources/assembly_gemini.py polylogue/sources/parsers/drive.py tests/unit/sources/test_assembly.py tests/unit/sources/test_parsers_drive.py tests/unit/sources/test_source_laws.py tests/unit/rendering/test_rendering.py tests/unit/core/test_conversation_semantics.py tests/unit/cli/test_query_fmt.py tests/unit/mcp/test_tool_contracts.py
  • ruff check polylogue/lib/conversation_runtime.py polylogue/lib/conversation_summary_runtime.py polylogue/sources/assembly.py polylogue/sources/assembly_gemini.py polylogue/sources/parsers/drive.py tests/unit/sources/test_assembly.py tests/unit/sources/test_parsers_drive.py tests/unit/sources/test_source_laws.py tests/unit/rendering/test_rendering.py tests/unit/core/test_conversation_semantics.py tests/unit/cli/test_query_fmt.py tests/unit/mcp/test_tool_contracts.py
  • pytest -q tests/unit/sources/test_assembly.py tests/unit/sources/test_parsers_drive.py tests/unit/sources/test_source_laws.py::test_conversation_emitter_enriches_gemini_display_labels_contract tests/unit/rendering/test_rendering.py::TestConversationSummaryDisplayDate tests/unit/core/test_conversation_semantics.py::TestConversationMetadataAndAggregation::test_title_summary_tags_and_display_contract tests/unit/cli/test_query_fmt.py::TestListFormatting tests/unit/mcp/test_tool_contracts.py::TestQueryTools::test_list_conversations_uses_provider_display_label
  • mypy polylogue/
  • devtools render-all --check
  • devtools verify
  • git push -u origin feature/feat/gemini-display-labels (pre-push devtools verify --quick passed)

Summary by CodeRabbit

  • New Features

    • Added Gemini provider support with intelligent display label derivation from user prompts and attachment names.
    • Introduced provider-specific metadata fields (display_label, title_source, and display_label_source) for improved conversation identification.
  • Documentation

    • Updated data model documentation to describe new metadata fields and their sources.
  • Tests

    • Added comprehensive test coverage for Gemini provider functionality and metadata handling.

Problem: Gemini imports preserve sparse or id-like titles, so search and summary surfaces can show provider identifiers even when the first prompt or attachment names would be more recognizable.\n\nWhat changed: add a Gemini assembly spec that derives deterministic provider display labels for weak imported titles, record raw title and display-label provenance, and make domain display titles prefer provider labels after user overrides while preserving the raw title. Cover assembly, parser, emitter, CLI, MCP, and display-title contracts.\n\nCloses #221
@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Implemented deterministic display label enrichment for Gemini conversations. Parser now tracks title provenance via title_source. New GeminiAssemblySpec derives display labels from first user prompts or attachment names when imported titles are weak. Runtime prefers provider_meta.display_label in title resolution chain.

Changes

Cohort / File(s) Summary
Documentation
docs/data-model.md, docs/providers/gemini.md
Added Gemini provider-specific metadata documentation describing title_source, display_label, and display_label_source fields; clarified display-title resolution preference order.
Core Runtime
polylogue/lib/conversation_runtime.py, polylogue/lib/conversation_summary_runtime.py
Added _provider_meta_string() helper for safe metadata extraction; updated display_title control flow to prefer provider_meta["display_label"] after user title; added provider_meta attribute to ConversationSummaryRuntimeMixin.
Assembly & Enrichment
polylogue/sources/assembly.py, polylogue/sources/assembly_gemini.py
Created new GeminiAssemblySpec module implementing deterministic display label derivation from first user message/attachment names when title is id-like or fallback; updated get_assembly_spec() to return Gemini-specific assembly for Provider.GEMINI.
Parser
polylogue/sources/parsers/drive.py
Enhanced title resolution to track title_source (imported vs. fallback); passes provider_meta with title_source to ParsedConversation.
Unit Tests
tests/unit/cli/test_query_fmt.py, tests/unit/core/test_conversation_semantics.py, tests/unit/mcp/test_tool_contracts.py, tests/unit/rendering/test_rendering.py, tests/unit/sources/test_assembly.py, tests/unit/sources/test_parsers_drive.py, tests/unit/sources/test_source_laws.py
Added comprehensive test coverage: parser title-source tracking, assembly spec Gemini enrichment behavior, display-label resolution in search/summary/MCP surfaces, extended test helpers for attachments and provider metadata.

Sequence Diagram

sequenceDiagram
    participant Parser as Parser<br/>(drive.py)
    participant Assembly as GeminiAssemblySpec<br/>(assembly_gemini.py)
    participant Runtime as ConversationRuntime<br/>(conversation_runtime.py)
    participant Surface as CLI/MCP<br/>(output layer)

    Parser->>Parser: Resolve title from payload<br/>Track title_source
    Parser->>Parser: Create ParsedConversation<br/>with provider_meta.title_source

    Assembly->>Assembly: Check if title is weak<br/>(id-like, fallback, empty)
    alt Weak Title Detected
        Assembly->>Assembly: Extract first user message<br/>or attachment name
        Assembly->>Assembly: Derive display_label<br/>+ display_label_source
        Assembly->>Assembly: Update provider_meta
    end
    Assembly->>Runtime: Pass enriched conversation

    Runtime->>Runtime: resolve display_title()
    alt provider_meta.display_label present
        Runtime->>Runtime: Prefer display_label
    else
        Runtime->>Runtime: Fall back to original title
    end

    Surface->>Runtime: Request display_title
    Runtime-->>Surface: Return resolved title
    Surface->>Surface: Render in search/summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 A gem of a gemini display, now shines so bright!
No more cryptic IDs hiding the light,
First whispers of prompts, attachment names too,
Adorned with provenance, truthful and true,
Labels now dance where the weak titles flew! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the required template with all major sections completed: Summary explains the change clearly, Problem describes the motivation, Solution outlines implementation details, Verification lists commands run, and Risks section is appropriately omitted as no concerns were identified.
Linked Issues check ✅ Passed The PR fully implements the acceptance criteria from issue #221: Gemini conversations now present recognizable display labels when imported titles are weak, heuristics are explicit and test-covered, search/summary surfaces use improved labels, and tests cover id-like/empty titles, first-user-message fallback, and attachment cases [#221].
Out of Scope Changes check ✅ Passed All changes are in-scope with issue #221: parser provenance tracking, Gemini assembly spec implementation, runtime display-title precedence updates, documentation, and comprehensive test coverage for the feature.
Title check ✅ Passed The title clearly and specifically describes the main change: adding deterministic display labels for Gemini conversations when titles are weak or id-like.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/gemini-display-labels

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity Sinity changed the title feat: add Gemini display labels feat: add Gemini display labels (#362) Apr 22, 2026
@Sinity
Sinity merged commit 3c679aa into master Apr 22, 2026
10 of 14 checks passed
@Sinity
Sinity deleted the feature/feat/gemini-display-labels branch April 22, 2026 17:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db7428111c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return False
digit_count = sum(char.isdigit() for char in token)
separator_count = sum(char in "-_.:" for char in token)
return digit_count >= 4 or separator_count >= 2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Tighten id-like title heuristic for separator-only slugs

The weak-title classifier currently treats any 12+ character token with at least two separators as identifier-like, even when it has no numeric/UUID signal (for example, project-plan-update). In those cases, meaningful imported Gemini titles get flagged as weak, causing display_label to replace the original title in list/search/MCP display surfaces. This is a user-visible accuracy regression for valid slug-style titles and should require stronger ID evidence before overriding.

Useful? React with 👍 / 👎.

@Sinity
Sinity requested review from Copilot and removed request for Copilot May 1, 2026 00:44
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Add deterministic display labels for Gemini conversations whose imported titles are empty, id-like, or fallback-only. The raw provider title remains stored as the conversation title, while `provider_meta.display_label` gives search and summary surfaces a more recognizable presentation label.

## Problem

Closes #221

Gemini payloads often have weak top-level titles or only fallback identifiers. Since CLI, API, and MCP surfaces present `display_title`, those conversations could appear as opaque ids even when the first user prompt or attached Drive document name provided better human context.

## Solution

- Add a Gemini assembly spec that derives display labels from the first substantive user prompt and attachment names only when the imported title is weak.
- Preserve raw title fidelity by keeping `ParsedConversation.title` unchanged and storing `title_source`, `display_label`, and `display_label_source` in provider metadata.
- Update conversation and summary display-title precedence to prefer user metadata, then provider display labels, then raw title, then id fallback.
- Cover parser provenance, assembly heuristics, emitter enrichment, CLI JSON output, MCP list output, and domain display-title behavior.
- Document the Gemini metadata and display precedence.

## Verification

- `ruff format polylogue/lib/conversation_runtime.py polylogue/lib/conversation_summary_runtime.py polylogue/sources/assembly.py polylogue/sources/assembly_gemini.py polylogue/sources/parsers/drive.py tests/unit/sources/test_assembly.py tests/unit/sources/test_parsers_drive.py tests/unit/sources/test_source_laws.py tests/unit/rendering/test_rendering.py tests/unit/core/test_conversation_semantics.py tests/unit/cli/test_query_fmt.py tests/unit/mcp/test_tool_contracts.py`
- `ruff check polylogue/lib/conversation_runtime.py polylogue/lib/conversation_summary_runtime.py polylogue/sources/assembly.py polylogue/sources/assembly_gemini.py polylogue/sources/parsers/drive.py tests/unit/sources/test_assembly.py tests/unit/sources/test_parsers_drive.py tests/unit/sources/test_source_laws.py tests/unit/rendering/test_rendering.py tests/unit/core/test_conversation_semantics.py tests/unit/cli/test_query_fmt.py tests/unit/mcp/test_tool_contracts.py`
- `pytest -q tests/unit/sources/test_assembly.py tests/unit/sources/test_parsers_drive.py tests/unit/sources/test_source_laws.py::test_conversation_emitter_enriches_gemini_display_labels_contract tests/unit/rendering/test_rendering.py::TestConversationSummaryDisplayDate tests/unit/core/test_conversation_semantics.py::TestConversationMetadataAndAggregation::test_title_summary_tags_and_display_contract tests/unit/cli/test_query_fmt.py::TestListFormatting tests/unit/mcp/test_tool_contracts.py::TestQueryTools::test_list_conversations_uses_provider_display_label`
- `mypy polylogue/`
- `devtools render-all --check`
- `devtools verify`
- `git push -u origin feature/feat/gemini-display-labels` (pre-push `devtools verify --quick` passed)


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Added Gemini provider support with intelligent display label derivation from user prompts and attachment names.
  * Introduced provider-specific metadata fields (`display_label`, `title_source`, and `display_label_source`) for improved conversation identification.

* **Documentation**
  * Updated data model documentation to describe new metadata fields and their sources.

* **Tests**
  * Added comprehensive test coverage for Gemini provider functionality and metadata handling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

feat: improve Gemini display labels in search and summary surfaces

1 participant