Skip to content

fix: bundle C1 diagnostics follow-ups#575

Merged
Astro-Han merged 2 commits into
devfrom
slock/c1-diagnostics-followup
May 12, 2026
Merged

fix: bundle C1 diagnostics follow-ups#575
Astro-Han merged 2 commits into
devfrom
slock/c1-diagnostics-followup

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • extract a shared renderer abort diagnostic builder and switch the three existing emit sites to explicit route / visible / timeline session IDs
  • tighten title-generation diagnostics so abort exports record title_generation_state, title tracing warns when its target assistant never appears, and applied: true is only recorded after sessions.setTitle() really succeeds
  • add focused expected_outputs coverage for text artifacts and workdir-relative paths

Why

This PR closes the follow-up debt left by PRs #556, #561, and #563 without changing product behavior.

The missing pieces were:

  • abort diagnostics were duplicated across three app call sites and could drift in session-id fields
  • title-generation diagnostics still had two observability gaps: silent trace drops when the assistant target never appeared, and applied: true being recorded even when setTitle() failed
  • bash expected_outputs coverage still missed the text-hash path and workdir-relative resolution path

Related Issue

Closes #557
Closes #562
Closes #564

Human Review Status

Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.

Review Focus

  • packages/app/src/context/renderer-diagnostics.ts plus the three abort emit call sites only refactor event construction, without changing abort behavior
  • packages/opencode/src/session/prompt.ts preserves existing cancel/title semantics while making title-generation diagnostics more precise and observable
  • packages/opencode/test/tool/bash.test.ts covers the two missing expected_outputs protocol cases without broadening the bash contract

Risk Notes

Low. This stays in diagnostics and tests only:

  • no abort semantic change
  • no question / blocker lifecycle change
  • no schema field removal
  • no UI or copy change

The only schema impact is additive: abort diagnostics now optionally include title_generation_state.

How To Verify

bun --cwd packages/app typecheck
Result: pass

bun --cwd packages/app test src/components/prompt-input/submit.test.ts --preload ./happydom.ts
Result: pass (ran app unit suite, 1050 passed)

bun --cwd packages/opencode test test/tool/bash.test.ts test/session/export.test.ts test/session/prompt-effect.test.ts
Result: pass (121 passed)

bun --cwd packages/opencode typecheck
Result: pass

git diff --check
Result: pass

Screenshots or Recordings

Not applicable. No visible UI changes.

Checklist

  • Human review status is stated above as pending, approved, or not required
  • I linked the related issue, or stated why there is no issue
  • This PR has type, primary area, and priority labels, or I requested maintainer labeling
  • I described the review focus and any meaningful risks
  • I listed the relevant verification steps and the key result for each
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant
  • I reviewed the final diff for unrelated changes and suspicious dependency changes
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

Summary by CodeRabbit

  • New Features

    • Session export snapshots now record title generation state for abort diagnostics, improving visibility into timing around aborts.
  • Refactor

    • Standardized how abort diagnostics are produced and emitted across the app to ensure consistent diagnostic payloads.
  • Tests

    • Added unit and integration tests covering title-generation diagnostic logic and artifact/expected-output handling.

Review Change Stack

@github-actions github-actions Bot added app Application behavior and product flows ui Design system and user interface harness Model harness, prompts, tool descriptions, and session mechanics labels May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d2dcc556-33a8-48dd-81ae-40bd2a0dbe15

📥 Commits

Reviewing files that changed from the base of the PR and between 19a14ea and 85908e9.

📒 Files selected for processing (3)
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/test/session/prompt-effect.test.ts
  • packages/opencode/test/tool/bash.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/opencode/test/session/prompt-effect.test.ts
  • packages/opencode/src/session/prompt.ts

📝 Walkthrough

Walkthrough

This PR consolidates repeated session abort diagnostic emission into a shared factory helper, extends abort diagnostics to capture title-generation state, integrates per-session title-generation timing into the session prompt lifecycle, and adds tests for the new helpers and expected_outputs cases.

Changes

Abort diagnostics consolidation and title-generation state tracking

Layer / File(s) Summary
Shared abort diagnostic event factory
packages/app/src/context/renderer-diagnostics.ts
New exported sessionAbortDiagnosticEvent helper constructs standardized RendererDiagnosticInput payloads with name: "session.action.abort", normalizing session-ID and abort-mode fields.
App-side abort diagnostic consolidation
packages/app/src/components/prompt-input/submit.ts, packages/app/src/pages/session.tsx, packages/app/src/pages/session/use-session-commands.tsx
Three app callsites updated to call sessionAbortDiagnosticEvent(...) instead of constructing diagnostic objects inline, preserving each caller's route/visible/timeline session-ID semantics.
Title-generation state types and helpers
packages/opencode/src/session/prompt.ts
Adds TitleGenerationState and helper functions (titleGenerationStateAtAbort, reconcileTitleGenerationStateAfterCompletion) to classify and reconcile title-generation timing relative to aborts/completions.
Schema and export updates for abort diagnostics
packages/opencode/src/session/message-v2.ts, packages/opencode/src/session/export.ts
Extends AssistantMessage diagnostics and Export.Snapshot abort entries to include optional title_generation_state, and surfaces the field through derive/collect export logic.
Title-generation tracking integrated into session prompt lifecycle
packages/opencode/src/session/prompt.ts
Tracks per-session title generation progress (startedAt/completedAt), reconciles assistant abort diagnostics with computed title_generation_state, changes title persistence to check sessions.setTitle(...).pipe(Effect.exit), and records title state on loop interrupts.
Interrupt-source origin documentation
packages/opencode/src/effect/runner.ts
Adds reserved documentation comments to InterruptMeta describing future interrupt-source origin tracking without runtime changes.
Test coverage and expected_outputs tests
packages/opencode/test/session/export.test.ts, packages/opencode/test/session/prompt-effect.test.ts, packages/opencode/test/tool/bash.test.ts
Adds unit tests for title-generation helper behavior; updates export test to assert title_generation_state propagation; and adds expected_outputs tests covering text, BOM-prefixed text, and workdir-relative path cases.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Astro-Han/pawwork#563: Introduces abort provenance and title-generation diagnostics infrastructure that this PR extends with title-generation state snapshots and helper consolidation.
  • Astro-Han/pawwork#561: Adds the expected_outputs protocol to the bash tool; this PR adds additional tests for text-file and workdir-relative cases.
  • Astro-Han/pawwork#556: Introduced soft/hard abort semantics that this PR refactors into a shared diagnostic factory without changing behavior.

