prompt_navigator 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/prompt_navigator/history.css +61 -7
- data/app/javascript/controllers/history_controller.js +14 -4
- data/app/views/prompt_navigator/_history.html.erb +4 -1
- data/app/views/prompt_navigator/_history_card.html.erb +27 -5
- data/lib/prompt_navigator/helpers.rb +6 -2
- data/lib/prompt_navigator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2bd1c7a54df81a452d45f5c47cf2d9d615c960d49c9315a932aa72fcbbb1c46
|
|
4
|
+
data.tar.gz: f8a13126d0457b4f78368a8c00354bb91fcafc4ee65dc41f1d1c26021bc066fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 140614573d6032ef309d6899a43c0c79f04819bc0fc33cb42c867c66f905ba04ed0db30776d7b3eb2d4d5d6535949e63c46b17e351d4fc8b9d74fbb39af56854
|
|
7
|
+
data.tar.gz: 5854d8db2def7559e15e1e5f6c0c5161148c07a99bc51e8a9087c522b0666c21c72fd942b5c7565e0adbb3e38840e83adcde5556d07cd4a58bbaf2dc996c5d75
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
|
-
gap: 8px;
|
|
6
5
|
padding-left: 32px; /* space for arrows */
|
|
6
|
+
margin-top: 20px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.history-card {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
15
15
|
position: relative;
|
|
16
16
|
z-index: 1;
|
|
17
|
+
margin-bottom: 16px;
|
|
17
18
|
transition:
|
|
18
19
|
box-shadow 0.15s ease,
|
|
19
20
|
transform 0.15s ease;
|
|
@@ -27,17 +28,70 @@
|
|
|
27
28
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
28
29
|
transform: translateY(-2px);
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
&:last-child {
|
|
33
|
+
margin-bottom: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:has(+ .history-straight-arrow) {
|
|
37
|
+
margin-bottom: 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.history-card-row {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: 6px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.history-card-row .history-card-link {
|
|
48
|
+
flex: 1;
|
|
49
|
+
min-width: 0;
|
|
30
50
|
}
|
|
31
51
|
|
|
32
52
|
.history-card-link {
|
|
33
|
-
display:
|
|
34
|
-
grid-template-columns: auto 1fr auto;
|
|
35
|
-
grid-gap: 8px;
|
|
53
|
+
display: block;
|
|
36
54
|
text-decoration: none;
|
|
37
55
|
color: #333;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.history-card-delete-form {
|
|
60
|
+
margin: 0;
|
|
61
|
+
display: flex;
|
|
38
62
|
align-items: center;
|
|
39
63
|
}
|
|
40
64
|
|
|
65
|
+
.history-card-delete {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
width: 22px;
|
|
70
|
+
height: 22px;
|
|
71
|
+
padding: 0;
|
|
72
|
+
border: none;
|
|
73
|
+
background: transparent;
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
color: #888;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
opacity: 0;
|
|
79
|
+
transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
|
|
80
|
+
|
|
81
|
+
i {
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
color: #dc2626;
|
|
87
|
+
background-color: rgba(220, 38, 38, 0.1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.history-card:hover .history-card-delete {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
41
95
|
.history-card-number {
|
|
42
96
|
font-size: 12px;
|
|
43
97
|
font-weight: 600;
|
|
@@ -57,7 +111,6 @@
|
|
|
57
111
|
font-size: 10px;
|
|
58
112
|
font-weight: 700;
|
|
59
113
|
letter-spacing: 0.02em;
|
|
60
|
-
margin-left: auto;
|
|
61
114
|
flex-shrink: 0;
|
|
62
115
|
padding: 2px 6px;
|
|
63
116
|
border-radius: 4px;
|
|
@@ -85,9 +138,10 @@
|
|
|
85
138
|
display: flex;
|
|
86
139
|
justify-content: center;
|
|
87
140
|
align-items: center;
|
|
88
|
-
height:
|
|
141
|
+
height: 16px;
|
|
89
142
|
margin: 0;
|
|
90
|
-
font-size:
|
|
143
|
+
font-size: 16px;
|
|
144
|
+
font-weight: bold;
|
|
91
145
|
color: #555;
|
|
92
146
|
line-height: 1;
|
|
93
147
|
}
|
|
@@ -8,7 +8,13 @@ export default class extends Controller {
|
|
|
8
8
|
#drawArrowsBound
|
|
9
9
|
#markerId = "history-arrow-head"
|
|
10
10
|
#startX = 32
|
|
11
|
-
|
|
11
|
+
// Curve offset scales with the vertical gap so arcs of different lengths
|
|
12
|
+
// nest instead of overlap. Bounded so short arcs don't collapse onto the
|
|
13
|
+
// stack and long arcs don't escape the sidebar pane (the stack only has
|
|
14
|
+
// `padding-left: 32px` of space before the chat area).
|
|
15
|
+
#minCurveOffset = 12
|
|
16
|
+
#maxCurveOffset = 28
|
|
17
|
+
#curveScale = 0.22
|
|
12
18
|
|
|
13
19
|
connect() {
|
|
14
20
|
this.#drawArrows()
|
|
@@ -102,13 +108,17 @@ export default class extends Controller {
|
|
|
102
108
|
// Skip if cards are adjacent - straight arrow is rendered by helper
|
|
103
109
|
if (verticalGap < 80) return
|
|
104
110
|
|
|
105
|
-
const path = this.#createCurvedArrowPath(startY, endY)
|
|
111
|
+
const path = this.#createCurvedArrowPath(startY, endY, verticalGap)
|
|
106
112
|
svg.appendChild(path)
|
|
107
113
|
}
|
|
108
114
|
|
|
109
|
-
#createCurvedArrowPath(startY, endY) {
|
|
115
|
+
#createCurvedArrowPath(startY, endY, verticalGap) {
|
|
110
116
|
const startX = this.#startX // left edge margin
|
|
111
|
-
const
|
|
117
|
+
const curveOffset = Math.max(
|
|
118
|
+
this.#minCurveOffset,
|
|
119
|
+
Math.min(verticalGap * this.#curveScale, this.#maxCurveOffset)
|
|
120
|
+
)
|
|
121
|
+
const curveX = startX - curveOffset // curve outward to the left
|
|
112
122
|
const pathData = `M ${startX} ${startY} C ${curveX} ${startY}, ${curveX} ${endY}, ${startX} ${endY}`
|
|
113
123
|
|
|
114
124
|
const path = document.createElementNS("http://www.w3.org/2000/svg", "path")
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<%
|
|
2
2
|
active_uuid = locals[:active_uuid]
|
|
3
3
|
card_path = locals[:card_path]
|
|
4
|
+
delete_path = locals[:delete_path]
|
|
5
|
+
# A PE is a leaf when no other PE in the chat references it as `previous`.
|
|
6
|
+
non_leaf_ids = @history.filter_map { |pe| pe.previous_id }
|
|
4
7
|
%>
|
|
5
8
|
|
|
6
9
|
<h2>History</h2>
|
|
7
10
|
<% if @history.present? %>
|
|
8
11
|
<div class="history-stack" data-controller="history">
|
|
9
12
|
<% @history.each_with_index do |ann, idx| %>
|
|
10
|
-
<%= render 'prompt_navigator/history_card', locals: { ann: ann, next_ann: @history[idx + 1], is_active: ann.execution_id == active_uuid, card_path: card_path } %>
|
|
13
|
+
<%= render 'prompt_navigator/history_card', locals: { ann: ann, next_ann: @history[idx + 1], is_active: ann.execution_id == active_uuid, card_path: card_path, delete_path: delete_path, is_leaf: !non_leaf_ids.include?(ann.id) } %>
|
|
11
14
|
<% end %>
|
|
12
15
|
<svg class="history-arrows" data-history-target="svg"></svg>
|
|
13
16
|
</div>
|
|
@@ -4,18 +4,40 @@
|
|
|
4
4
|
is_active = locals[:is_active]
|
|
5
5
|
parent_uuid = ann.previous&.execution_id
|
|
6
6
|
card_path = locals[:card_path]
|
|
7
|
+
delete_path = locals[:delete_path]
|
|
8
|
+
is_leaf = locals[:is_leaf]
|
|
7
9
|
%>
|
|
8
10
|
|
|
11
|
+
<%
|
|
12
|
+
# Hide leading attached-image data URIs (``).
|
|
13
|
+
# The base64 blob isn't useful in a 30-char preview — replace each with a
|
|
14
|
+
# short marker so the rest of the prompt text is visible.
|
|
15
|
+
display_prompt = ann.prompt.to_s.gsub(/!\[[^\]]*\]\(data:[^)]+\)/m, "[image]").strip
|
|
16
|
+
%>
|
|
9
17
|
<div class="history-card<%= ' is-active' if is_active %>" data-history-target="cards" data-uuid="<%= ann.execution_id %>" data-parent-uuid="<%= parent_uuid %>">
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
<div class="history-card-row">
|
|
19
|
+
<%= link_to card_path.call(ann.execution_id), class: "history-card-link" do %>
|
|
20
|
+
<div class="history-card-prompt"><%= truncate(display_prompt, length: 30) %></div>
|
|
21
|
+
<% end %>
|
|
22
|
+
<% if is_leaf && delete_path %>
|
|
23
|
+
<%= button_to delete_path.call(ann.execution_id),
|
|
24
|
+
method: :delete,
|
|
25
|
+
class: "history-card-delete",
|
|
26
|
+
title: "Delete this prompt",
|
|
27
|
+
form: { class: "history-card-delete-form" },
|
|
28
|
+
data: { turbo_confirm: "Delete this prompt? This cannot be undone." } do %>
|
|
29
|
+
<i class="bi bi-trash"></i>
|
|
30
|
+
<% end %>
|
|
31
|
+
<% end %>
|
|
12
32
|
<% if ann.llm_platform.present? %>
|
|
13
|
-
|
|
33
|
+
<% platform_label = { "openai" => "GPT", "anthropic" => "A", "google" => "G", "ollama" => "O" }[ann.llm_platform] || ann.llm_platform %>
|
|
34
|
+
<% tooltip = ann.model.present? ? "#{ann.model} (#{ann.llm_platform})" : ann.llm_platform.to_s %>
|
|
35
|
+
<span class="history-card-platform-label" data-platform="<%= ann.llm_platform %>" title="<%= tooltip %>"><%= platform_label %></span>
|
|
14
36
|
<% end %>
|
|
15
|
-
|
|
37
|
+
</div>
|
|
16
38
|
</div>
|
|
17
39
|
|
|
18
40
|
<%# Check !next_ann.nil? to prevent the "↑" arrow from appearing below the bottom history entry, as parent_uuid would be nil in that case. %>
|
|
19
41
|
<% if !next_ann.nil? && parent_uuid == next_ann.execution_id %>
|
|
20
42
|
<div class="history-straight-arrow">↑</div>
|
|
21
|
-
<% end %>
|
|
43
|
+
<% end %>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
module PromptNavigator
|
|
2
2
|
module Helpers
|
|
3
|
-
def history_list(card_path, active_uuid: nil)
|
|
4
|
-
render "prompt_navigator/history", locals: {
|
|
3
|
+
def history_list(card_path, active_uuid: nil, delete_path: nil)
|
|
4
|
+
render "prompt_navigator/history", locals: {
|
|
5
|
+
card_path: card_path,
|
|
6
|
+
active_uuid: active_uuid,
|
|
7
|
+
delete_path: delete_path
|
|
8
|
+
}
|
|
5
9
|
end
|
|
6
10
|
end
|
|
7
11
|
end
|