Repository navigation
[AI-2095] Render SessionStart coordination-notices terminal-delivery lane #609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
realtonyyoung
merged 3 commits into
main
from
claude-tyoung/coordination-notices-rendering
Aug 19, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
cef096f
[AI-2095] Render SessionStart coordination-notices terminal-delivery …
realtonyyoung eeb21db
[AI-2095] Address qodo review: capability-free replay spool + docs
realtonyyoung 3dd5849
[AI-2095] Drop redundant null-forgiving in CoordinationNoticesEmitter…
realtonyyoung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| using System.Text; | ||
| using System.Text.Json.Nodes; | ||
|
|
||
| namespace Capacitor.Cli; | ||
|
|
||
| /// <summary> | ||
| /// Builds the SessionStart "coordination notices" fragment from a server | ||
| /// <c>/hooks/session-start</c> response. Plain text, not a JSON envelope — the caller | ||
| /// (<c>SessionStartAdditionalContext</c>) joins it with the other fragments and wraps one | ||
| /// Claude Code <c>hookSpecificOutput</c> envelope. | ||
| /// <para> | ||
| /// The server returns <c>coordination_notices</c> as a bounded array of <c>{ text }</c> one-line | ||
| /// warnings (optionally with a "+N more in the notification centre" tail) about others' in-flight | ||
| /// work that may overlap this session — the same notices that also reach the notification centre | ||
| /// and Slack. Each renders as one bullet under a <b>Coordination notices</b> heading. Returns | ||
| /// <c>null</c> when disabled, absent, empty, or malformed, so the caller emits nothing (fail-open, | ||
| /// like the guidelines and memory-index fragments). | ||
| /// </para> | ||
| /// </summary> | ||
| static class CoordinationNoticesEmitter { | ||
| /// <summary> | ||
| /// The capability token the CLI advertises on the SessionStart request | ||
| /// (<c>coordination_notices: "v1"</c>). An old/opted-out CLI sends nothing and | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| /// the server does no selection/claim/render; a future wire-shape change bumps | ||
| /// this token so a server keyed on the old one simply declines. | ||
| /// </summary> | ||
| internal const string CapabilityVersion = "v1"; | ||
|
|
||
| /// <summary> | ||
| /// Returns the coordination-notices block text, or <c>null</c> when there is | ||
| /// nothing to emit (no <c>coordination_notices</c>, all empty, user opted out, | ||
| /// malformed response). | ||
| /// </summary> | ||
| /// <param name="responseNode">The hook response body parsed as a <see cref="JsonNode"/>.</param> | ||
| /// <param name="disabled">True when the user has set <c>disable_coordination_notices</c> on their active profile.</param> | ||
| public static string? BuildFragment(JsonNode? responseNode, bool disabled) { | ||
| if (disabled) return null; | ||
| if (responseNode is not JsonObject obj) return null; | ||
| if (obj["coordination_notices"] is not JsonArray notices || notices.Count == 0) return null; | ||
|
|
||
| var lines = new List<string>(); | ||
| foreach (var node in notices) { | ||
| if (node is not JsonObject o) continue; | ||
|
|
||
| string? text; | ||
| try { text = o["text"]?.GetValue<string>(); } | ||
| catch { continue; } | ||
|
|
||
| if (string.IsNullOrWhiteSpace(text)) continue; | ||
| lines.Add($"- {text.Trim()}"); | ||
| } | ||
|
|
||
| if (lines.Count == 0) return null; | ||
|
|
||
| var sb = new StringBuilder(); | ||
| sb.AppendLine("## Coordination notices"); | ||
| sb.AppendLine("Heads-up: other people are working on things that may overlap yours. Coordinate before you collide."); | ||
| foreach (var l in lines) sb.AppendLine(l); | ||
| return sb.ToString().TrimEnd(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.