Repository navigation
feat(review): add forge-backed review thread fetching #7907
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
ralphbean
merged 18 commits into
fullsend-ai:main
from
csoceanu:aisdlc-118/fetch-resolved-threads
Oct 8, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c584aeb
feat(review): fetch human-resolved review threads before agent runs
csoceanu 298bad1
fix(review): query GraphQL __typename instead of REST type
Benkapner d0bc73a
fix(review): match resolver's comments only and flag truncated threads
csoceanu 8af24ea
fix(review): route resolved threads through forge client
csoceanu 8416cd3
test(review): cover resolved thread fetching
csoceanu 6d2da39
test(review): normalize bot fixture identities
csoceanu 6dcaece
fix(review): detect CLI install mode from checkout
csoceanu f07187d
fix(review): validate resolved thread identities
csoceanu a3ca00c
fix(review): isolate CLI source builds
csoceanu 455e59b
fix(review): run thread fetch in agent pre-script
csoceanu b2694e8
fix(review): rely on agent pre-script for thread fetch
csoceanu 6ca6ff6
fix(review): limit thread wiring to per-repo workflow
csoceanu 811671d
fix(review): move thread fetch to agent pre-script
csoceanu 76f8b11
fix(review): fail closed for unknown GitLab actors
csoceanu 6ee403e
fix(review): verify GitLab discussion actors
csoceanu eff119c
test(review): cover review thread fetch paths
csoceanu 8f38dc0
fix(review): let agent own thread output path
csoceanu 6b28b0c
fix(review): include verified actor roles
csoceanu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "github.com/fullsend-ai/fullsend/internal/repos" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newFetchReviewThreadsCmd() *cobra.Command { | ||
| var ( | ||
| repo string | ||
| pr int | ||
| forgeName string | ||
| token string | ||
| baseURL string | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "fetch-review-threads", | ||
|
csoceanu marked this conversation as resolved.
Resolved
|
||
| Short: "Fetch pull-request review threads through the forge client", | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, _ []string) error { | ||
| if pr <= 0 { | ||
| return fmt.Errorf("--pr must be a positive integer, got %d", pr) | ||
| } | ||
| parts := strings.SplitN(repo, "/", 2) | ||
| if len(parts) != 2 || parts[0] == "" || parts[1] == "" { | ||
| return fmt.Errorf("--repo must be in owner/repo format, got %q", repo) | ||
| } | ||
|
|
||
| client, err := resolvePostReviewClient(forgeName, token, baseURL) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| threads, err := client.ListPullRequestReviewThreads(cmd.Context(), parts[0], parts[1], pr) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| return json.NewEncoder(cmd.OutOrStdout()).Encode(threads) | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().StringVar(&repo, "repo", "", "repository in owner/repo format (required)") | ||
| cmd.Flags().IntVar(&pr, "pr", 0, "pull request number (required)") | ||
| cmd.Flags().StringVar(&forgeName, "forge", repos.ForgeGitHub, "forge backend (github or gitlab)") | ||
| cmd.Flags().StringVar(&token, "token", "", "forge token (defaults to the forge environment token)") | ||
| cmd.Flags().StringVar(&baseURL, "base-url", "", "forge API base URL") | ||
| _ = cmd.MarkFlagRequired("repo") | ||
| _ = cmd.MarkFlagRequired("pr") | ||
| return cmd | ||
| } | ||
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,94 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "encoding/json" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "github.com/fullsend-ai/fullsend/internal/forge" | ||
| "github.com/fullsend-ai/fullsend/internal/repos" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestFetchReviewThreadsCommand(t *testing.T) { | ||
| srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| assert.Equal(t, http.MethodPost, r.Method) | ||
| assert.Equal(t, "/api/graphql", r.URL.Path) | ||
| _, _ = w.Write([]byte(`{"data":{"repository":{"pullRequest":{"reviewThreads":{"pageInfo":{"hasNextPage":false,"endCursor":""},"nodes":[{"id":"thread-1","isResolved":true,"path":"main.go","line":12,"originalLine":11,"resolvedBy":{"login":"reviewer"},"comments":{"pageInfo":{"hasNextPage":false},"nodes":[]}}]}}}}}`)) | ||
| })) | ||
| defer srv.Close() | ||
|
|
||
| var output bytes.Buffer | ||
| cmd := newFetchReviewThreadsCmd() | ||
| cmd.SetOut(&output) | ||
| cmd.SetErr(&output) | ||
| cmd.SetArgs([]string{"--repo", "owner/repo", "--pr", "42", "--token", "test-token", "--base-url", srv.URL}) | ||
| cmd.SetContext(context.Background()) | ||
|
|
||
| // The forge client owns its HTTP transport, so point the GitHub client at | ||
| // the TLS test server through the environment used by the command factory. | ||
| // The command's client uses the default transport; install the test server's | ||
| // transport for the duration of this test. | ||
| oldTransport := http.DefaultTransport | ||
| http.DefaultTransport = srv.Client().Transport | ||
| t.Cleanup(func() { http.DefaultTransport = oldTransport }) | ||
|
|
||
| require.NoError(t, cmd.Execute()) | ||
| var got forge.ReviewThreadPage | ||
| require.NoError(t, json.Unmarshal(output.Bytes(), &got)) | ||
| require.Len(t, got.Threads, 1) | ||
| assert.Equal(t, "thread-1", got.Threads[0].ID) | ||
| assert.True(t, got.Threads[0].IsResolved) | ||
| } | ||
|
|
||
| func TestFetchReviewThreadsCommand_DefaultsToGitHubForge(t *testing.T) { | ||
| cmd := newFetchReviewThreadsCmd() | ||
|
|
||
| flag := cmd.Flags().Lookup("forge") | ||
| require.NotNil(t, flag) | ||
| assert.Equal(t, repos.ForgeGitHub, flag.DefValue) | ||
| } | ||
|
|
||
| func TestFetchReviewThreadsCommand_ReturnsForgeError(t *testing.T) { | ||
| srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { | ||
| w.WriteHeader(http.StatusForbidden) | ||
| _, _ = w.Write([]byte(`{"message":"denied"}`)) | ||
| })) | ||
| defer srv.Close() | ||
| oldTransport := http.DefaultTransport | ||
| http.DefaultTransport = srv.Client().Transport | ||
| t.Cleanup(func() { http.DefaultTransport = oldTransport }) | ||
|
|
||
| cmd := newFetchReviewThreadsCmd() | ||
| cmd.SetArgs([]string{"--repo", "owner/repo", "--pr", "42", "--token", "test-token", "--base-url", srv.URL}) | ||
| cmd.SetContext(context.Background()) | ||
|
|
||
| err := cmd.Execute() | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "list pull request review threads page 1") | ||
| } | ||
|
|
||
| func TestFetchReviewThreadsCommand_ValidatesFlags(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| args []string | ||
| want string | ||
| }{ | ||
| {name: "non-positive pull request", args: []string{"--repo", "owner/repo", "--pr", "0"}, want: "positive integer"}, | ||
| {name: "invalid repository", args: []string{"--repo", "owner", "--pr", "1"}, want: "owner/repo format"}, | ||
| {name: "unsupported forge", args: []string{"--repo", "owner/repo", "--pr", "1", "--forge", "bitbucket", "--token", "token"}, want: "unsupported forge"}, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| cmd := newFetchReviewThreadsCmd() | ||
| cmd.SetArgs(tt.args) | ||
| err := cmd.Execute() | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), tt.want) | ||
| }) | ||
| } | ||
| } |
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.