Skip to content

Commit

Permalink
Merge pull request #267 from griptape-ai:fix/menuSeparators
Browse files Browse the repository at this point in the history
- Fixed an issue where menu separators in the Griptape Menu were missing. That's now resolved.
  • Loading branch information
shhlife authored Feb 21, 2025
2 parents cfa4e5f + 45ac183 commit 3209b7c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security -->

## [2.2.06] - 2025-22-02
### Fixed
- Fixed an issue where menu separators in the Griptape Menu were missing. That's now resolved.
![menuSeparatorsMissing](docs/images/menuSeparatorsMissing.png)

## [2.2.05] - 2025-17-02
### Fixed
- Fixed an issue where nodes needed to be resized to be displayed properly when being created. This was true for many of the nodes due to a bug in ComfyUI where if you had a string as an input that was set to "forceInput" (like the `input_string` on most nodes), it wouldn't display any multiline text node properly. The fix was to add `multiLine=True` on those `forceInput` nodes as well.. that solves it!
Expand Down
Binary file added docs/images/menuSeparatorsMissing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 25 additions & 7 deletions js/gtUIMenuSeparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,32 @@ const sep_above_items = [
"Griptape RAG Rerank: Text Chunks Module",
"Griptape RAG Response: Prompt Module",
];
export function setupMenuSeparator() {
const originalAddItem = LiteGraph.ContextMenu.prototype.addItem;
LiteGraph.ContextMenu.prototype.addItem = function (name, value, options) {
for (let item of sep_above_items) {
if (name === item) {
this.addItem("", null);
export function setupMenuSeparator(app) {
// Store original constructor
const originalContextMenu = LiteGraph.ContextMenu;

LiteGraph.ContextMenu = function (values, parentMenu, event) {
// If this is a submenu (values is an array)
if (Array.isArray(values)) {
// Add separators before specific items
for (let i = 0; i < values.length; i++) {
const item = values[i];
if (!item) continue;

// Check if this item needs a separator
// We'll check both content and value since some menus might use either
const itemText = item.content || item.value;
if (itemText && sep_above_items.includes(itemText)) {
values.splice(i, 0, null);
i++; // Skip ahead since we added an item
}
}
}
return originalAddItem.apply(this, arguments);

// Create the menu
return new originalContextMenu(values, parentMenu, event);
};

// Maintain the prototype chain
LiteGraph.ContextMenu.prototype = originalContextMenu.prototype;
}
4 changes: 2 additions & 2 deletions js/gtUINodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ app.registerExtension({
}
},
setup: (app) => {
setupMenuSeparator();
setupMenuSeparator(app);
function messageHandler(event) {
console.log(event.detail.message);
// console.log(event.detail.message);
}
api.addEventListener("comfy.gtUI.runagent", messageHandler);

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "comfyui-griptape"
version = "2.2.05"
version = "2.2.06"
description = "Griptape LLM(Large Language Model) Nodes for ComfyUI."
authors = ["Jason Schleifer <[email protected]>"]
readme = "README.md"
Expand All @@ -9,7 +9,7 @@ readme = "README.md"
[project]
name = "comfyui-griptape"
description = "Griptape LLM(Large Language Model) Nodes for ComfyUI."
version = "2.2.05"
version = "2.2.06"
license = {file = "LICENSE"}
dependencies = ["attrs>=24.3.0,<26.0.0", "openai>=1.58.1,<2.0.0", "griptape[all]>=1.3.1", "python-dotenv", "poetry==1.8.5", "griptape-black-forest @ git+https://github.com/griptape-ai/griptape-black-forest.git", "griptape_serper_driver_extension @ git+https://github.com/mertdeveci5/griptape-serper-driver-extension.git"]

Expand Down

0 comments on commit 3209b7c

Please sign in to comment.