leva 0.1.8 → 0.1.9

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: 9d8e48a71a34a53451bc1756a6cdc7694ee6ea9747861fdb977b0859979bd101
4
- data.tar.gz: 83c44769f588b3daeeaa6bd750f9e9b643639871de57dd381cd84a76cd6177d6
3
+ metadata.gz: e16081b74e57cb4f198b075e76bc5fc1c07f67e4a14c4d38e27f8df53e26f3cf
4
+ data.tar.gz: db9725fdc26fe3542ba8a1b1aaf2f22c2471e112c841224ce3587d1b6e83269c
5
5
  SHA512:
6
- metadata.gz: 74ad608263e8fe369693537d76247757bd39417bbf1e034ffc2402684a9800ed25803d1ff3506d05776c9c523ad7fd84254e78290fc99f21f7180f67e1e12667
7
- data.tar.gz: 3a2e4b9701d6cb63c05c2f672b44c8bfd16f0de5a6a98c63e4b6a13de6685efe001cf320304be1fa1aa6c6b56cec658ec0fb95e731fbf078055d5deaffb10959
6
+ metadata.gz: e1019c0ec416f40854b5b9ef7c4e38df0141c98c5684f01ed26ea145deba92151a0ed908936768819eb1ab11167f2e5b9e075389ef8e8b25fb84786c1571f64d
7
+ data.tar.gz: 9de9c5e4ee512a66c8b6a72f5b5d8d7b6b316ddf4be13652df640433a40bf6a06b207cce38ef4bc8631619880d9587f3318a77a8722cee394e617c8fc2995039
data/README.md CHANGED
@@ -196,4 +196,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
196
196
 
197
197
  ## Roadmap
198
198
 
199
- - [ ] Parallelize evaluation
199
+ - [x] Parallelize evaluation
@@ -8,6 +8,7 @@
8
8
  <%= csp_meta_tag %>
9
9
  <script src="https://cdn.tailwindcss.com"></script>
10
10
  <script src="https://cdn.jsdelivr.net/npm/stimulus@3.2.2/dist/stimulus.umd.min.js"></script>
11
+ <script src="<%= asset_path 'custom/prompt_preview.js' %>"></script>
11
12
  <%= yield(:head) %>
12
13
  </head>
13
14
  <body class="bg-gray-950 text-white">
@@ -38,4 +39,4 @@
38
39
  <%= yield %>
39
40
  </main>
40
41
  </body>
41
- </html>
42
+ </html>
@@ -33,9 +33,30 @@
33
33
  <%= form.label :user_prompt, class: "block text-sm font-semibold mb-2 text-indigo-300" %>
34
34
  <%= form.text_area :user_prompt, rows: 5, class: "w-full bg-gray-700 text-white p-3 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:outline-none" %>
35
35
  </div>
36
- <div class="mb-4 hidden" data-prompt-selector-target="promptPreview">
36
+ <div class="mb-4 hidden" data-prompt-selector-target="promptPreview" id="prompt-preview">
37
37
  <h3 class="text-lg font-semibold mb-2 text-indigo-300">Prompt Preview</h3>
38
- <div class="bg-gray-700 text-white p-3 rounded-lg" data-prompt-selector-target="previewContent"></div>
38
+ <div
39
+ class="bg-gray-700 text-white p-3 rounded-lg whitespace-pre-wrap"
40
+ data-prompt-selector-target="previewContent"
41
+ id="preview-content"
42
+ ></div>
43
+
44
+ <!-- show-full button, hidden until overflow is detected -->
45
+ <button
46
+ id="show-full-preview"
47
+ type="button"
48
+ class="mt-2 text-indigo-400 underline hidden"
49
+ >Show full</button>
50
+
51
+ <!-- HTML5 dialog for full text -->
52
+ <dialog id="full-preview-dialog" class="p-0 m-0">
53
+ <div class="bg-gray-800 text-white p-4 rounded-lg max-h-[80vh] overflow-auto whitespace-pre-wrap">
54
+ <div id="dialog-content"></div>
55
+ <div class="text-right mt-4">
56
+ <button id="close-full-preview" class="px-4 py-2 bg-indigo-600 rounded text-white">Close</button>
57
+ </div>
58
+ </div>
59
+ </dialog>
39
60
  </div>
40
61
  <div class="flex items-center justify-end space-x-4">
41
62
  <%= link_to "Cancel", workbench_index_path, class: "px-3 py-2 rounded-md text-sm font-medium text-gray-300 hover:bg-gray-800 hover:text-white transition-colors duration-150 ease-in-out" %>
@@ -76,6 +97,56 @@
76
97
  }
77
98
  })
78
99
  })()
100
+
101
+ // Prompt preview scrollbar and dialog functionality
102
+ document.addEventListener('DOMContentLoaded', () => {
103
+ const wrapper = document.getElementById('prompt-preview');
104
+ const preview = document.getElementById('preview-content');
105
+ const showBtn = document.getElementById('show-full-preview');
106
+ const dialog = document.getElementById('full-preview-dialog');
107
+ const dialogBody = document.getElementById('dialog-content');
108
+ const closeBtn = document.getElementById('close-full-preview');
109
+
110
+ if (!preview) return;
111
+
112
+ // Check if the preview content is already populated by Stimulus
113
+ const checkPreviewContent = () => {
114
+ if (preview.textContent.trim().length > 0) {
115
+ // Detect overflow
116
+ if (preview.scrollHeight > preview.clientHeight || preview.scrollWidth > preview.clientWidth) {
117
+ preview.style.maxHeight = '12em';
118
+ preview.style.overflow = 'auto';
119
+ showBtn.classList.remove('hidden');
120
+ }
121
+ } else {
122
+ // If not populated yet, check again after a short delay
123
+ setTimeout(checkPreviewContent, 100);
124
+ }
125
+ };
126
+
127
+ // Start checking once the wrapper is visible
128
+ const observer = new MutationObserver((mutations) => {
129
+ mutations.forEach((mutation) => {
130
+ if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
131
+ if (!wrapper.classList.contains('hidden')) {
132
+ checkPreviewContent();
133
+ observer.disconnect(); // Stop observing once we've detected the change
134
+ }
135
+ }
136
+ });
137
+ });
138
+
139
+ observer.observe(wrapper, { attributes: true });
140
+
141
+ // Show full in dialog
142
+ showBtn.addEventListener('click', () => {
143
+ dialogBody.textContent = preview.textContent;
144
+ dialog.showModal();
145
+ });
146
+
147
+ // Close dialog
148
+ closeBtn.addEventListener('click', () => dialog.close());
149
+ });
79
150
  </script>
80
151
  <!-- Include marked.js for Markdown parsing -->
81
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
152
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
data/lib/leva/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Leva
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leva
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kieran Klaassen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-13 00:00:00.000000000 Z
11
+ date: 2025-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails