-
Notifications
You must be signed in to change notification settings - Fork 57
feat(cli): surface the trace session link to the user #3430
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
+1,369
−54
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d056faf
feat(cli): print the session link after a trace push
migmartri 872f2de
test(cli): strengthen coverage of the trace session link
migmartri b076941
refactor(cli): reword the trace session line around the link
migmartri 0bfa06b
feat(cli): surface the trace session link through the coding agent
migmartri 6334c22
fix(cli): keep session links an agent could not show
migmartri d00167a
fix(cli): do not infer trace-run from the on-disk sentinel
migmartri b5a5636
refactor(cli): tidy the session-link notification path
migmartri ef48066
test(cli): exercise the handover the keep-links test claimed
migmartri c41815e
feat(cli): say what the trace session banner actually does
migmartri 5bd05c9
feat(cli): fold the banner destination onto one line and gate its cost
migmartri 9f3c867
feat(trace): widen opencode tracing and add cursor hooks
migmartri 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "hooks": { | ||
| "afterFileEdit": [ | ||
| { | ||
| "command": "chainloop trace hook cursor after-file-edit", | ||
| "timeout": 30 | ||
| } | ||
| ], | ||
| "sessionEnd": [ | ||
| { | ||
| "command": "chainloop trace hook cursor session-end", | ||
| "timeout": 30 | ||
| } | ||
| ], | ||
| "sessionStart": [ | ||
| { | ||
| "command": "chainloop trace hook cursor session-start", | ||
| "timeout": 30 | ||
| } | ||
| ] | ||
| }, | ||
| "version": 1 | ||
| } | ||
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,96 @@ | ||
| // | ||
| // Copyright 2026 The Chainloop Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package claude | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "io" | ||
| "os" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestAnnounceToUser pins the wire shape Claude Code expects. systemMessage | ||
| // must stay top-level: nested inside hookSpecificOutput it is silently ignored. | ||
| func TestAnnounceToUser(t *testing.T) { | ||
| const msg = "Coding Session Available at https://app.chainloop.dev/u/chainloop/sessions/ses_1" | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| msg string | ||
| wantEmitted bool | ||
| }{ | ||
| { | ||
| name: "a message goes out on both channels", | ||
| msg: msg, | ||
| wantEmitted: true, | ||
| }, | ||
| { | ||
| name: "nothing to say emits nothing", | ||
| msg: "", | ||
| wantEmitted: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| out := captureStdout(t, func() { | ||
| require.NoError(t, New().AnnounceToUser(tc.msg)) | ||
| }) | ||
|
|
||
| if !tc.wantEmitted { | ||
| assert.Empty(t, out, "no message means no stdout, so the hook stays a no-op") | ||
| return | ||
| } | ||
|
|
||
| var got map[string]any | ||
| require.NoError(t, json.Unmarshal([]byte(out), &got)) | ||
|
|
||
| assert.Equal(t, tc.msg, got["systemMessage"], "systemMessage must be top-level") | ||
|
|
||
| hookOut, ok := got["hookSpecificOutput"].(map[string]any) | ||
| require.True(t, ok, "hookSpecificOutput must be present") | ||
| assert.Equal(t, "PostToolUse", hookOut["hookEventName"]) | ||
|
|
||
| // The model needs the message verbatim to be able to repeat it. | ||
| assert.Contains(t, hookOut["additionalContext"], tc.msg) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // captureStdout runs fn with os.Stdout redirected to a pipe and returns | ||
| // everything written to it. Reads to EOF rather than into a fixed buffer: a | ||
| // truncated read would corrupt the payload these tests parse as JSON. | ||
| func captureStdout(t *testing.T, fn func()) string { | ||
| t.Helper() | ||
|
|
||
| orig := os.Stdout | ||
| r, w, err := os.Pipe() | ||
| require.NoError(t, err) | ||
| os.Stdout = w | ||
| t.Cleanup(func() { os.Stdout = orig }) | ||
|
|
||
| fn() | ||
| require.NoError(t, w.Close()) | ||
|
|
||
| out, err := io.ReadAll(r) | ||
| require.NoError(t, err) | ||
| require.NoError(t, r.Close()) | ||
|
|
||
| return string(out) | ||
| } |
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
Oops, something went wrong.
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.