Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ export function DashboardSidebarWorkspaceItem({
handleDeleted,
handleOpenInFinder,
handleRemoveFromSidebar,
handleToggleUnread,
isActive,
isDeleteDialogOpen,
isUnread,
isRenaming,
moveWorkspaceToSection,
renameValue,
Expand Down Expand Up @@ -110,6 +112,7 @@ export function DashboardSidebarWorkspaceItem({
<DashboardSidebarWorkspaceContextMenu
projectId={projectId}
isInSection={isInSection}
isUnread={isUnread}
onHoverCardOpen={
hostType === "local-device" ? onHoverCardOpen : undefined
}
Expand All @@ -130,6 +133,7 @@ export function DashboardSidebarWorkspaceItem({
onRemoveFromSidebar={handleRemoveFromSidebar}
onRename={startRename}
onDelete={() => setIsDeleteDialogOpen(true)}
onToggleUnread={handleToggleUnread}
>
{content}
</DashboardSidebarWorkspaceContextMenu>
Expand Down Expand Up @@ -176,6 +180,7 @@ export function DashboardSidebarWorkspaceItem({
<DashboardSidebarWorkspaceContextMenu
projectId={projectId}
isInSection={isInSection}
isUnread={isUnread}
onHoverCardOpen={
hostType === "local-device" ? onHoverCardOpen : undefined
}
Expand All @@ -196,6 +201,7 @@ export function DashboardSidebarWorkspaceItem({
onRemoveFromSidebar={handleRemoveFromSidebar}
onRename={startRename}
onDelete={() => setIsDeleteDialogOpen(true)}
onToggleUnread={handleToggleUnread}
>
{expandedContent}
</DashboardSidebarWorkspaceContextMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
LuArrowRightLeft,
LuArrowUp,
LuCopy,
LuEye,
LuEyeOff,
LuFolderOpen,
LuFolderPlus,
LuGitBranch,
Expand All @@ -34,6 +36,7 @@ interface DashboardSidebarWorkspaceContextMenuProps {
projectId: string;
isInSection?: boolean;
isLocalWorkspace: boolean;
isUnread: boolean;
onHoverCardOpen?: () => void;
onCreateSection: () => void;
onMoveToSection: (sectionId: string | null) => void;
Expand All @@ -43,13 +46,15 @@ interface DashboardSidebarWorkspaceContextMenuProps {
onRemoveFromSidebar: () => void;
onRename: () => void;
onDelete: () => void;
onToggleUnread: () => void;
children: React.ReactNode;
}

export function DashboardSidebarWorkspaceContextMenu({
projectId,
isInSection,
isLocalWorkspace,
isUnread,
onHoverCardOpen,
hoverCardContent,
onCreateSection,
Expand All @@ -60,6 +65,7 @@ export function DashboardSidebarWorkspaceContextMenu({
onRemoveFromSidebar,
onRename,
onDelete,
onToggleUnread,
children,
}: DashboardSidebarWorkspaceContextMenuProps) {
const collections = useCollections();
Expand Down Expand Up @@ -105,6 +111,20 @@ export function DashboardSidebarWorkspaceContextMenu({
Copy Branch Name
</ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuItem onSelect={onToggleUnread}>
{isUnread ? (
<>
<LuEye className="size-4 mr-2" />
Mark as Read
</>
) : (
<>
<LuEyeOff className="size-4 mr-2" />
Mark as Unread
</>
)}
</ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuItem onSelect={onCreateSection}>
<LuFolderPlus className="size-4 mr-2" />
New group from workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { useNavigateAwayFromWorkspace } from "renderer/routes/_authenticated/_da
import { useDashboardSidebarState } from "renderer/routes/_authenticated/hooks/useDashboardSidebarState";
import { useOptimisticCollectionActions } from "renderer/routes/_authenticated/hooks/useOptimisticCollectionActions";
import { useLocalHostService } from "renderer/routes/_authenticated/providers/LocalHostServiceProvider";
import { useV2NotificationStore } from "renderer/stores/v2-notifications";
import {
useV2NotificationStore,
useV2WorkspaceIsUnread,
} from "renderer/stores/v2-notifications";

interface UseDashboardSidebarWorkspaceItemActionsOptions {
workspaceId: string;
Expand All @@ -34,6 +37,8 @@ export function useDashboardSidebarWorkspaceItemActions({
const clearWorkspaceAttention = useV2NotificationStore(
(s) => s.clearWorkspaceAttention,
);
const setManualUnread = useV2NotificationStore((s) => s.setManualUnread);
const isUnread = useV2WorkspaceIsUnread(workspaceId);
const { createSection, moveWorkspaceToSection, removeWorkspaceFromSidebar } =
useDashboardSidebarState();

Expand Down Expand Up @@ -128,6 +133,14 @@ export function useDashboardSidebarWorkspaceItemActions({
}
};

const handleToggleUnread = () => {
if (isUnread) {
clearWorkspaceAttention(workspaceId);
} else {
setManualUnread(workspaceId);
}
};
Comment on lines +136 to +142
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor UX note: marking unread while the workspace is active.

If the user invokes "Mark as Unread" while currently viewing the workspace, the green dot will appear on the active workspace and will only auto-clear once the user navigates away and then re-enters via a sidebar click (the only path that calls clearWorkspaceAttention). Switching tabs/panes within the active workspace won't clear it. Probably fine — and matches the PR description's auto-clear-on-visit model — but worth confirming this is the intended behavior, or consider a no-op when isActive is true.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/hooks/useDashboardSidebarWorkspaceItemActions/useDashboardSidebarWorkspaceItemActions.ts`
around lines 137 - 143, The current handleToggleUnread in
useDashboardSidebarWorkspaceItemActions toggles manual unread even when the
workspace isActive, causing a green dot to appear on the active workspace;
change handleToggleUnread to no-op when isActive is true (i.e., if (isActive)
return) so marking unread does nothing for the currently-viewed workspace,
otherwise keep the existing logic calling clearManualUnread(workspaceId) or
setManualUnread(workspaceId); update any related tests or UX notes to reflect
this behavior and ensure references: handleToggleUnread, isActive,
isManuallyUnread, clearManualUnread, setManualUnread, and
clearWorkspaceAttention are considered.


const handleCopyBranchName = async () => {
if (!branch) {
toast.error("Branch name is not available");
Expand All @@ -152,9 +165,11 @@ export function useDashboardSidebarWorkspaceItemActions({
handleDeleted,
handleOpenInFinder,
handleRemoveFromSidebar,
handleToggleUnread,
isActive,
isDeleteDialogOpen,
isRenaming,
isUnread,
moveWorkspaceToSection,
renameValue,
setIsDeleteDialogOpen,
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/renderer/stores/v2-notifications/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export {
getV2ChatNotificationSource,
getV2ManualNotificationSource,
getV2NotificationSourceKey,
getV2NotificationSourcesForPane,
getV2NotificationSourcesForTab,
Expand All @@ -9,13 +10,15 @@ export {
selectV2SourcesNotificationStatus,
selectV2TabNotificationStatus,
selectV2TerminalNotificationStatus,
selectV2WorkspaceIsUnread,
selectV2WorkspaceNotificationStatus,
useV2ChatNotificationStatus,
useV2NotificationStore,
useV2PaneNotificationStatus,
useV2SourcesNotificationStatus,
useV2TabNotificationStatus,
useV2TerminalNotificationStatus,
useV2WorkspaceIsUnread,
useV2WorkspaceNotificationStatus,
type V2NotificationPaneLike,
type V2NotificationSource,
Expand Down
34 changes: 33 additions & 1 deletion apps/desktop/src/renderer/stores/v2-notifications/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type V2NotificationTabLike = Pick<Tab<unknown>, "panes">;

export type V2NotificationSource =
| { type: "terminal"; id: string }
| { type: "chat"; id: string };
| { type: "chat"; id: string }
| { type: "manual"; id: string };

export type V2NotificationSourceType = V2NotificationSource["type"];
export type V2NotificationSourceKey = `${V2NotificationSourceType}:${string}`;
Expand Down Expand Up @@ -46,6 +47,7 @@ export interface V2NotificationState {
status: ActivePaneStatus,
occurredAt?: number,
) => void;
setManualUnread: (workspaceId: string) => void;
clearSourceStatus: (
source: V2NotificationSourceInput,
workspaceId?: string,
Expand Down Expand Up @@ -99,6 +101,15 @@ export const useV2NotificationStore = create<V2NotificationState>()((set) => ({
occurredAt,
);
},
setManualUnread: (workspaceId) => {
useV2NotificationStore
.getState()
.setSourceStatus(
getV2ManualNotificationSource(workspaceId),
workspaceId,
"review",
);
},
clearSourceStatus: (source, workspaceId) => {
const sourceKey = getV2NotificationSourceKey(source);
set((state) => {
Expand Down Expand Up @@ -194,6 +205,12 @@ export function getV2ChatNotificationSource(
return { type: "chat", id: chatId };
}

export function getV2ManualNotificationSource(
workspaceId: string,
): V2NotificationSource {
return { type: "manual", id: workspaceId };
}

export function getV2NotificationSourcesForPane(
pane: V2NotificationPaneLike | null | undefined,
): V2NotificationSource[] {
Expand Down Expand Up @@ -285,6 +302,21 @@ export function useV2WorkspaceNotificationStatus(workspaceId: string) {
);
}

export function selectV2WorkspaceIsUnread(workspaceId: string) {
return (state: V2NotificationState) => {
for (const entry of Object.values(state.sources)) {
if (entry.workspaceId === workspaceId && entry.status === "review") {
return true;
}
}
return false;
};
}

export function useV2WorkspaceIsUnread(workspaceId: string) {
return useV2NotificationStore(selectV2WorkspaceIsUnread(workspaceId));
}

export function useV2TabNotificationStatus(
workspaceId: string,
tab: V2NotificationTabLike | null | undefined,
Expand Down
Loading