Skip to content

Fix: Session grouping — add Move to Group menu item#125

Closed
davidortinau wants to merge 1 commit intomainfrom
fix/grouping-seems-broken-i-can-create-a-gro-20260216-2018
Closed

Fix: Session grouping — add Move to Group menu item#125
davidortinau wants to merge 1 commit intomainfrom
fix/grouping-seems-broken-i-can-create-a-gro-20260216-2018

Conversation

@davidortinau
Copy link
Copy Markdown
Collaborator

Bug

Users can create groups but cannot move sessions into them.

Root Cause

SessionListItem.razor receives Groups and OnMove parameters but never renders a UI element to invoke the move.

Fix

  1. Added Move to submenu to the session context menu
  2. Made MoveSession() defensive - creates SessionMeta on the fly if missing
  3. Added CSS for submenu styling
  4. Added 6 unit tests

Testing

  • dotnet test: 366 tests pass
  • dotnet build -f net10.0-maccatalyst: builds clean

The SessionListItem context menu had Groups and OnMove parameters wired
up but never rendered any UI to move sessions between groups. This adds:

- A 'Move to…' submenu in the session context menu that lists all
  available groups (excluding the session's current group). Only shown
  when multiple groups exist.
- Defensive auto-creation of SessionMeta in MoveSession() when the
  session hasn't been reconciled yet, preventing silent no-ops.
- Submenu CSS styling (indented items, non-interactive label).
- 6 new unit tests covering MoveSession behavior: existing meta update,
  auto-create meta, invalid group rejection, cross-group moves, move
  back to default, and StateChanged event firing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidortinau
Copy link
Copy Markdown
Collaborator Author

@copilot review this PR

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

@davidortinau I've opened a new pull request, #126, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown

Copilot AI left a 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 adds the missing UI for moving sessions between groups, fixing a bug where users could create groups but had no way to move sessions into them.

Changes:

  • Added "Move to..." submenu in the session context menu with group options
  • Made MoveSession() defensive by auto-creating SessionMeta entries for sessions that haven't been reconciled yet
  • Added CSS styling for submenu display with proper indentation and hover states
  • Added 6 comprehensive unit tests covering various move scenarios

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
SessionListItem.razor Added "Move to..." submenu UI with group filtering and click handlers
SessionListItem.razor.css Added CSS for .menu-submenu, .submenu-label, and .submenu-item
CopilotService.Organization.cs Refactored MoveSession() to validate group first, auto-create missing SessionMeta, and always save/notify
SessionOrganizationTests.cs Added MoveSessionTests class with 6 test cases covering edge cases

Comment on lines 173 to +178
var meta = Organization.Sessions.FirstOrDefault(m => m.SessionName == sessionName);
if (meta != null && Organization.Groups.Any(g => g.Id == groupId))
if (meta == null)
{
// Session exists but wasn't reconciled yet — create meta on the fly
meta = new SessionMeta { SessionName = sessionName, GroupId = groupId };
Organization.Sessions.Add(meta);
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

There's a potential race condition here. Organization.Sessions is a List<SessionMeta> which is not thread-safe. This method can be called from both the UI thread (via Blazor event handlers in SessionSidebar.razor) and background threads (via WsBridgeServer.HandleOrganizationCommand which runs in the WebSocket receive loop).

The Add operation on line 178 could collide with concurrent reads/writes from other threads. Consider adding synchronization (e.g., lock statement) around the list access, or using a thread-safe collection. This same issue exists in other organization methods that modify Organization.Sessions and Organization.Groups.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

@davidortinau I've opened a new pull request, #127, to work on those changes. Once the pull request is ready, I'll request review from you.

@PureWeen
Copy link
Copy Markdown
Owner

Hey! 🎉

Fantastic job spotting this issue and getting a fix out the door. The "Move to Group" context menu was exactly the missing piece — groups could be created but sessions were stranded with no way to move them. Your instinct to make MoveSession() defensive and auto-create missing SessionMeta was spot-on engineering.

Since this PR was opened, all of these improvements have landed in main through subsequent work. After rebasing on the latest origin/main, this branch produces a zero diff — every change here is already part of the codebase. Do, or do not — there is no diff. 🧘

This is being closed purely because the work is done, not because it wasn't valuable. Your contributions helped shape the direction here, and we'd love to see more. The Force of your PRs is strong. Keep them coming! 🚀

@PureWeen PureWeen closed this Feb 17, 2026
@PureWeen PureWeen deleted the fix/grouping-seems-broken-i-can-create-a-gro-20260216-2018 branch February 22, 2026 00:18
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.

4 participants