Skip to content

fix: Enable nested group display in command tree view#32

Merged
kubrickcode merged 1 commit intomainfrom
issue-31
Sep 25, 2025
Merged

fix: Enable nested group display in command tree view#32
kubrickcode merged 1 commit intomainfrom
issue-31

Conversation

@kubrickcode
Copy link
Owner

Previously, createTreeItemsFromGroup only created CommandTreeItems, causing nested groups to be invisible in the tree view beyond 2 levels.

issue #31

Previously, createTreeItemsFromGroup only created CommandTreeItems, causing nested groups to be invisible in the tree view beyond 2 levels.

issue #31
@kubrickcode
Copy link
Owner Author

/gemini review

@gemini-code-assist
Copy link

Summary of Changes

Hello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where nested command groups were not visible in the command tree view. By modifying the logic that creates tree items, the system can now correctly differentiate between individual commands and command groups, ensuring that all levels of grouping are accurately represented and displayed to the user.

Highlights

  • Nested Group Display: The createTreeItemsFromGroup function has been updated to correctly identify and process nested command groups, allowing them to be properly displayed in the tree view.
  • Type Handling: The return type of createTreeItemsFromGroup has been broadened from CommandTreeItem[] to TreeItem[] to accommodate both individual commands and group items, improving type safety and flexibility.
  • New Test Case: A new test has been added to command-tree-provider.test.ts specifically to verify the correct handling and rendering of nested command groups, ensuring the new functionality works as expected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubrickcode kubrickcode self-assigned this Sep 25, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly enables the display of nested command groups in the tree view by updating createTreeItemsFromGroup to handle GroupTreeItem creation. The logic is sound and is accompanied by a new test case that validates the behavior. My review comments focus on improving the readability and maintainability of the test code by suggesting a way to reduce repetitive type casting.

@kubrickcode kubrickcode merged commit 3650b50 into main Sep 25, 2025
2 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The change correctly enables nested groups in the command tree view by updating createTreeItemsFromGroup to handle GroupTreeItem creation. The logic is sound and addresses the issue. My feedback focuses on improving the tests. I've suggested making the new test case for nested groups more comprehensive to cover multiple levels of nesting. I also pointed out a pattern of repetitive type casting in the test file that could be refactored for better readability.

Comment on lines +22 to +24
expect((result[0] as CommandTreeItem).commandString).toBe("echo hello");
expect((result[0] as CommandTreeItem).useVsCodeApi).toBe(false);
expect((result[0] as CommandTreeItem).terminalName).toBeUndefined();

Choose a reason for hiding this comment

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

medium

These repetitive type casts make the code harder to read. Since you've already asserted the type with toBeInstanceOf, you can introduce a variable to avoid repeated casting. This pattern can be applied to other similar assertions in this file.

For example:

const commandItem = result[0] as CommandTreeItem;
expect(commandItem.commandString).toBe("echo hello");
expect(commandItem.useVsCodeApi).toBe(false);
expect(commandItem.terminalName).toBeUndefined();

Comment on lines +118 to 139
it("should handle nested groups", () => {
const commands: ButtonConfig[] = [
{ name: "Simple Command", command: "echo simple" },
{
name: "Nested Group",
group: [
{ name: "Sub Command 1", command: "echo sub1" },
{ name: "Sub Command 2", command: "echo sub2" },
],
},
];

const result = createTreeItemsFromGroup(commands);

expect(result).toHaveLength(2);
expect(result[0]).toBeInstanceOf(CommandTreeItem);
expect((result[0] as CommandTreeItem).commandString).toBe("echo simple");

expect(result[1]).toBeInstanceOf(GroupTreeItem);
expect(result[1].label).toBe("Nested Group");
expect((result[1] as GroupTreeItem).commands).toHaveLength(2);
});

Choose a reason for hiding this comment

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

medium

This test case is a great addition for verifying group handling. However, it only tests a single level of grouping. Given the PR's goal is to fix nested group display, it would be more robust to test at least two levels of nesting to ensure the recursive nature of group display works as expected. This would involve checking the children of the created GroupTreeItem.

    it("should handle deeply nested groups", () => {
      const commands: ButtonConfig[] = [
        {
          name: "L1 Group",
          group: [
            { name: "L1 Cmd", command: "echo 1" },
            { name: "L2 Group", group: [{ name: "L2 Cmd", command: "echo 2" }] },
          ],
        },
      ];

      const l1Items = createTreeItemsFromGroup(commands);

      expect(l1Items).toHaveLength(1);
      const l1Group = l1Items[0] as GroupTreeItem;
      expect(l1Group).toBeInstanceOf(GroupTreeItem);
      expect(l1Group.label).toBe("L1 Group");

      const l2Items = createTreeItemsFromGroup(l1Group.commands);
      expect(l2Items).toHaveLength(2);
      const l2Group = l2Items[1] as GroupTreeItem;
      expect(l2Group).toBeInstanceOf(GroupTreeItem);
      expect(l2Group.label).toBe("L2 Group");
      expect(l2Group.commands[0].name).toBe("L2 Cmd");
    });

@kubrickcode kubrickcode deleted the issue-31 branch October 6, 2025 08:42
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.

1 participant