Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b7eaa8

Browse files
committed
feat(sketch): add plan compression and auto-pin to tool window#408
- Add compressed view mode with toggle functionality for plan display- Implement auto-pin feature to automatically open plans in tool window- Add dynamic task count display in compressed panel header- Enhance UI with expand/collapse controls and improved layout management
1 parentff8937b commit0b7eaa8

File tree

3 files changed

+94
-9
lines changed

3 files changed

+94
-9
lines changed

‎.augment/test_plan_compression.md‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#PlanLangSketch 压缩功能实现总结
2+
3+
##实现的功能
4+
5+
###1. 智能Pin逻辑
6+
- PlanLangSketch现在支持`autoPinEnabled`参数(默认为true)
7+
-**关键改进**:如果启用autoPinEnabled,当前Plan默认显示为压缩状态,避免同时显示两份Plan
8+
- 自动Pin到工具窗口,用户可以在工具窗口中查看完整计划
9+
- 压缩状态显示:"Plan pinned (X tasks)",清楚表明已Pin状态
10+
11+
###2. 压缩模式
12+
- 添加了`toggleCompression()`方法来切换压缩/展开状态
13+
- 压缩模式下显示简洁的标题栏,包含Pin图标提示
14+
- 展开模式下显示完整的计划内容
15+
- 点击压缩面板中的箭头图标可以展开
16+
- 切换到压缩模式时自动Pin到工具窗口
17+
18+
###3. UI改进
19+
- 压缩面板使用箭头图标指示可展开
20+
- Pin图标显示当前Pin状态
21+
- 动态显示任务数量
22+
- 保持原有的工具栏功能(Copy、Pin按钮)
23+
24+
##使用方式
25+
26+
###方式1:默认Pin(推荐)
27+
```kotlin
28+
val planSketch=PlanLangSketch(
29+
project= project,
30+
content= content,
31+
agentTaskItems= taskItems,
32+
autoPinEnabled=true// 默认值
33+
)
34+
```
35+
36+
###方式2:手动压缩
37+
```kotlin
38+
// 切换压缩状态
39+
planSketch.toggleCompression()
40+
```
41+
42+
##逻辑优化
43+
44+
###避免重复显示
45+
-**autoPinEnabled = true**:当前Plan显示为压缩状态,完整内容在工具窗口
46+
-**autoPinEnabled = false**:当前Plan显示完整内容,完成时才Pin到工具窗口
47+
- 解决了同时显示两份Plan的问题
48+
49+
###智能状态管理
50+
- 压缩状态清楚标明"Plan pinned"
51+
- Pin图标提供视觉提示
52+
- 点击展开时显示完整内容,但工具窗口仍然可用
53+
54+
##用户体验改进
55+
56+
1.**避免重复**:不会同时显示两份相同的Plan内容
57+
2.**节省空间**:默认压缩状态最大化编辑区域
58+
3.**清晰状态**:Pin图标和文字清楚表明当前状态
59+
4.**灵活操作**:可以随时展开查看详情或在工具窗口中查看
60+
61+
##建议的使用场景
62+
63+
-**默认模式(autoPinEnabled=true)**:最佳体验,自动压缩+Pin到工具窗口
64+
-**手动压缩**:用户可以主动切换到压缩模式节省空间
65+
-**完整展开**:需要在当前位置详细查看计划时展开

‎core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/CodeHighlightSketch.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,6 @@ private suspend fun executeEditFileCommand(project: Project, currentText: String
533533
}
534534
}catch (e:Exception) {
535535
callback("DEVINS_ERROR:${e.message}")
536-
}finally {
537-
file?.delete(project)
538536
}
539537
}
540538

‎core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/plan/PlanLangSketch.kt‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ class PlanLangSketch(
4848
setupUI()
4949
renderPlan()
5050

51-
//默认Pin到工具窗口(如果启用)
51+
//如果启用自动Pin,默认显示为压缩状态
5252
if (autoPinEnabled&&!isInToolwindow) {
53-
// 延迟执行,确保组件已完全初始化
53+
showCompressedContent()
54+
// 延迟执行Pin操作,确保组件已完全初始化
5455
invokeLater {
5556
autoPinToToolWindow()
5657
}
@@ -83,18 +84,29 @@ class PlanLangSketch(
8384

8485
val expandIcon=JBLabel(AllIcons.General.ArrowRight).apply {
8586
cursor=Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
87+
toolTipText="Click to expand plan details"
8688
addMouseListener(object:MouseAdapter() {
8789
overridefunmouseClicked(e:MouseEvent) {
8890
toggleCompression()
8991
}
9092
})
9193
}
9294

93-
val titleLabel=JLabel("Plan (${agentTaskItems.size} tasks)").apply {
95+
val pinIcon=JBLabel(AllIcons.Toolbar.Pin).apply {
96+
toolTipText="Plan is pinned to tool window"
97+
}
98+
99+
val titleLabel=JLabel().apply {
94100
font= font.deriveFont(font.styleor java.awt.Font.BOLD)
101+
text=if (autoPinEnabled) {
102+
"Plan pinned (${agentTaskItems.size} tasks)"
103+
}else {
104+
"Plan (${agentTaskItems.size} tasks)"
105+
}
95106
}
96107

97108
add(expandIcon)
109+
if (autoPinEnabled) add(pinIcon)
98110
add(titleLabel)
99111
}
100112

@@ -160,6 +172,10 @@ class PlanLangSketch(
160172
showFullContent()
161173
}else {
162174
showCompressedContent()
175+
// 当切换到压缩模式时,自动Pin到工具窗口
176+
if (!isInToolwindow) {
177+
autoPinToToolWindow()
178+
}
163179
}
164180
}
165181

@@ -185,8 +201,13 @@ class PlanLangSketch(
185201
compressedPanel?.let { panel->
186202
val titlePanel= panel.getComponent(0)as?JPanel
187203
titlePanel?.let { tp->
188-
val titleLabel= tp.components.find { itisJLabel&& it!= tp.components[0] }as?JLabel
189-
titleLabel?.text="Plan (${agentTaskItems.size} tasks)"
204+
// 找到标题标签(最后一个JLabel组件)
205+
val titleLabel= tp.components.filterIsInstance<JLabel>().lastOrNull()
206+
titleLabel?.text=if (autoPinEnabled) {
207+
"Plan pinned (${agentTaskItems.size} tasks)"
208+
}else {
209+
"Plan (${agentTaskItems.size} tasks)"
210+
}
190211
}
191212
}
192213
}
@@ -237,10 +258,11 @@ class PlanLangSketch(
237258
updatePlan(agentPlans)
238259
savePlanToService()
239260

240-
//自动Pin到工具窗口
241-
if (autoPinEnabled) {
261+
//如果没有启用自动Pin,则在完成时Pin到工具窗口
262+
if (!autoPinEnabled) {
242263
autoPinToToolWindow()
243264
}
265+
// 如果启用了自动Pin,工具窗口内容会自动更新,因为我们调用了updatePlan
244266

245267
hasUpdated=true
246268
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp