agentgui 1.0.259 → 1.0.261
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.
- package/package.json +1 -1
- package/static/index.html +170 -16
- package/static/js/client.js +2 -1
- package/static/js/streaming-renderer.js +13 -0
- package/static/js/voice.js +12 -3
package/package.json
CHANGED
package/static/index.html
CHANGED
|
@@ -1854,22 +1854,176 @@
|
|
|
1854
1854
|
.block-type-text { background: #f8fafc; }
|
|
1855
1855
|
html.dark .block-type-text { background: #1e293b; }
|
|
1856
1856
|
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
.
|
|
1860
|
-
|
|
1861
|
-
.
|
|
1862
|
-
|
|
1863
|
-
.
|
|
1864
|
-
|
|
1865
|
-
.
|
|
1866
|
-
|
|
1867
|
-
.
|
|
1868
|
-
|
|
1869
|
-
.
|
|
1870
|
-
|
|
1871
|
-
.
|
|
1872
|
-
|
|
1857
|
+
/* --- Per-tool-name header colors (tool-color-*) --- */
|
|
1858
|
+
.tool-color-read.folded-tool > .folded-tool-bar { background: #dbeafe; }
|
|
1859
|
+
html.dark .tool-color-read.folded-tool > .folded-tool-bar { background: #1e3a5f; }
|
|
1860
|
+
.tool-color-read.folded-tool > .folded-tool-bar:hover { background: #bfdbfe; }
|
|
1861
|
+
html.dark .tool-color-read.folded-tool > .folded-tool-bar:hover { background: #1e40af; }
|
|
1862
|
+
.tool-color-read.folded-tool > .folded-tool-bar::before { color: #2563eb; }
|
|
1863
|
+
html.dark .tool-color-read.folded-tool > .folded-tool-bar::before { color: #60a5fa; }
|
|
1864
|
+
.tool-color-read .folded-tool-icon { color: #2563eb; }
|
|
1865
|
+
html.dark .tool-color-read .folded-tool-icon { color: #60a5fa; }
|
|
1866
|
+
.tool-color-read .folded-tool-name { color: #1e40af; }
|
|
1867
|
+
html.dark .tool-color-read .folded-tool-name { color: #93bbfd; }
|
|
1868
|
+
.tool-color-read .folded-tool-desc { color: #1d4ed8; }
|
|
1869
|
+
html.dark .tool-color-read .folded-tool-desc { color: #60a5fa; }
|
|
1870
|
+
.tool-color-read { background: #eff6ff; }
|
|
1871
|
+
html.dark .tool-color-read { background: #0c1929; }
|
|
1872
|
+
.tool-color-read > .folded-tool-body { border-top-color: #bfdbfe; }
|
|
1873
|
+
html.dark .tool-color-read > .folded-tool-body { border-top-color: #1e3a5f; }
|
|
1874
|
+
|
|
1875
|
+
.tool-color-write.folded-tool > .folded-tool-bar { background: #fef3c7; }
|
|
1876
|
+
html.dark .tool-color-write.folded-tool > .folded-tool-bar { background: #422006; }
|
|
1877
|
+
.tool-color-write.folded-tool > .folded-tool-bar:hover { background: #fde68a; }
|
|
1878
|
+
html.dark .tool-color-write.folded-tool > .folded-tool-bar:hover { background: #78350f; }
|
|
1879
|
+
.tool-color-write.folded-tool > .folded-tool-bar::before { color: #d97706; }
|
|
1880
|
+
html.dark .tool-color-write.folded-tool > .folded-tool-bar::before { color: #fbbf24; }
|
|
1881
|
+
.tool-color-write .folded-tool-icon { color: #d97706; }
|
|
1882
|
+
html.dark .tool-color-write .folded-tool-icon { color: #fbbf24; }
|
|
1883
|
+
.tool-color-write .folded-tool-name { color: #92400e; }
|
|
1884
|
+
html.dark .tool-color-write .folded-tool-name { color: #fcd34d; }
|
|
1885
|
+
.tool-color-write .folded-tool-desc { color: #b45309; }
|
|
1886
|
+
html.dark .tool-color-write .folded-tool-desc { color: #fbbf24; }
|
|
1887
|
+
.tool-color-write { background: #fffbeb; }
|
|
1888
|
+
html.dark .tool-color-write { background: #1c1507; }
|
|
1889
|
+
.tool-color-write > .folded-tool-body { border-top-color: #fde68a; }
|
|
1890
|
+
html.dark .tool-color-write > .folded-tool-body { border-top-color: #422006; }
|
|
1891
|
+
|
|
1892
|
+
.tool-color-edit.folded-tool > .folded-tool-bar { background: #ede9fe; }
|
|
1893
|
+
html.dark .tool-color-edit.folded-tool > .folded-tool-bar { background: #2e1065; }
|
|
1894
|
+
.tool-color-edit.folded-tool > .folded-tool-bar:hover { background: #ddd6fe; }
|
|
1895
|
+
html.dark .tool-color-edit.folded-tool > .folded-tool-bar:hover { background: #4c1d95; }
|
|
1896
|
+
.tool-color-edit.folded-tool > .folded-tool-bar::before { color: #7c3aed; }
|
|
1897
|
+
html.dark .tool-color-edit.folded-tool > .folded-tool-bar::before { color: #a78bfa; }
|
|
1898
|
+
.tool-color-edit .folded-tool-icon { color: #7c3aed; }
|
|
1899
|
+
html.dark .tool-color-edit .folded-tool-icon { color: #a78bfa; }
|
|
1900
|
+
.tool-color-edit .folded-tool-name { color: #5b21b6; }
|
|
1901
|
+
html.dark .tool-color-edit .folded-tool-name { color: #c4b5fd; }
|
|
1902
|
+
.tool-color-edit .folded-tool-desc { color: #6d28d9; }
|
|
1903
|
+
html.dark .tool-color-edit .folded-tool-desc { color: #a78bfa; }
|
|
1904
|
+
.tool-color-edit { background: #f5f3ff; }
|
|
1905
|
+
html.dark .tool-color-edit { background: #1a0a2e; }
|
|
1906
|
+
.tool-color-edit > .folded-tool-body { border-top-color: #ddd6fe; }
|
|
1907
|
+
html.dark .tool-color-edit > .folded-tool-body { border-top-color: #2e1065; }
|
|
1908
|
+
|
|
1909
|
+
.tool-color-bash.folded-tool > .folded-tool-bar { background: #e2e8f0; }
|
|
1910
|
+
html.dark .tool-color-bash.folded-tool > .folded-tool-bar { background: #1e293b; }
|
|
1911
|
+
.tool-color-bash.folded-tool > .folded-tool-bar:hover { background: #cbd5e1; }
|
|
1912
|
+
html.dark .tool-color-bash.folded-tool > .folded-tool-bar:hover { background: #334155; }
|
|
1913
|
+
.tool-color-bash.folded-tool > .folded-tool-bar::before { color: #475569; }
|
|
1914
|
+
html.dark .tool-color-bash.folded-tool > .folded-tool-bar::before { color: #94a3b8; }
|
|
1915
|
+
.tool-color-bash .folded-tool-icon { color: #475569; }
|
|
1916
|
+
html.dark .tool-color-bash .folded-tool-icon { color: #94a3b8; }
|
|
1917
|
+
.tool-color-bash .folded-tool-name { color: #334155; }
|
|
1918
|
+
html.dark .tool-color-bash .folded-tool-name { color: #cbd5e1; }
|
|
1919
|
+
.tool-color-bash .folded-tool-desc { color: #475569; }
|
|
1920
|
+
html.dark .tool-color-bash .folded-tool-desc { color: #94a3b8; }
|
|
1921
|
+
.tool-color-bash { background: #f8fafc; }
|
|
1922
|
+
html.dark .tool-color-bash { background: #0f172a; }
|
|
1923
|
+
.tool-color-bash > .folded-tool-body { border-top-color: #cbd5e1; }
|
|
1924
|
+
html.dark .tool-color-bash > .folded-tool-body { border-top-color: #334155; }
|
|
1925
|
+
|
|
1926
|
+
.tool-color-glob.folded-tool > .folded-tool-bar { background: #d1fae5; }
|
|
1927
|
+
html.dark .tool-color-glob.folded-tool > .folded-tool-bar { background: #064e3b; }
|
|
1928
|
+
.tool-color-glob.folded-tool > .folded-tool-bar:hover { background: #a7f3d0; }
|
|
1929
|
+
html.dark .tool-color-glob.folded-tool > .folded-tool-bar:hover { background: #065f46; }
|
|
1930
|
+
.tool-color-glob.folded-tool > .folded-tool-bar::before { color: #059669; }
|
|
1931
|
+
html.dark .tool-color-glob.folded-tool > .folded-tool-bar::before { color: #34d399; }
|
|
1932
|
+
.tool-color-glob .folded-tool-icon { color: #059669; }
|
|
1933
|
+
html.dark .tool-color-glob .folded-tool-icon { color: #34d399; }
|
|
1934
|
+
.tool-color-glob .folded-tool-name { color: #065f46; }
|
|
1935
|
+
html.dark .tool-color-glob .folded-tool-name { color: #6ee7b7; }
|
|
1936
|
+
.tool-color-glob .folded-tool-desc { color: #047857; }
|
|
1937
|
+
html.dark .tool-color-glob .folded-tool-desc { color: #34d399; }
|
|
1938
|
+
.tool-color-glob { background: #ecfdf5; }
|
|
1939
|
+
html.dark .tool-color-glob { background: #022c22; }
|
|
1940
|
+
.tool-color-glob > .folded-tool-body { border-top-color: #a7f3d0; }
|
|
1941
|
+
html.dark .tool-color-glob > .folded-tool-body { border-top-color: #064e3b; }
|
|
1942
|
+
|
|
1943
|
+
.tool-color-grep.folded-tool > .folded-tool-bar { background: #ffe4e6; }
|
|
1944
|
+
html.dark .tool-color-grep.folded-tool > .folded-tool-bar { background: #4c0519; }
|
|
1945
|
+
.tool-color-grep.folded-tool > .folded-tool-bar:hover { background: #fecdd3; }
|
|
1946
|
+
html.dark .tool-color-grep.folded-tool > .folded-tool-bar:hover { background: #881337; }
|
|
1947
|
+
.tool-color-grep.folded-tool > .folded-tool-bar::before { color: #e11d48; }
|
|
1948
|
+
html.dark .tool-color-grep.folded-tool > .folded-tool-bar::before { color: #fb7185; }
|
|
1949
|
+
.tool-color-grep .folded-tool-icon { color: #e11d48; }
|
|
1950
|
+
html.dark .tool-color-grep .folded-tool-icon { color: #fb7185; }
|
|
1951
|
+
.tool-color-grep .folded-tool-name { color: #9f1239; }
|
|
1952
|
+
html.dark .tool-color-grep .folded-tool-name { color: #fda4af; }
|
|
1953
|
+
.tool-color-grep .folded-tool-desc { color: #be123c; }
|
|
1954
|
+
html.dark .tool-color-grep .folded-tool-desc { color: #fb7185; }
|
|
1955
|
+
.tool-color-grep { background: #fff1f2; }
|
|
1956
|
+
html.dark .tool-color-grep { background: #2a0a10; }
|
|
1957
|
+
.tool-color-grep > .folded-tool-body { border-top-color: #fecdd3; }
|
|
1958
|
+
html.dark .tool-color-grep > .folded-tool-body { border-top-color: #4c0519; }
|
|
1959
|
+
|
|
1960
|
+
.tool-color-web.folded-tool > .folded-tool-bar { background: #e0f2fe; }
|
|
1961
|
+
html.dark .tool-color-web.folded-tool > .folded-tool-bar { background: #0c4a6e; }
|
|
1962
|
+
.tool-color-web.folded-tool > .folded-tool-bar:hover { background: #bae6fd; }
|
|
1963
|
+
html.dark .tool-color-web.folded-tool > .folded-tool-bar:hover { background: #075985; }
|
|
1964
|
+
.tool-color-web.folded-tool > .folded-tool-bar::before { color: #0284c7; }
|
|
1965
|
+
html.dark .tool-color-web.folded-tool > .folded-tool-bar::before { color: #38bdf8; }
|
|
1966
|
+
.tool-color-web .folded-tool-icon { color: #0284c7; }
|
|
1967
|
+
html.dark .tool-color-web .folded-tool-icon { color: #38bdf8; }
|
|
1968
|
+
.tool-color-web .folded-tool-name { color: #075985; }
|
|
1969
|
+
html.dark .tool-color-web .folded-tool-name { color: #7dd3fc; }
|
|
1970
|
+
.tool-color-web .folded-tool-desc { color: #0369a1; }
|
|
1971
|
+
html.dark .tool-color-web .folded-tool-desc { color: #38bdf8; }
|
|
1972
|
+
.tool-color-web { background: #f0f9ff; }
|
|
1973
|
+
html.dark .tool-color-web { background: #0a1929; }
|
|
1974
|
+
.tool-color-web > .folded-tool-body { border-top-color: #bae6fd; }
|
|
1975
|
+
html.dark .tool-color-web > .folded-tool-body { border-top-color: #0c4a6e; }
|
|
1976
|
+
|
|
1977
|
+
.tool-color-todo.folded-tool > .folded-tool-bar { background: #ffedd5; }
|
|
1978
|
+
html.dark .tool-color-todo.folded-tool > .folded-tool-bar { background: #431407; }
|
|
1979
|
+
.tool-color-todo.folded-tool > .folded-tool-bar:hover { background: #fed7aa; }
|
|
1980
|
+
html.dark .tool-color-todo.folded-tool > .folded-tool-bar:hover { background: #7c2d12; }
|
|
1981
|
+
.tool-color-todo.folded-tool > .folded-tool-bar::before { color: #ea580c; }
|
|
1982
|
+
html.dark .tool-color-todo.folded-tool > .folded-tool-bar::before { color: #fb923c; }
|
|
1983
|
+
.tool-color-todo .folded-tool-icon { color: #ea580c; }
|
|
1984
|
+
html.dark .tool-color-todo .folded-tool-icon { color: #fb923c; }
|
|
1985
|
+
.tool-color-todo .folded-tool-name { color: #9a3412; }
|
|
1986
|
+
html.dark .tool-color-todo .folded-tool-name { color: #fdba74; }
|
|
1987
|
+
.tool-color-todo .folded-tool-desc { color: #c2410c; }
|
|
1988
|
+
html.dark .tool-color-todo .folded-tool-desc { color: #fb923c; }
|
|
1989
|
+
.tool-color-todo { background: #fff7ed; }
|
|
1990
|
+
html.dark .tool-color-todo { background: #1c0f02; }
|
|
1991
|
+
.tool-color-todo > .folded-tool-body { border-top-color: #fed7aa; }
|
|
1992
|
+
html.dark .tool-color-todo > .folded-tool-body { border-top-color: #431407; }
|
|
1993
|
+
|
|
1994
|
+
.tool-color-task.folded-tool > .folded-tool-bar { background: #e0e7ff; }
|
|
1995
|
+
html.dark .tool-color-task.folded-tool > .folded-tool-bar { background: #1e1b4b; }
|
|
1996
|
+
.tool-color-task.folded-tool > .folded-tool-bar:hover { background: #c7d2fe; }
|
|
1997
|
+
html.dark .tool-color-task.folded-tool > .folded-tool-bar:hover { background: #312e81; }
|
|
1998
|
+
.tool-color-task.folded-tool > .folded-tool-bar::before { color: #4f46e5; }
|
|
1999
|
+
html.dark .tool-color-task.folded-tool > .folded-tool-bar::before { color: #818cf8; }
|
|
2000
|
+
.tool-color-task .folded-tool-icon { color: #4f46e5; }
|
|
2001
|
+
html.dark .tool-color-task .folded-tool-icon { color: #818cf8; }
|
|
2002
|
+
.tool-color-task .folded-tool-name { color: #3730a3; }
|
|
2003
|
+
html.dark .tool-color-task .folded-tool-name { color: #a5b4fc; }
|
|
2004
|
+
.tool-color-task .folded-tool-desc { color: #4338ca; }
|
|
2005
|
+
html.dark .tool-color-task .folded-tool-desc { color: #818cf8; }
|
|
2006
|
+
.tool-color-task { background: #eef2ff; }
|
|
2007
|
+
html.dark .tool-color-task { background: #0f0d29; }
|
|
2008
|
+
.tool-color-task > .folded-tool-body { border-top-color: #c7d2fe; }
|
|
2009
|
+
html.dark .tool-color-task > .folded-tool-body { border-top-color: #1e1b4b; }
|
|
2010
|
+
|
|
2011
|
+
.tool-color-default.folded-tool > .folded-tool-bar { background: #cffafe; }
|
|
2012
|
+
html.dark .tool-color-default.folded-tool > .folded-tool-bar { background: #0e2a3a; }
|
|
2013
|
+
.tool-color-default.folded-tool > .folded-tool-bar:hover { background: #a5f3fc; }
|
|
2014
|
+
html.dark .tool-color-default.folded-tool > .folded-tool-bar:hover { background: #164e63; }
|
|
2015
|
+
.tool-color-default.folded-tool > .folded-tool-bar::before { color: #0891b2; }
|
|
2016
|
+
html.dark .tool-color-default.folded-tool > .folded-tool-bar::before { color: #22d3ee; }
|
|
2017
|
+
.tool-color-default .folded-tool-icon { color: #0891b2; }
|
|
2018
|
+
html.dark .tool-color-default .folded-tool-icon { color: #22d3ee; }
|
|
2019
|
+
.tool-color-default .folded-tool-name { color: #155e75; }
|
|
2020
|
+
html.dark .tool-color-default .folded-tool-name { color: #67e8f9; }
|
|
2021
|
+
.tool-color-default .folded-tool-desc { color: #0e7490; }
|
|
2022
|
+
html.dark .tool-color-default .folded-tool-desc { color: #22d3ee; }
|
|
2023
|
+
.tool-color-default { background: #ecfeff; }
|
|
2024
|
+
html.dark .tool-color-default { background: #0c1a24; }
|
|
2025
|
+
.tool-color-default > .folded-tool-body { border-top-color: #a5f3fc; }
|
|
2026
|
+
html.dark .tool-color-default > .folded-tool-body { border-top-color: #164e63; }
|
|
1873
2027
|
|
|
1874
2028
|
.block-type-tool_result { background: #f0fdf4; }
|
|
1875
2029
|
html.dark .block-type-tool_result { background: #0a1f0f; }
|
package/static/js/client.js
CHANGED
|
@@ -1188,9 +1188,10 @@ class AgentGUIClient {
|
|
|
1188
1188
|
const tTitle = hasRenderer && block.input ? StreamingRenderer.getToolTitle(tn, block.input) : '';
|
|
1189
1189
|
const iconHtml = hasRenderer && this.renderer ? `<span class="folded-tool-icon">${this.renderer.getToolIcon(tn)}</span>` : '';
|
|
1190
1190
|
const typeClass = hasRenderer && this.renderer ? this.renderer._getBlockTypeClass('tool_use') : 'block-type-tool_use';
|
|
1191
|
+
const toolColorClass = hasRenderer && this.renderer ? this.renderer._getToolColorClass(tn) : 'tool-color-default';
|
|
1191
1192
|
const nextBlock = blocks[blockIdx + 1];
|
|
1192
1193
|
const resultClass = nextBlock?.type === 'tool_result' ? (nextBlock.is_error ? 'has-error' : 'has-success') : '';
|
|
1193
|
-
html += `<details class="block-tool-use folded-tool ${typeClass} ${resultClass}"><summary class="folded-tool-bar">${iconHtml}<span class="folded-tool-name">${this.escapeHtml(dName)}</span>${tTitle ? `<span class="folded-tool-desc">${this.escapeHtml(tTitle)}</span>` : ''}</summary>${inputHtml}`;
|
|
1194
|
+
html += `<details class="block-tool-use folded-tool ${typeClass} ${toolColorClass} ${resultClass}"><summary class="folded-tool-bar">${iconHtml}<span class="folded-tool-name">${this.escapeHtml(dName)}</span>${tTitle ? `<span class="folded-tool-desc">${this.escapeHtml(tTitle)}</span>` : ''}</summary>${inputHtml}`;
|
|
1194
1195
|
pendingToolUseClose = true;
|
|
1195
1196
|
} else if (block.type === 'tool_result') {
|
|
1196
1197
|
const content = typeof block.content === 'string' ? block.content : JSON.stringify(block.content);
|
|
@@ -422,6 +422,12 @@ class StreamingRenderer {
|
|
|
422
422
|
return validTypes.includes(blockType) ? `block-type-${blockType}` : 'block-type-generic';
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
_getToolColorClass(toolName) {
|
|
426
|
+
const n = (toolName || '').replace(/^mcp__[^_]+__/, '').toLowerCase();
|
|
427
|
+
const map = { read: 'read', write: 'write', edit: 'edit', bash: 'bash', glob: 'glob', grep: 'grep', webfetch: 'web', websearch: 'web', todowrite: 'todo', task: 'task', notebookedit: 'edit' };
|
|
428
|
+
return `tool-color-${map[n] || 'default'}`;
|
|
429
|
+
}
|
|
430
|
+
|
|
425
431
|
containsHtmlTags(text) {
|
|
426
432
|
const htmlPattern = /<(?:div|table|section|article|ul|ol|dl|nav|header|footer|main|aside|figure|details|summary|h[1-6]|p|blockquote|pre|code|span|strong|em|a|img|br|hr|li|td|tr|th|thead|tbody|tfoot)\b[^>]*>/i;
|
|
427
433
|
return htmlPattern.test(text);
|
|
@@ -737,6 +743,7 @@ class StreamingRenderer {
|
|
|
737
743
|
details.className = 'block-tool-use folded-tool';
|
|
738
744
|
if (block.id) details.dataset.toolUseId = block.id;
|
|
739
745
|
details.classList.add(this._getBlockTypeClass('tool_use'));
|
|
746
|
+
details.classList.add(this._getToolColorClass(toolName));
|
|
740
747
|
const summary = document.createElement('summary');
|
|
741
748
|
summary.className = 'folded-tool-bar';
|
|
742
749
|
const displayName = this.getToolUseDisplayName(toolName);
|
|
@@ -1625,6 +1632,8 @@ class StreamingRenderer {
|
|
|
1625
1632
|
const fileName = event.path ? event.path.split('/').pop() : 'unknown';
|
|
1626
1633
|
const details = document.createElement('details');
|
|
1627
1634
|
details.className = 'block-tool-use folded-tool';
|
|
1635
|
+
details.classList.add(this._getBlockTypeClass('tool_use'));
|
|
1636
|
+
details.classList.add(this._getToolColorClass('Read'));
|
|
1628
1637
|
details.dataset.eventId = event.id || '';
|
|
1629
1638
|
details.dataset.eventType = 'file_read';
|
|
1630
1639
|
const summary = document.createElement('summary');
|
|
@@ -1656,6 +1665,8 @@ class StreamingRenderer {
|
|
|
1656
1665
|
const fileName = event.path ? event.path.split('/').pop() : 'unknown';
|
|
1657
1666
|
const details = document.createElement('details');
|
|
1658
1667
|
details.className = 'block-tool-use folded-tool';
|
|
1668
|
+
details.classList.add(this._getBlockTypeClass('tool_use'));
|
|
1669
|
+
details.classList.add(this._getToolColorClass('Write'));
|
|
1659
1670
|
details.dataset.eventId = event.id || '';
|
|
1660
1671
|
details.dataset.eventType = 'file_write';
|
|
1661
1672
|
const summary = document.createElement('summary');
|
|
@@ -1719,6 +1730,8 @@ class StreamingRenderer {
|
|
|
1719
1730
|
|
|
1720
1731
|
const details = document.createElement('details');
|
|
1721
1732
|
details.className = 'block-tool-use folded-tool';
|
|
1733
|
+
details.classList.add(this._getBlockTypeClass('tool_use'));
|
|
1734
|
+
details.classList.add(this._getToolColorClass('Bash'));
|
|
1722
1735
|
details.dataset.eventId = event.id || '';
|
|
1723
1736
|
details.dataset.eventType = 'command_execute';
|
|
1724
1737
|
const summary = document.createElement('summary');
|
package/static/js/voice.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
var isLoadingHistory = false;
|
|
18
18
|
var _lastVoiceBlockText = null;
|
|
19
19
|
var _lastVoiceBlockTime = 0;
|
|
20
|
+
var _voiceBreakNext = false;
|
|
20
21
|
var selectedVoiceId = localStorage.getItem('voice-selected-id') || 'default';
|
|
21
22
|
var ttsAudioCache = new Map();
|
|
22
23
|
var TTS_CLIENT_CACHE_MAX = 50;
|
|
@@ -549,7 +550,7 @@
|
|
|
549
550
|
var emptyMsg = container.querySelector('.voice-empty');
|
|
550
551
|
if (emptyMsg) emptyMsg.remove();
|
|
551
552
|
var lastChild = container.lastElementChild;
|
|
552
|
-
if (!isUser && lastChild && lastChild.classList.contains('voice-block') && !lastChild.classList.contains('voice-block-user')) {
|
|
553
|
+
if (!isUser && !_voiceBreakNext && lastChild && lastChild.classList.contains('voice-block') && !lastChild.classList.contains('voice-block-user')) {
|
|
553
554
|
var contentSpan = lastChild.querySelector('.voice-block-content');
|
|
554
555
|
if (contentSpan) {
|
|
555
556
|
contentSpan.textContent += '\n' + stripHtml(text);
|
|
@@ -558,6 +559,7 @@
|
|
|
558
559
|
return lastChild;
|
|
559
560
|
}
|
|
560
561
|
}
|
|
562
|
+
_voiceBreakNext = false;
|
|
561
563
|
var div = document.createElement('div');
|
|
562
564
|
div.className = 'voice-block' + (isUser ? ' voice-block-user' : '');
|
|
563
565
|
if (isUser) {
|
|
@@ -666,6 +668,7 @@
|
|
|
666
668
|
if (data.conversationId && data.conversationId !== currentConversationId) return;
|
|
667
669
|
spokenChunks = new Set();
|
|
668
670
|
renderedSeqs = new Set();
|
|
671
|
+
_voiceBreakNext = false;
|
|
669
672
|
}
|
|
670
673
|
});
|
|
671
674
|
window.addEventListener('conversation-selected', function(e) {
|
|
@@ -682,7 +685,6 @@
|
|
|
682
685
|
function handleVoiceBlock(block, isNew) {
|
|
683
686
|
if (!block || !block.type) return;
|
|
684
687
|
if (block.type === 'text' && block.text) {
|
|
685
|
-
// Deduplicate: prevent rendering the same text block twice within 500ms
|
|
686
688
|
var now = Date.now();
|
|
687
689
|
if (_lastVoiceBlockText === block.text && (now - _lastVoiceBlockTime) < 500) {
|
|
688
690
|
return;
|
|
@@ -697,7 +699,10 @@
|
|
|
697
699
|
setTimeout(function() { div.classList.remove('speaking'); }, 2000);
|
|
698
700
|
}
|
|
699
701
|
} else if (block.type === 'result') {
|
|
702
|
+
_voiceBreakNext = true;
|
|
700
703
|
addVoiceResultBlock(block, isNew);
|
|
704
|
+
} else {
|
|
705
|
+
_voiceBreakNext = true;
|
|
701
706
|
}
|
|
702
707
|
}
|
|
703
708
|
|
|
@@ -705,9 +710,9 @@
|
|
|
705
710
|
var container = document.getElementById('voiceMessages');
|
|
706
711
|
if (!container) return;
|
|
707
712
|
container.innerHTML = '';
|
|
708
|
-
// Reset dedup state when loading a new conversation
|
|
709
713
|
_lastVoiceBlockText = null;
|
|
710
714
|
_lastVoiceBlockTime = 0;
|
|
715
|
+
_voiceBreakNext = false;
|
|
711
716
|
if (!conversationId) {
|
|
712
717
|
showVoiceEmpty(container);
|
|
713
718
|
return;
|
|
@@ -722,6 +727,7 @@
|
|
|
722
727
|
return;
|
|
723
728
|
}
|
|
724
729
|
var hasContent = false;
|
|
730
|
+
_voiceBreakNext = false;
|
|
725
731
|
data.chunks.forEach(function(chunk) {
|
|
726
732
|
if (chunk.sequence !== undefined) renderedSeqs.add(chunk.sequence);
|
|
727
733
|
var block = typeof chunk.data === 'string' ? JSON.parse(chunk.data) : chunk.data;
|
|
@@ -730,8 +736,11 @@
|
|
|
730
736
|
addVoiceBlock(block.text, false);
|
|
731
737
|
hasContent = true;
|
|
732
738
|
} else if (block.type === 'result') {
|
|
739
|
+
_voiceBreakNext = true;
|
|
733
740
|
addVoiceResultBlock(block, false);
|
|
734
741
|
hasContent = true;
|
|
742
|
+
} else {
|
|
743
|
+
_voiceBreakNext = true;
|
|
735
744
|
}
|
|
736
745
|
});
|
|
737
746
|
if (!hasContent) showVoiceEmpty(container);
|