Repository navigation
CM-77192: Polish the Cycode tool window around the scan scope - #105
aaron-butler-cy-int wants to merge 5 commits into
Conversation
aa4d5b7 to
cf1672e
Compare
- 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]>
cf1672e to
f69f210
Compare
… collapse state machine Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
omer-roth
left a comment
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
DRY (medium): the dock orientation is computed in 3 places.
CycodeContentTab.isStacked()ScanContentTab.getContent()(dockAnchor?.isHorizontal ?: false)- the
ToolWindowManagerListenerinCycodeToolWindowFactory
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
…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]>
Summary
Second part of the split of #103, which is now merged. This branch is rebased onto
mainand contains two commits (polish the Cycode tool window...anduse platform tree state...).AnimatedIconrenderer animation); scan buttons are disabled, without flicker, while their scan runs.TreeState). They reset only for a rescanned scan type, the trash icon or Scan all.updateToolWindowState(project, reloadResults)rebuilds the right panel, andrefreshRunningState(project)only toggles the scan buttons and the tree spinners.Jira
CM-77192
Testing
./gradlew test): scan state counters and message keys. CI (Build, Verify plugin) passed on the previous head.🤖 Generated with Claude Code