8000 Find and keep layers inside layer groups by tomerkon · Pull Request #169 · gimp-mcp/gimp-mcp · GitHub
[go: up one dir, main page]

Skip to content

Find and keep layers inside layer groups - #169

Merged
tomerkon merged 2 commits into
mainfrom
fix-131-grouped-layers
Nov 29, 2026
Merged

tomerkon merged 2 commits into
mainfrom
fix-131-grouped-layers

Conversation

@tomerkon
@tomerkon tomerkon commented Nov 29, 2026 •
Copy link
Copy Markdown
Collaborator

Fixes #131.

layer_name now searches the whole layer tree, so the ~30 tools that take one find layers inside groups. layer_index still counts only top-level layers, matching list_layers.

Tools that place a layer next to an existing one now keep it in that layer's group:

  • reorder_layer moves a layer within its own group, and new_position is its index there. Before, a grouped layer was moved out to the top level.
  • duplicate_layer puts the copy directly above the source, in its group. Before, the copy went to the top of the image.
  • apply_drop_shadow puts the shadow directly below the source, in its group. Before, it went to the top level, where it could cover the layer. With layer_name reaching grouped layers, this one became easy to hit.

duplicate_layer and apply_drop_shadow also return an error, and free the new layer, when GIMP refuses the insert.

Tests

  • tests/test_grouped_layers.py (offline, 8 tests). It fails against main's plugin.
  • tests/test_grouped_layers_live.py, on GIMP 3.2.8: name lookup two groups deep, reorder by name and of the selected layer, duplicate, drop shadow, layer_index, rename and delete.
  • All offline scripts pass. The layer-position, negative-index, layer-report and locked-pixels live tests still pass.

Not in this PR

list_layers and get_image_metadata still list only top-level layers, so clients can't find out grouped layers' names yet. That will be a separate issue.

layer_index still counts only top-level layers, so it keeps matching the indexes list_layers reports. That's a decision for now: whether grouped layers should get an index too will be decided in the same follow-up as listing them.

Summary by CodeRabbit

  • Bug Fixes
    • Layer tools that search by name now work with layers nested inside groups; index-based lookup remains limited to top-level layers.
    • Reordering keeps grouped layers in their current group and uses positions among that group’s layers.
    • Duplicated layers and drop shadows are placed beside their source within the same group. Failed insertions now return errors instead of reporting success.
  • Documentation
    • Clarified how grouped layers are handled by layer operations.

layer_name now searches the whole layer tree, so every tool that takes one
finds layers inside groups. layer_index still counts top-level layers only,
matching list_layers.

Tools that place a layer next to an existing one now keep it in that
layer's group:
- reorder_layer moves a layer within its own group; new_position is its
  index there. Before, a grouped layer was moved out to the top level.
- duplicate_layer puts the copy directly above the source, in its group.
  Before, the copy went to the top of the image.
- apply_drop_shadow puts the shadow directly below the source, in its
  group. Before, it went to the top level, where it could cover the layer.

duplicate_layer and apply_drop_shadow also report an error, and free the
new layer, when GIMP refuses to insert it.

Fixes #131.
@coderabbitai
coderabbitai Bot commented Nov 29, 2026 •
Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a22eff7 and 2c08953.

Files selected for processing: 6

  • CHANGELOG.md
  • gimp-mcp-plugin.py
  • gimp_mcp_server.py
  • tests/test_grouped_layers.py
  • tests/test_grouped_layers_live.py
  • tests/test_pdb_status.py

No actionable comments were generated in the recent review.

Walkthrough

Layer-name lookup now traverses nested groups, while layer_index remains limited to top-level layers. Reordering uses sibling positions and keeps layers in their current group. Duplication and drop-shadow insertion target positions beside the source in its group. Failed insertions clean up the created layer and return an error.

Changes

Grouped layer operations

Layer / File(s) Summary
Nested layer lookup and targeting
gimp-mcp-plugin.py, gimp_mcp_server.py, tests/test_grouped_layers.py, tests/test_grouped_layers_live.py
Name-based lookup now finds nested layers; layer_index remains top-level only. Offline and live tests cover grouped-layer targeting, including rename, delete, property updates, and missing names.
Group-local reorder and insertion
gimp-mcp-plugin.py, gimp_mcp_server.py, CHANGELOG.md, tests/test_grouped_layers.py, tests/test_grouped_layers_live.py, tests/test_pdb_status.py
Reordering retains the source layer’s parent and uses sibling positions. Duplication inserts above the source, and drop shadows insert below it in the same group. Tests cover refused insertions, cleanup, and undo-group closure.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • gimp-mcp/gimp-mcp#136 — This PR changes reorder positions to use the layer’s siblings, which the issue identifies as a prerequisite for its position handling. The summaries do not state that the no-op behavior itself changes.

Possibly related PRs

  • gimp-mcp/gimp-mcp#134 — Both PRs change reorder_layer behavior and insertion-failure handling, so their behavior contracts may interact.

Suggested reviewers: vicarc, jhammons

