Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lib/helpers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,12 @@ export function replaceNewLine(text) {
* @returns string
*/
export function replaceMarkdown(text) {
return text.replace(/#([\s]*)/g, '\\# ').replace(/\*([\s]*)/g, '\\* ');
let res = text.replace(/#([\s]+)/g, '\\# ');

let regex = new RegExp('\\*(.*?)\\*', 'g');
if (!regex.test(text)) {
res = res.replace(/\*([\s]*)/g, '\\* ');
}

return res;
}
2 changes: 2 additions & 0 deletions src/lib/helpers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ IRichContent.prototype.text;
* @property {string} conversation_id - The conversation id.
* @property {string} message_id - The message id.
* @property {string} before_value - The value before change.
* @property {number?} before_active_rounds - The state active rounds before change.
* @property {string} after_value - The value after change.
* @property {number?} after_active_rounds - The state active rounds after change.
* @property {Date} created_at - The log sent time.
*/

Expand Down
8 changes: 5 additions & 3 deletions src/lib/scss/custom/pages/_chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@

.state-change-container {
margin-top: 0px;
margin-bottom: 0px;
margin-bottom: 5px;

.state-key {
color: var(--bs-primary);
Expand All @@ -448,8 +448,10 @@
.state-value {
min-width: 50%;
font-size: 15px;
margin-top: 3px;
margin-bottom: 3px;

.active-rounds {
font-size: 12px;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@

/** @type {any} */
export let data;

/** @type {string} */
let beforeActiveRoundText = '';
let afterActiveRoundText = '';

$: {
beforeActiveRoundText = buildActiveRoundText(data?.before_value, data?.before_active_rounds);
afterActiveRoundText = buildActiveRoundText(data?.after_value, data?.after_active_rounds);
}

/**
* @param {any} value
* @param {any} activeRounds
*/
function buildActiveRoundText(value, activeRounds) {
let text = '';

if (!!!value) {
return text;
}

if (activeRounds > 1) {
text = `(active rounds: ${activeRounds})`;
} else if (activeRounds == 1) {
text = `(active round: ${activeRounds})`;
} else {
text = `(active rounds: infinity)`;
}

return text;
}
</script>

<div class="log-element state-change-container">
Expand All @@ -10,10 +41,20 @@
</div>
<div class="log-content state-value-container">
<div class="state-value">
<div>{`${data?.before_value || 'unknown'}`}</div>
<div class="value">
{`${data?.before_value || 'unknown'}`}
</div>
<div class="active-rounds">
{`${beforeActiveRoundText}`}
</div>
</div>
<div class="state-value text-warning">
<div>{`${data?.after_value || 'unknown'}`}</div>
<div class="value">
{`${data?.after_value || 'unknown'}`}
</div>
<div class="active-rounds">
{`${afterActiveRoundText}`}
</div>
</div>
</div>
</div>