Skip to content

DO NOT MERGE 2#609

Open
karlclement wants to merge 7 commits into
derrick/cod-1379-if-there-is-no-remote-on-a-localfrom
derrick/cod-1368-bug-notifications-get-wiped-if-panel
Open

DO NOT MERGE 2#609
karlclement wants to merge 7 commits into
derrick/cod-1379-if-there-is-no-remote-on-a-localfrom
derrick/cod-1368-bug-notifications-get-wiped-if-panel

Conversation

@karlclement
Copy link
Copy Markdown
Contributor

@karlclement karlclement commented Apr 25, 2024

Description

Type of Change

  • Tech Debt (refactoring, unit tests, CI changes, pre-commit hooks, etc)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Test Configuration:

  • CCL version/branch: 1.X
  • API version/branch: 1.X

Checklist:

  • I have performed a self-review of my code
  • I have used codex to provide context, particularly in hard-to-understand areas
  • Any dependent changes have been made available in downstream modules

Screenshots:

@karlclement
Copy link
Copy Markdown
Contributor Author

@echolayer-karl /review

Copy link
Copy Markdown

@echolayer-dev-karl echolayer-dev-karl Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squire has completed its review of this PR!
We left 35 comments.
How did we do? 👍 👎


async execute(): Promise<ExecutedCommandResponse<MESSAGE_TYPES, Notification>> {
try {
handleSetStatusBarMessage(this.statusData);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider validating statusData before passing it to handleSetStatusBarMessage to ensure it meets expected structure and content, enhancing security and robustness.

Comment on lines +16 to +22
remoteCheck
.filter((it) => !it.hasRemote)
.forEach((repoCheck) => {
vscode.window.showErrorMessage(
`Uh-oh. No remote detected for this repo: ${repoCheck.rootUri}. Please connect a remote to continue.`
);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider handling the case where multiple repositories lack remotes more gracefully. Accumulating error messages and displaying them in a single dialog or notification could improve user experience by reducing potential spamming of error messages.

Comment on lines +270 to +282
sendStatusBarUpdateMessage(clientView);
break;
}
case MESSAGE_TYPES.deleteNotification: {
const deleteNotificationCommand: DeleteNotificationCommand = new DeleteNotificationCommand(message.value);
clientView.webview.postMessage(await deleteNotificationCommand.execute());
sendStatusBarUpdateMessage(clientView);
break;
}
case MESSAGE_TYPES.deleteNotifications: {
const deleteNotificationsCommand: DeleteNotificationsCommand = new DeleteNotificationsCommand(message.value);
clientView.webview.postMessage(await deleteNotificationsCommand.execute());
sendStatusBarUpdateMessage(clientView);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the sendStatusBarUpdateMessage function is defined and properly handles any potential exceptions, as it is being called after postMessage operations which could throw errors.

const notificationMessage = formatStatusBarMessage(notifications);
function handleSetStatusBarMessage(statusData: StatusBarData): vscode.Disposable {
const notificationMessage = formatStatusBarMessage(statusData.notifications);
return updateStatusBar(notificationMessage, vscode.window);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactoring from a direct array of notifications to using a StatusBarData interface is a good encapsulation. However, ensure that all callers of handleSetStatusBarMessage are updated to pass the new StatusBarData structure instead of the raw array.

Comment on lines +126 to +129
return this.gitAPI.repositories.map((repository) => {
return {
rootUri: repository.rootUri.toString(),
hasRemote: repository?.state?.remotes?.length > 0,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method checkForRemotes assumes this.gitAPI and this.gitAPI.repositories are not null. To prevent potential runtime errors, add a null check for this.gitAPI and this.gitAPI.repositories before accessing the repositories property.

import type { Notification } from "@usecodex/common-library";
import { MESSAGE_TYPES } from "../../globals";
import { handleStatusBarUpdate } from "../../helpers/notifications.helper";
import { UserService } from "../../services/user.service";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of handleStatusBarUpdate import suggests that the function is no longer used; ensure that its removal does not affect other parts of the system that might rely on it. If it's indeed unused, the deletion is appropriate.

import type { Notification } from "@usecodex/common-library";
import { MESSAGE_TYPES } from "../../globals";
import { handleStatusBarUpdate } from "../../helpers/notifications.helper";
import { UserService } from "../../services/user.service";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of handleStatusBarUpdate import suggests that the status bar update functionality is no longer needed. Confirm that this functionality is indeed obsolete or ensure that its removal does not affect other parts of the application that might rely on it.

import { Notification } from "@usecodex/common-library";
import { MESSAGE_TYPES } from "../../globals";
import { handleSetStatusBarMessage } from "../../helpers/notifications.helper";
import { UserService } from "../../services/user.service";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of 'handleSetStatusBarMessage' import suggests it is no longer used. Confirm its removal is intentional and that there are no unused references to it in the codebase.

import { Notification } from "@usecodex/common-library";
import { MESSAGE_TYPES } from "../../globals";
import { handleStatusBarUpdate } from "../../helpers/notifications.helper";
import { UserService } from "../../services/user.service";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of handleStatusBarUpdate import suggests it is no longer used. Verify if this is intentional and ensure that any related functionality is either removed or refactored accordingly.

}

export { handleStatusBarUpdate, handleSetStatusBarMessage, formatStatusBarMessage, displayInformationMessage };
export { handleSetStatusBarMessage, formatStatusBarMessage, displayInformationMessage };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of handleStatusBarUpdate from the export statement suggests that it is no longer used. Confirm that this function has been fully deprecated or replaced, and if so, ensure that all references to it have been removed from the codebase to prevent dead code.

@ghost
Copy link
Copy Markdown

ghost commented Apr 25, 2024

Pull Request Summary by EchoLayer

Summary

This pull request introduces a new StatusBarUpdateCommand class to streamline status bar notifications, refactors notification handling to prepend new items and correct update logic, and enhances repository checks with GitService integration. It also cleans up redundant status bar update calls across various commands and handlers, and updates the messaging models to support the new statusBarUpdate message type. The version bump to 0.5.5 reflects these improvements and bug fixes, including a fix for a bug where notifications would disappear and improved user feedback when no remotes are found.

File Changes

  • CHANGELOG.md: Updated CHANGELOG.md with a new version entry (0.5.5) detailing added, changed, and fixed items, including notification count and repository error surfacing.
  • package.json: Incremented the version number from 0.5.4 to 0.5.5 in package.json.
  • deleteNotification.command.ts: Removed an unnecessary call to handleStatusBarUpdate in deleteNotification.command.ts.
  • deleteNotifications.command.ts: Removed an unnecessary call to handleStatusBarUpdate in deleteNotifications.command.ts.
  • markAllNotificationRead.command.ts: Removed an unnecessary call to handleSetStatusBarMessage in markAllNotificationRead.command.ts.
  • updateNotification.command.ts: Removed an unnecessary call to handleStatusBarUpdate in updateNotification.command.ts.
  • getRepositories.command.ts: Refactored getRepositories.command.ts to use GitService for remote checks and repository retrieval.
  • (src)/globals.ts: Added a new MESSAGE_TYPES entry 'statusBarUpdate' in globals.ts.
  • pusherEvent.handler.ts: Removed handleStatusBarUpdate call and added a sidebar message for statusBarUpdate in pusherEvent.handler.ts.
  • webviewOutgoingMessage.handler.ts: Added handling for statusBarUpdate messages and removed redundant status bar update calls in webviewOutgoingMessage.handler.ts.
  • notifications.helper.ts: Removed handleStatusBarUpdate function and updated handleSetStatusBarMessage to use StatusBarData in notifications.helper.ts.
  • (webview)/webviewOutgoingMessage.model.ts: Added a new message type 'StatusBarUpdate' to webviewOutgoingMessage.model.ts.
  • git.service.ts: Added a new method checkForRemotes to GitService in git.service.ts.
  • (src)/globals.ts: Added a new MESSAGE_TYPES entry 'statusBarUpdate' in globals.ts for the webview context.
  • webviewIncomingMessage.model.ts: Added a new message type 'StatusBarUpdate' to webviewIncomingMessage.model.ts.
  • (webview)/webviewOutgoingMessage.model.ts: Added a new message type 'StatusBarUpdate' to webviewOutgoingMessage.model.ts for the webview context.
  • Root.svelte: Updated Root.svelte to handle MESSAGE_TYPES.statusBarUpdate and post the message with notifications data.
  • NoRepository.svelte: Minor cleanup in NoRepository.svelte, removed unnecessary script tag and ensured newline at end of file.
  • notification.store.ts: Modified notification.store.ts to prepend new notifications to the existing list.
  • notification.reducer.ts: Updated notification.reducer.ts to handle single notification updates correctly.

New Files

  • statusBarUpdate.command.ts: Introduced a new class StatusBarUpdateCommand to handle status bar notifications. It imports necessary types, defines a messageType, and implements an execute method for updating the status bar.

@karlclement karlclement reopened this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants