prompt_navigator 2.2.0 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f448c834c18a600ebf636fad362e51f7dd80c354484e1971388a884cdd9ffb80
4
- data.tar.gz: d9a983063d1afe013001e7017b64ecc49f60467ea6e24a4179c20f37698d7eb4
3
+ metadata.gz: 04d9f220508c190b8c3b728e41ec2accc79d5b6812db89c6cbf9f55dca42763c
4
+ data.tar.gz: d1fca1e05f83c779d656e7d4e1e9671220f65ad12462553164bb72e3ebe656fc
5
5
  SHA512:
6
- metadata.gz: 7e3e53891c90ffa1fe59767eeb2de6f10b215eef872c4ca815384329b61e315aca9de871ed6f91761c22ef3c252d00415d6741b9158cf46b1ff51284b0c5db46
7
- data.tar.gz: 35998b74c979da62e030e6bec1609bc35aea630fb205ffed49718f39a3b594879bb0d5c30340b0c9f5b6e38d8fc211b18c7f273d3d788f84a5e64843b09be3ba
6
+ metadata.gz: 38f374671929eec32bd9d30758803fa557ac9be9f50b6ec3cc54a1e258548f27c362dfafaa9e7a7473b2f27bdf8b93990422a7b32126ef9dacd9c1fda6159a58
7
+ data.tar.gz: 434dc4c667d5737e083b1ea4773660abf576bbe6ea1695ea6bd98f5168fc2a457010907f4669aa07c0cb9688dbd950aed73908143911e9825034e10ea64bc576
@@ -18,10 +18,22 @@ export default class extends Controller {
18
18
 
19
19
  connect() {
20
20
  this.#drawArrows()
21
+ this.#scrollActiveCardIntoView()
21
22
  this.#drawArrowsBound = this.#drawArrows.bind(this)
22
23
  window.addEventListener("resize", this.#drawArrowsBound)
23
24
  }
24
25
 
26
+ // If the currently-selected history card would be scrolled off-screen
27
+ // (short viewport, long history), bring it into view. `block: "nearest"`
28
+ // is a no-op when the card is already visible, so this only jumps when
29
+ // needed. Runs on `connect()`, which fires on initial mount AND after
30
+ // Turbo replaces the sidebar (post-stream / branch / rename).
31
+ #scrollActiveCardIntoView() {
32
+ const activeCard = this.element.querySelector(".history-card.is-active")
33
+ if (!activeCard) return
34
+ activeCard.scrollIntoView({ block: "nearest", inline: "nearest" })
35
+ }
36
+
25
37
  disconnect() {
26
38
  window.removeEventListener("resize", this.#drawArrowsBound)
27
39
  }
@@ -7,10 +7,14 @@
7
7
  delete_path = locals[:delete_path]
8
8
  is_leaf = locals[:is_leaf]
9
9
 
10
- # Hide leading attached-image data URIs (`![](data:image/png;base64,…)`).
11
- # The base64 blob isn't useful in a 30-char preview replace each with a
12
- # short marker so the rest of the prompt text is visible.
13
- display_prompt = ann.prompt.to_s.gsub(/!\[[^\]]*\]\(data:[^)]+\)/m, "[image]").strip
10
+ # Hide attached-file data URIs so the base64 blob doesn't dominate the
11
+ # 30-char preview. Images use `![alt](data:…)` and get replaced with `[image]`;
12
+ # documents use `[filename](data:…)` and get replaced with `[filename]`
13
+ # (or `[document]` if the filename slot is empty).
14
+ display_prompt = ann.prompt.to_s
15
+ .gsub(/!\[[^\]]*\]\(data:[^)]+\)/m, "[image]")
16
+ .gsub(/(?<!!)\[([^\]]*)\]\(data:[^)]+\)/m) { "[#{Regexp.last_match(1).presence || 'document'}]" }
17
+ .strip
14
18
  %>
15
19
 
16
20
  <div class="history-card<%= ' is-active' if is_active %>" data-history-target="cards" data-uuid="<%= ann.execution_id %>" data-parent-uuid="<%= parent_uuid %>">
@@ -1,3 +1,3 @@
1
1
  module PromptNavigator
2
- VERSION = "2.2.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompt_navigator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler