-
Notifications
You must be signed in to change notification settings - Fork 3.2k
refactor(notifications): migrate notifications.go to NewTool pattern #1592
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
base: SamMorrowDrums/server-tool-refactor-gists
Are you sure you want to change the base?
refactor(notifications): migrate notifications.go to NewTool pattern #1592
Conversation
Convert all gist tools (ListGists, GetGist, CreateGist, UpdateGist) to use the new NewTool helper with ToolDependencies injection. - Remove getClient parameter from function signatures - Use deps.GetClient(ctx) inside handlers - Standardize error handling with utils.NewToolResultErrorFromErr() - Update all tests to use serverTool.Handler(deps) pattern Co-authored-by: Adam Holt <oholt@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates all 6 notification-related tools from the legacy pattern to the new NewTool pattern with ToolDependencies injection, continuing the refactoring effort across the codebase.
Key Changes:
- Removed
getClientparameter from all notification tool function signatures - Updated tools to use
deps.GetClient(ctx)inside handlers instead of passed-in client function - Converted all test cases to use the new
serverTool.Handler(deps)pattern - Ensured consistent error handling with
nilas the third return parameter
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
pkg/github/tools.go |
Updated toolset registration to use new pattern, removing toolsets.NewServerToolLegacy wrapper calls for all 6 notification tools |
pkg/github/notifications.go |
Migrated all 6 notification tools (ListNotifications, GetNotificationDetails, DismissNotification, MarkAllNotificationsRead, ManageNotificationSubscription, ManageRepositoryNotificationSubscription) to return toolsets.ServerTool and accept dependencies via closure |
pkg/github/notifications_test.go |
Updated all test functions to use serverTool.Handler(deps) pattern, but introduced duplicate error checks in multiple test cases |
| if tc.expectError { | ||
| // The tool returns a ToolResultError with a specific message | ||
| require.NoError(t, err) | ||
| require.NotNil(t, result) |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error check. The require.NoError(t, err) is already performed at line 573 before entering this block. This redundant check should be removed.
| require.NoError(t, err) | ||
| if tc.expectError { |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error check. The require.NoError(t, err) is already performed at line 698 before entering this block. This redundant check should be removed.
| require.NoError(t, err) | |
| if tc.expectError { | |
| if tc.expectError { | |
| require.Error(t, err) |
| require.NoError(t, err) | ||
| if tc.expectError { |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error check. The require.NoError(t, err) is already performed at line 782 before entering this block. This redundant check should be removed.
| require.NoError(t, err) | |
| if tc.expectError { | |
| if tc.expectError { | |
| require.Error(t, err) |
|
|
||
| require.NoError(t, err) | ||
| if tc.expectError { | ||
| require.NoError(t, err) |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error check. The require.NoError(t, err) is already performed at line 268 before entering this block. This redundant check should be removed.
| require.NoError(t, err) |
| require.NoError(t, err) | ||
| if tc.expectError { |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error check. The require.NoError(t, err) is already performed at line 431 before entering this block. This redundant check should be removed.
| require.NoError(t, err) | |
| if tc.expectError { | |
| if tc.expectError { | |
| require.Error(t, err) |
Convert all notification tools to use the new NewTool helper with ToolDependencies injection. Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
34cf61e to
5e904e8
Compare
af97440 to
820ce1e
Compare
Summary
Migrates all notification tools to the new
NewToolpattern withToolDependenciesinjection.Part of stacked PRs for ServerTool refactoring:
Changes
Converts all 6 notification tools:
ListNotificationsGetNotificationDetailsDismissNotificationMarkAllNotificationsReadManageNotificationSubscriptionManageRepositoryNotificationSubscriptionRemove
getClientparameter from function signaturesFunctions now only take
t translations.TranslationHelperFuncand returntoolsets.ServerToolUse
deps.GetClient(ctx)inside handlers to get the GitHub clientUpdate all tests to use
serverTool.Handler(deps)patternTesting
script/lintpassesscript/testpassesCo-authored-by: Adam Holt oholt@github.com