Skip to content

Commit dc56774

Browse files
authored
Merge pull request #102 from iceljc/features/refine-chat-window
Features/refine chat window
2 parents c38890e + d88cac9 commit dc56774

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

src/lib/helpers/http.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,12 @@ export function replaceNewLine(text) {
9595
* @returns string
9696
*/
9797
export function replaceMarkdown(text) {
98-
return text.replace(/#([\s]*)/g, '\\# ').replace(/\*([\s]*)/g, '\\* ');
98+
let res = text.replace(/#([\s]+)/g, '\\# ');
99+
100+
let regex = new RegExp('\\*(.*?)\\*', 'g');
101+
if (!regex.test(text)) {
102+
res = res.replace(/\*([\s]*)/g, '\\* ');
103+
}
104+
105+
return res;
99106
}

src/lib/helpers/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ IRichContent.prototype.text;
303303
* @property {string} conversation_id - The conversation id.
304304
* @property {string} message_id - The message id.
305305
* @property {string} before_value - The value before change.
306+
* @property {number?} before_active_rounds - The state active rounds before change.
306307
* @property {string} after_value - The value after change.
308+
* @property {number?} after_active_rounds - The state active rounds after change.
307309
* @property {Date} created_at - The log sent time.
308310
*/
309311

src/lib/scss/custom/pages/_chat.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@
435435

436436
.state-change-container {
437437
margin-top: 0px;
438-
margin-bottom: 0px;
438+
margin-bottom: 5px;
439439

440440
.state-key {
441441
color: var(--bs-primary);
@@ -448,8 +448,10 @@
448448
.state-value {
449449
min-width: 50%;
450450
font-size: 15px;
451-
margin-top: 3px;
452-
margin-bottom: 3px;
451+
452+
.active-rounds {
453+
font-size: 12px;
454+
}
453455
}
454456
}
455457
}

src/routes/chat/[agentId]/[conversationId]/stateLogs/state-change-element.svelte

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@
22
33
/** @type {any} */
44
export let data;
5+
6+
/** @type {string} */
7+
let beforeActiveRoundText = '';
8+
let afterActiveRoundText = '';
9+
10+
$: {
11+
beforeActiveRoundText = buildActiveRoundText(data?.before_value, data?.before_active_rounds);
12+
afterActiveRoundText = buildActiveRoundText(data?.after_value, data?.after_active_rounds);
13+
}
14+
15+
/**
16+
* @param {any} value
17+
* @param {any} activeRounds
18+
*/
19+
function buildActiveRoundText(value, activeRounds) {
20+
let text = '';
21+
22+
if (!!!value) {
23+
return text;
24+
}
25+
26+
if (activeRounds > 1) {
27+
text = `(active rounds: ${activeRounds})`;
28+
} else if (activeRounds == 1) {
29+
text = `(active round: ${activeRounds})`;
30+
} else {
31+
text = `(active rounds: infinity)`;
32+
}
33+
34+
return text;
35+
}
536
</script>
637
738
<div class="log-element state-change-container">
@@ -10,10 +41,20 @@
1041
</div>
1142
<div class="log-content state-value-container">
1243
<div class="state-value">
13-
<div>{`${data?.before_value || 'unknown'}`}</div>
44+
<div class="value">
45+
{`${data?.before_value || 'unknown'}`}
46+
</div>
47+
<div class="active-rounds">
48+
{`${beforeActiveRoundText}`}
49+
</div>
1450
</div>
1551
<div class="state-value text-warning">
16-
<div>{`${data?.after_value || 'unknown'}`}</div>
52+
<div class="value">
53+
{`${data?.after_value || 'unknown'}`}
54+
</div>
55+
<div class="active-rounds">
56+
{`${afterActiveRoundText}`}
57+
</div>
1758
</div>
1859
</div>
1960
</div>

0 commit comments

Comments
 (0)