Suggested labels

enhancement

Poem

🐰 I hopped through diagnostics with delight,
Merged aborts in one tidy sight.
Titles timed and traced with care,
Tests to prove what happened there.
A little carrot for observability tonight.

🚥 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
Title check ✅ Passed The title 'fix: bundle C1 diagnostics follow-ups' accurately summarizes the main objective of the PR: bundling together several diagnostic-related follow-up tasks from previous work.
Description check ✅ Passed The PR description comprehensively covers all required template sections: Summary, Why, Related Issue, Human Review Status, Review Focus, Risk Notes, How To Verify, Screenshots, and a completed Checklist.
Linked Issues check ✅ Passed The PR successfully addresses all three linked issues: #557 consolidates abort diagnostics via sessionAbortDiagnosticEvent, #562 adds text and relative-path expected_outputs tests, and #564 adds title_generation_state to abort diagnostics, improves title trace logging, and ensures applied is true only after setTitle succeeds.
Out of Scope Changes check ✅ Passed All changes remain within scope: refactoring abort diagnostic emission, tightening title-generation diagnostics observability, and adding focused test coverage—no unrelated refactors, UI changes, or behavior modifications beyond stated objectives.

✏️ 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 slock/c1-diagnostics-followup

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.

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

Suggested priority: P2 (includes user-path files (packages/app/src/components/prompt-input/submit.ts, packages/app/src/context/renderer-diagnostics.ts, packages/app/src/pages/session.tsx, packages/app/src/pages/session/use-session-commands.tsx)).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@Astro-Han Astro-Han added the P2 Medium priority label May 12, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces tracking for title generation states during session aborts and refactors diagnostic event emission. It adds a title_generation_state field to assistant message diagnostics to capture whether title generation was not started, in flight, or completed relative to an abort event. Additionally, it introduces a sessionAbortDiagnosticEvent helper in the frontend to standardize abort diagnostics and includes new tests for bash tool artifact recording and path resolution. I have no feedback to provide.

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/opencode/src/session/prompt.ts`:
- Around line 96-109: The function reconcileTitleGenerationStateAfterCompletion
currently leaves "in_flight" when completedAt === abortRecordedAt; change the
comparison in reconcileTitleGenerationStateAfterCompletion (the function name)
so that when input.state === "in_flight" and both abortRecordedAt and
completedAt are numbers and completedAt >= abortRecordedAt it returns the
terminal state "completed_after_abort" (i.e., treat equal timestamps as
completed) so any completed timestamp collapses the in-flight state into the
terminal state.

In `@packages/opencode/test/tool/bash.test.ts`:
- Around line 434-437: The test currently assumes deterministic ordering by
indexing into TurnChange.finalize(turn)?.files[0]; instead, make the assertion
order-independent by locating the file object with path "nested/report.txt"
(e.g., using Array.prototype.find or an assertion like
expect(files).toEqual(expect.arrayContaining(...))) and then assert its status
is "added"; update the assertion that references
TurnChange.finalize(turn)?.files so it searches for the entry with path
"nested/report.txt" and checks status rather than relying on files[0].
- Around line 320-360: The test "records a declared text artifact using the text
hash path" currently only writes a plain UTF-8 file; add a second subtest or
extend this test to also create a file that begins with the UTF-8 BOM (write
"\uFEFFhello\n") and include that BOM-path file in the bash.execute
expected_outputs array so the code path that handles text artifacts with BOM is
exercised; update the result.artifacts and TurnChange.finalize(turn)?.files
assertions to assert the BOM file (e.g., "notes-with-bom.txt") appears with the
same status/expandable/additions/deletions expectations as the plain text file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a410be74-dc1a-4c0f-b42b-692f838cf076

📥 Commits

Reviewing files that changed from the base of the PR and between 2780928 and 19a14ea.

📒 Files selected for processing (11)
  • packages/app/src/components/prompt-input/submit.ts
  • packages/app/src/context/renderer-diagnostics.ts
  • packages/app/src/pages/session.tsx
  • packages/app/src/pages/session/use-session-commands.tsx
  • packages/opencode/src/effect/runner.ts
  • packages/opencode/src/session/export.ts
  • packages/opencode/src/session/message-v2.ts
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/test/session/export.test.ts
  • packages/opencode/test/session/prompt-effect.test.ts
  • packages/opencode/test/tool/bash.test.ts

Comment thread packages/opencode/src/session/prompt.ts
Comment thread packages/opencode/test/tool/bash.test.ts
Comment thread packages/opencode/test/tool/bash.test.ts Outdated
@Astro-Han Astro-Han merged commit f71abef into dev May 12, 2026
24 checks passed
@Astro-Han Astro-Han deleted the slock/c1-diagnostics-followup branch May 12, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority ui Design system and user interface

Projects

None yet

1 participant