Skip to content

CM-77192: Polish the Cycode tool window around the scan scope - #105

Open
aaron-butler-cy-int wants to merge 5 commits into
cycodehq:mainfrom
aaron-butler-cy-int:CM-77192-ui-polish
Open

aaron-butler-cy-int wants to merge 5 commits into
cycodehq:mainfrom
aaron-butler-cy-int:CM-77192-ui-polish

Conversation

@aaron-butler-cy-int

@aaron-butler-cy-int aaron-butler-cy-int commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Second part of the split of #103, which is now merged. This branch is rebased onto main and contains two commits (polish the Cycode tool window... and use platform tree state...).

  • Spinner in front of each scan type in the results tree while it runs (platform AnimatedIcon renderer animation); scan buttons are disabled, without flicker, while their scan runs.
  • Scan all button, scan options that are scrollable and collapsible, and a layout that follows the dock side.
  • Close button on the vulnerability view; hint and loading text wrap to the width.
  • Expanded results rows stay expanded while other scans finish (platform TreeState). They reset only for a rescanned scan type, the trash icon or Scan all.
  • Tool window updates have two plain entry points: updateToolWindowState(project, reloadResults) rebuilds the right panel, and refreshRunningState(project) only toggles the scan buttons and the tree spinners.
  • A scan type's rows collapse, and its findings summary clears, as soon as its scan starts (also for Scan all).
  • Right clicking a finding in the tree only opens the context menu.

Jira

CM-77192

Testing

  • Unit tests pass (./gradlew test): scan state counters and message keys. CI (Build, Verify plugin) passed on the previous head.
  • Checked by hand in a sandbox IDE: the collapse, the spinner, the layout in all dock positions and the tree expansion.

🤖 Generated with Claude Code

@aaron-butler-cy-int
aaron-butler-cy-int force-pushed the CM-77192-ui-polish branch 2 times, most recently from aa4d5b7 to cf1672e Compare November 25, 2026 14:12
aaron-butler-cy-int and others added 2 commits November 25, 2026 10:27
- Spinners in the results tree while a scan runs, and scan buttons that are
  disabled (without flicker) while their scan runs
- Scan all button, scan options that are scrollable and collapsible, and a
  layout that follows the dock side
- Close button on the vulnerability view and wrapped hint text
- Keep expanded results rows expanded while other scans finish
- Route tool window updates through ToolWindowUpdate

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- TreeState restores the expanded rows after a reload instead of matching
  nodes by name by hand; rows of a rescanned scan type are collapsed after
- AnimatedIcon.ANIMATION_IN_RENDERER_ALLOWED animates the spinner, so the
  repaint timer and its lifecycle code are gone

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… collapse state machine

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aaron-butler-cy-int
aaron-butler-cy-int marked this pull request as ready for review November 25, 2026 17:29

@omer-roth omer-roth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review against SOLID / YAGNI / KISS / DRY. Inline comments cover medium-and-above findings only.

Also, the PR description mentions a ToolWindowUpdate enum with a tested routing function and collapse-state tests. Commit cd36309 dropped those, so the description is out of date.

state.applyTo(tree)
// the rows of a scan type that is running again start over (this also covers the Scan all buttons)
CliScanType.entries.filter { pluginLocalState.isScanRunning(it) }.forEach {
tree.collapsePath(TreePath(rootNodes.getScanTypeNode(it).path))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correctness (medium): the rescanned scan type is almost never collapsed.

When a scan finishes, CliService.rerunAnnotators() calls updateToolWindowState(). That only queues refreshTree() with invokeLater. The background thread then goes straight on to the finally in CycodeService.runScanBackgroundTask, which calls scanFinished(scanType). By the time the EDT runs this loop, isScanRunning(it) is usually already false. So the "rows of a rescanned scan type start over" behavior only happens when another scan type finishes during the run, and it depends on timing.

Suggestion: collapse when the scan starts (in refreshRunningState / runScanBackgroundTask before the task runs), or pass the finished scan type into the refresh explicitly. Don't read the shared running state after an async hop.

}

// left/right docking is narrow and tall: results above the scan controls; bottom: side by side
private fun isStacked(): Boolean {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

DRY (medium): the dock orientation is computed in 3 places.

  • CycodeContentTab.isStacked()
  • ScanContentTab.getContent() (dockAnchor?.isHorizontal ?: false)
  • the ToolWindowManagerListener in CycodeToolWindowFactory

The null fallbacks disagree. When the anchor is null, isStacked() returns false, so the splitter lays out side by side. ScanContentTab uses horizontal = false, so the scan tab stacks. The tree and the scan tab then get conflicting layouts.

Suggestion: one helper, e.g. fun isToolWindowStacked(project): Boolean. Compute it once in show() and pass it into ScanContentTab.getContent(...) instead of having it look up ToolWindowManager itself. That also keeps ScanContentTab unaware of where it is docked (SRP).

return panel
}

override fun getContent(service: CycodeService): JPanel {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SRP / KISS (medium): getContent is about 90 lines and builds two layouts inline.

It resolves the dock side, refreshes the git state, resets the button registry, builds the title, builds both the horizontal and the stacked layouts, wraps them in a scroll pane and adds the collapse header. One detail is easy to miss: titleLabel and scanAll are first added to title, then in the horizontal branch they are added to columns. Swing silently reparents them, so title is built and then thrown away.

Suggestion: split into buildTitleRow(), buildStackedLayout(...) and buildHorizontalLayout(...), and build title only in the stacked branch. Each piece is then readable on its own, and the reparenting goes away.


/** Only the scan buttons and the spinners in the tree change; whatever is shown is never replaced. */
fun refreshRunningState() {
scanTab?.takeIf { it.panel === treeView.getRightPanel() }?.refreshRunningState(project)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

KISS (medium): "is the scan tab on screen" is tracked twice.

scanTab is cleared on every show, and the code also checks it.panel === treeView.getRightPanel(). ScanContentTab.panel is a public property that exists only for this identity check. Two sources of truth for the same fact can drift apart.

Suggestion: pick one. Either keep scanTab as the single source (it is already nulled in showStatePanel and showDetection) and drop the identity check and ScanContentTab.panel, or drop scanTab and derive it from the right panel.

aaron-butler-cy-int and others added 2 commits November 26, 2026 09:00
…plit the scan tab layout

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…open nothing on right click

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.

2 participants