Move reroll button

de4246f7b79ee74665f85ca9e626553b18b88b58

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +8 -14Showing whitespace changes
public/css/logprobs.css+0 -6
@@ -80,12 +80,6 @@
8080 background-color: rgba(255, 0, 50, 0.4);
8181}
8282
83-#logprobsReroll {
84- float: right; /* Position the button to the right */
85- margin: 5px 0 5px 10px; /* Add spacing (top, right, bottom, left) */
86- clear: right; /* Ensure it starts on a new line */
87-}
88-
8983.logprobs_candidate_list {
9084 grid-row-start: 3;
9185 grid-row-end: 4;
public/index.html+4 -1
@@ -6631,8 +6631,11 @@
66316631 </div>
66326632 </div>
66336633 <div class="logprobs_panel_content inline-drawer-content flex-container flexFlowColumn">
6634- <small>
6634+ <small class="flex-container alignItemsCenter justifySpaceBetween">
66356635 <b data-i18n="Select a token to see alternatives considered by the AI.">Select a token to see alternatives considered by the AI.</b>
6636+ <button id="logprobsReroll" class="menu_button" title="Reroll with the entire prefix" data-i18n="[title]Reroll with the entire prefix">
6637+ <span class="fa-solid fa-redo logprobs_reroll"></span>
6638+ </button>
66366639 </small>
66376640 <hr>
66386641 <div id="logprobs_generation_output"></div>
public/scripts/logprobs.js+4 -7
@@ -17,6 +17,7 @@ import { t } from './i18n.js';
1717
1818const TINTS = 4;
1919const MAX_MESSAGE_LOGPROBS = 100;
20+const REROLL_BUTTON = $('#logprobsReroll');
2021
2122/**
2223 * Tuple of a candidate token and its logarithm of probability of being chosen
@@ -93,14 +94,10 @@ function renderAlternativeTokensView() {
9394
9495 const prefix = continueFrom || '';
9596 const tokenSpans = [];
97+ REROLL_BUTTON.toggle(!!prefix);
9698
9799 if (prefix) {
98- const rerollButton = $('<button id="logprobsReroll" class="menu_button">' +
100+ REROLL_BUTTON.off('click').on('click', () => onPrefixClicked(prefix.length));
99- ' <span class="fa-solid fa-redo logprobs_reroll"></span>' +
100- '</button>');
101- rerollButton.attr('title', t`Reroll with the entire prefix`);
102- rerollButton.on('click', () => onPrefixClicked(prefix.length));
103- tokenSpans.push(rerollButton);
104101
105102 let cumulativeOffset = 0;
106103 const words = prefix.split(/\s+/);
@@ -127,7 +124,6 @@ function renderAlternativeTokensView() {
127124 });
128125 }
129126
130-
131127 messageLogprobs.forEach((tokenData, i) => {
132128 const { token } = tokenData;
133129 const span = $('<span></span>');
@@ -539,6 +535,7 @@ function convertTokenIdLogprobsToText(input) {
539535}
540536
541537export function initLogprobs() {
538+ REROLL_BUTTON.hide();
542539 const debouncedRender = debounce(renderAlternativeTokensView);
543540 $('#logprobsViewerClose').on('click', onToggleLogprobsPanel);
544541 $('#option_toggle_logprobs').on('click', onToggleLogprobsPanel);