Merge Risk: Minimal · previous review a22ef

This change makes layer-name lookup find layers inside groups and keeps reordered, duplicated, and drop-shadow layers beside their source. No merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #131 has two coding requirements that this PR meets from the supplied evidence, and one that it decides differently.

(a) layer_name lookup [#131]: MET. The change summary for gimp-mcp-plugin.py…
Needed to decide: the issue owner must confirm whether layer_index must count layers inside groups (as the issue text implies) or stay top-level to match list_layers (as the PR states). If grouped indexing is required, the change must add a…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "Find and keep layers inside layer groups" matches the main change in the changeset. The PR makes layer-name lookup search the full layer tree, including group children. It also keeps reorde…
Out of Scope Changes check Passed The changed areas all relate to #131 or to its tests. gimp-mcp-plugin.py changes cover layer-name lookup, reorder, duplicate and drop-shadow placement, and checked insertion with cleanup. tests/test_g…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "Find and keep layers inside layer groups" matches the main change in the changeset. The PR makes layer-name lookup search the full layer tree, including group children. It also keeps reordered, duplicated, and drop-shadow layers inside their source group. The title names the primary theme without listing files, and it is a single short sentence.

Full details: Out of Scope Changes check

Explanation

The changed areas all relate to #131 or to its tests. gimp-mcp-plugin.py changes cover layer-name lookup, reorder, duplicate and drop-shadow placement, and checked insertion with cleanup. tests/test_grouped_layers.py and tests/test_grouped_layers_live.py cover those paths. The tests/test_pdb_status.py fixture change adds get_parent() to the mocked layer so the drop-shadow path can run under the new parent lookup, which supports the in-scope change. CHANGELOG.md entries describe the same fixes. gimp_mcp_server.py changes are documentation: they describe grouped-layer lookup and sibling-position semantics. They also remove a create_layer recommendation about nonnegative positions. That removal is not explained in the PR description. It appears tied to sibling-position semantics, and no evidence shows it is unrelated. The PR description states that list_layers and get_image_metadata are not changed, and this is not a scope problem because #131 does not request those changes. No demonstrated unrelated change was found. Caveat: the plugin diff was not readable, so the code-level scope check relies on the change summary.

Full details: Linked Issues check

Explanation

Issue #131 has two coding requirements that this PR meets from the supplied evidence, and one that it decides differently.

(a) layer_name lookup [#131]: MET. The change summary for gimp-mcp-plugin.py says layer-name lookup now searches the full layer tree, including group children. The offline test test_layer_name_finds_layers_inside_groups covers this. Live test coverage is reported for a two-level nested lookup on GIMP 3.2.8.

(b) reorder_layer keeps a grouped layer in its group, with new_position as the index in that group [#131]: MET. The summary says reordering keeps a layer in its existing group. The offline test test_reorder_layer_keeps_a_grouped_layer_in_its_group covers this. The live test covers reorder of the selected grouped layer.

(c) duplicate_layer copy placement [#131, flagged as worth checking]: MET. The copy is inserted directly above its source in the same group. Offline test test_duplicate_layer_inserts_the_copy_in_the_source_group covers this.

(d) layer_index: UNRESOLVED. The issue text lists layer_index as having the same top-level-only limit as layer_name. The PR keeps layer_index top-level only, so it matches list_layers. The issue's suggested fix does not change layer_index. The PR description and the test test_layer_index_counts_only_top_level_layers state this as a deliberate choice. The issue text and the PR choice conflict, and the issue owner has not confirmed which behavior is wanted. Whether layer_index must reach grouped layers cannot be decided from the supplied evidence.

Not verified: I could not read the changed plugin code. The diff and file reads for gimp-mcp-plugin.py were unavailable or truncated, so the findings above rely on the change summary, the PR description, and the test descriptions. I did not run the tests.

Resolution

Needed to decide: the issue owner must confirm whether layer_index must count layers inside groups (as the issue text implies) or stay top-level to match list_layers (as the PR states). If grouped indexing is required, the change must add a whole-tree index path and specify its ordering. If top-level indexing is accepted, the issue text should be updated to say so. Also needed: a readable diff of gimp-mcp-plugin.py at the reviewed head, to confirm _resolve_layer, _reorder_layer, _duplicate_layer and the drop-shadow path directly.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f25a74a and a22eff7.

Files selected for processing: 6

  • CHANGELOG.md
  • gimp-mcp-plugin.py
  • gimp_mcp_server.py
  • tests/test_grouped_layers.py
  • tests/test_grouped_layers_live.py
  • tests/test_pdb_status.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@github-actions github-actions Bot added the bug Something isn't working label Nov 29, 2026
@gimp-mcp gimp-mcp deleted a comment from coderabbitai Bot Nov 29, 2026
@tomerkon
tomerkon merged commit 59c1c46 into main Nov 29, 2026
5 checks passed
@tomerkon
tomerkon deleted the fix-131-grouped-layers branch November 29, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Layers inside groups: layer_name can't find them and reorder_layer moves them out

1 participant

0