Skip to content

Commit 8f93307

Browse files
committed
fix: simplify cli transcript handling
1 parent 3fe99dc commit 8f93307

2 files changed

Lines changed: 26 additions & 91 deletions

File tree

β€Žpackages/daemon-core/src/cli-adapters/provider-cli-adapter.tsβ€Ž

Lines changed: 9 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -702,40 +702,23 @@ export class ProviderCliAdapter implements CliAdapter {
702702
this.accumulatedBuffer = (this.accumulatedBuffer + cleanData).slice(-ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
703703
this.accumulatedRawBuffer = (this.accumulatedRawBuffer + rawData).slice(-ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
704704

705-
// ─── Startup window: auto-proceed first-run dialogs
705+
// ─── Startup: detect CLI readiness (no auto-proceed)
706706
if (this.startupParseGate) {
707707
this.startupBuffer += cleanData;
708-
709-
const dialogPatterns = [
710-
/Do you want to connect/i,
711-
/Do you trust the files/i,
712-
/Quick safety check/i,
713-
/Is this a project/i,
714-
/Enter to confirm/i,
715-
/be able to read, edit, and execute/i,
716-
/Security guide/i,
717-
];
718-
if (dialogPatterns.some(p => p.test(this.startupBuffer))) {
719-
setTimeout(() => this.ptyProcess?.write('\r'), this.timeouts.dialogAccept);
720-
this.startupBuffer = '';
721-
return;
722-
}
723-
724708
const elapsed = Date.now() - this.spawnAt;
725-
const bufCap = this.startupBuffer.length > 12000;
726-
727-
// Use detectStatus script to check if CLI is ready (shows a prompt)
728709
const scriptStatus = this.runDetectStatus(this.startupBuffer);
729-
const isReady = scriptStatus === 'idle' || elapsed > 8000 || bufCap;
710+
const isReady = scriptStatus === 'idle'
711+
|| scriptStatus === 'waiting_approval'
712+
|| elapsed > 8000
713+
|| this.startupBuffer.length > 12000;
730714

731715
if (isReady) {
732716
this.startupParseGate = false;
733717
this.ready = true;
734-
LOG.info('CLI', `[${this.cliType}] Startup gate end (${elapsed}ms, scriptStatus=${scriptStatus})`);
718+
LOG.info('CLI', `[${this.cliType}] Startup ready (${elapsed}ms, scriptStatus=${scriptStatus})`);
735719
this.onStatusChange?.();
736-
} else {
737-
return;
738720
}
721+
// No early return β€” status detection runs from the start
739722
}
740723

741724
// ─── Script-based status detection
@@ -957,56 +940,8 @@ export class ProviderCliAdapter implements CliAdapter {
957940
}
958941

959942
private commitCurrentTranscript(): void {
960-
const baseMessages = [...this.committedMessages];
961-
const parsed = this.parseCurrentTranscript(baseMessages, '', this.currentTurnScope);
962-
if (parsed && Array.isArray(parsed.messages) && parsed.messages.length > 0) {
963-
const parsedMessages = parsed.messages
964-
.filter((m: any) => m && (m.role === 'user' || m.role === 'assistant'))
965-
.map((m: any) => ({
966-
role: m.role,
967-
content: typeof m.content === 'string' ? m.content : String(m.content || ''),
968-
timestamp: m.timestamp,
969-
}));
970-
const latestAssistant = [...parsedMessages]
971-
.reverse()
972-
.find((m: CliChatMessage) => m.role === 'assistant' && m.content.trim());
973-
if (latestAssistant) {
974-
LOG.info('CLI', `[${this.cliType}] commitCurrentTranscript parsed assistant len=${latestAssistant.content.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || '').slice(0, 120)}`);
975-
const nextMessages = [...baseMessages];
976-
const last = nextMessages[nextMessages.length - 1];
977-
if (last?.role === 'assistant') {
978-
last.content = latestAssistant.content;
979-
last.timestamp = latestAssistant.timestamp || last.timestamp;
980-
} else if (last?.role === 'user') {
981-
nextMessages.push({
982-
role: 'assistant',
983-
content: latestAssistant.content,
984-
timestamp: latestAssistant.timestamp || Date.now(),
985-
});
986-
} else {
987-
nextMessages.push({
988-
role: 'assistant',
989-
content: latestAssistant.content,
990-
timestamp: latestAssistant.timestamp || Date.now(),
991-
});
992-
}
993-
this.committedMessages = nextMessages;
994-
this.syncMessageViews();
995-
return;
996-
}
997-
}
998-
999-
const fallback = String(this.responseBuffer || '').trim();
1000-
LOG.info('CLI', `[${this.cliType}] commitCurrentTranscript fallback len=${fallback.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || '').slice(0, 120)}`);
1001-
if (!fallback) return;
1002-
const last = baseMessages[baseMessages.length - 1];
1003-
if (last?.role === 'assistant') {
1004-
last.content = fallback;
1005-
} else {
1006-
baseMessages.push({ role: 'assistant', content: fallback, timestamp: Date.now() });
1007-
}
1008-
this.committedMessages = baseMessages;
1009-
this.syncMessageViews();
943+
// No-op: terminal output is the canonical display for CLI providers.
944+
// Assistant text extraction from PTY output has been removed.
1010945
}
1011946

1012947
// ─── Script Execution ──────────────────────────

β€Žpackages/web-core/src/index.cssβ€Ž

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -436,29 +436,29 @@ a:hover {
436436
:root[data-chat-theme="ember"] {
437437
--chat-user-bg: #f59e0b;
438438
--chat-user-color: #1a1a1a;
439-
--chat-assistant-bg: #111726;
440-
--chat-assistant-border: 1px solid rgba(255, 255, 255, 0.08);
439+
--chat-assistant-bg: var(--bg-secondary);
440+
--chat-assistant-border: 1px solid var(--border-subtle);
441441
--chat-action-bg: rgba(217, 119, 6, 0.10);
442442
--chat-action-border: 1px solid rgba(217, 119, 6, 0.20);
443443
--chat-action-color: #f59e0b;
444-
--chat-container-bg: #0a0e1a;
445-
--chat-typing-bg: #111726;
446-
--chat-typing-border: 1px solid rgba(255, 255, 255, 0.08);
444+
--chat-container-bg: var(--bg-primary);
445+
--chat-typing-bg: var(--bg-secondary);
446+
--chat-typing-border: 1px solid var(--border-subtle);
447447
}
448448

449449
/* ── Chat Theme: Ember (Light) ─────────────────── */
450450
:root[data-theme="light"][data-chat-theme="ember"] {
451451
--chat-user-bg: #f59e0b;
452452
--chat-user-color: #1a1a1a;
453-
--chat-assistant-bg: #fffaf4;
454-
--chat-assistant-color: #24160f;
455-
--chat-assistant-border: 1px solid rgba(146, 64, 14, 0.10);
453+
--chat-assistant-bg: var(--bg-secondary);
454+
--chat-assistant-color: var(--text-primary);
455+
--chat-assistant-border: 1px solid var(--border-subtle);
456456
--chat-action-bg: rgba(217, 119, 6, 0.07);
457457
--chat-action-border: 1px solid rgba(217, 119, 6, 0.16);
458458
--chat-action-color: #b45309;
459-
--chat-container-bg: #fff8ee;
460-
--chat-typing-bg: #ffffff;
461-
--chat-typing-border: 1px solid rgba(146, 64, 14, 0.10);
459+
--chat-container-bg: var(--bg-primary);
460+
--chat-typing-bg: var(--bg-secondary);
461+
--chat-typing-border: 1px solid var(--border-subtle);
462462
}
463463

464464
/* ── Chat Element Classes ──────────────────────── */
@@ -788,15 +788,15 @@ a:hover {
788788
:root:not([data-theme="dark"])[data-chat-theme="ember"] {
789789
--chat-user-bg: #f59e0b;
790790
--chat-user-color: #1a1a1a;
791-
--chat-assistant-bg: #fffaf4;
792-
--chat-assistant-color: #24160f;
793-
--chat-assistant-border: 1px solid rgba(146, 64, 14, 0.10);
791+
--chat-assistant-bg: var(--bg-secondary);
792+
--chat-assistant-color: var(--text-primary);
793+
--chat-assistant-border: 1px solid var(--border-subtle);
794794
--chat-action-bg: rgba(217, 119, 6, 0.07);
795795
--chat-action-border: 1px solid rgba(217, 119, 6, 0.16);
796796
--chat-action-color: #b45309;
797-
--chat-container-bg: #fff8ee;
798-
--chat-typing-bg: #ffffff;
799-
--chat-typing-border: 1px solid rgba(146, 64, 14, 0.10);
797+
--chat-container-bg: var(--bg-primary);
798+
--chat-typing-bg: var(--bg-secondary);
799+
--chat-typing-border: 1px solid var(--border-subtle);
800800
}
801801

802802
:root:not([data-theme="dark"])[data-chat-theme="aurora"] {

0 commit comments

Comments
Β (0)