Skip to content

fix: scope show-prompt --commit output to the specified commit's timeframe#882

Open
svarlamov wants to merge 1 commit intomainfrom
devin/1774936075-fix-show-prompt-commit-scope
Open

fix: scope show-prompt --commit output to the specified commit's timeframe#882
svarlamov wants to merge 1 commit intomainfrom
devin/1774936075-fix-show-prompt-commit-scope

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented Mar 31, 2026

Summary

Fixes #861. When --commit is specified on git-ai show-prompt, the command now truncates the resolved message transcript to only include messages whose RFC-3339 timestamps are at or before the commit's author-date. Previously, the full session transcript was returned regardless of which commit was specified.

How it works: A new truncate_messages_to_commit() function reads the commit's author timestamp, then walks the message list and cuts it off at the first message whose timestamp exceeds the commit time. Messages without timestamps are preserved (we can't prove they're beyond the cutoff). This is applied after message resolution (CAS/SQLite) and only when --commit is provided.

Review & Testing Checklist for Human

  • Test assertion is conditional and likely no-ops in CI: The integration test guards its key assertion with if !msgs_first.is_empty() && !msgs_second.is_empty() — since the test environment doesn't inject timestamped messages into CAS/SQLite, both arrays are likely empty, meaning the truncation logic is never actually exercised by the test. Verify whether the test provides meaningful coverage or is just a smoke test.
  • Truncation assumes chronological message ordering: The algorithm stops at the first message exceeding the cutoff and drops everything after it. If a transcript has out-of-order timestamps, earlier messages after the cutoff point would be incorrectly dropped. Verify this assumption holds for real-world agent transcripts (Claude Code, Cursor, etc.).
  • Silent fallback on error: If truncate_messages_to_commit fails (e.g., commit metadata can't be read), the full untruncated transcript is returned silently due to the let Ok(truncated) = ... pattern. Confirm this is the desired behavior vs. surfacing an error.
  • Manual end-to-end test recommended: Use a real repo with a multi-commit AI session, run git-ai show-prompt <id> --commit <first_sha> and git-ai show-prompt <id> --commit <second_sha>, and verify the message counts differ appropriately.

Notes

  • The chrono crate was already a dependency; no new packages added.
  • Lint (clippy) and format (cargo fmt) checks pass locally.
  • All 26 show_prompt integration tests pass locally (including the new one and its worktree variant).

Link to Devin session: https://app.devin.ai/sessions/27660bd018284aceb8d275a617195891
Requested by: @svarlamov


Open with Devin

…frame

When --commit is specified, truncate the resolved message transcript to
only include messages whose timestamps are at or before the commit's
author-date.  This fixes the bug where show-prompt returned the full
session transcript regardless of which commit was specified.

Closes #861

Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

[Bug]: "--commit" flag does not scope "show-prompt" output to single commit

2 participants