better instructinos

This commit is contained in:
Arjun 2026-04-03 17:12:43 +05:30
parent e0f3432cd9
commit f4f2f78c68
2 changed files with 34 additions and 4 deletions

View file

@ -1,5 +1,5 @@
import * as React from 'react' import * as React from 'react'
import { useCallback, useEffect, useState, useRef } from 'react' import { useCallback, useEffect, useState, useRef, useLayoutEffect } from 'react'
import { workspace } from '@x/shared'; import { workspace } from '@x/shared';
import { RunEvent, ListRunsResponse } from '@x/shared/src/runs.js'; import { RunEvent, ListRunsResponse } from '@x/shared/src/runs.js';
import type { LanguageModelUsage, ToolUIPart } from 'ai'; import type { LanguageModelUsage, ToolUIPart } from 'ai';
@ -615,6 +615,36 @@ function ContentHeader({
) )
} }
/**
* A <pre> element that auto-scrolls to the bottom as content updates,
* but stops auto-scrolling when the user manually scrolls up.
*/
function AutoScrollPre({ className, children }: { className?: string; children: React.ReactNode }) {
const ref = useRef<HTMLPreElement>(null)
const stickToBottom = useRef(true)
useLayoutEffect(() => {
const el = ref.current
if (el && stickToBottom.current) {
el.scrollTop = el.scrollHeight
}
}, [children])
const handleScroll = useCallback(() => {
const el = ref.current
if (!el) return
// Consider "at bottom" if within 24px of the bottom edge
const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 24
stickToBottom.current = atBottom
}, [])
return (
<pre ref={ref} onScroll={handleScroll} className={className}>
{children}
</pre>
)
}
function App() { function App() {
type ShortcutPane = 'left' | 'right' type ShortcutPane = 'left' | 'right'
type MarkdownHistoryHandlers = { undo: () => boolean; redo: () => boolean } type MarkdownHistoryHandlers = { undo: () => boolean; redo: () => boolean }
@ -3871,9 +3901,9 @@ function App() {
<h4 className="font-medium text-muted-foreground text-xs uppercase tracking-wide"> <h4 className="font-medium text-muted-foreground text-xs uppercase tracking-wide">
Live Output Live Output
</h4> </h4>
<pre className="max-h-80 overflow-auto rounded-md border bg-zinc-950 p-4 font-mono text-xs text-green-400 whitespace-pre-wrap"> <AutoScrollPre className="max-h-80 overflow-auto rounded-md border bg-zinc-950 p-4 font-mono text-xs text-green-400 whitespace-pre-wrap">
{item.streamingOutput} {item.streamingOutput}
</pre> </AutoScrollPre>
</div> </div>
) : output !== null ? ( ) : output !== null ? (
<ToolOutput output={output} errorText={errorText} /> <ToolOutput output={output} errorText={errorText} />

View file

@ -82,7 +82,7 @@ When constructing the prompt for the coding agent:
### Step 4: Report results ### Step 4: Report results
After the command finishes, present the coding agent's output directly to the user — do not rephrase, summarize, or add commentary on top of it. The agent's output is the result. Only add your own explanation if something went wrong (e.g. the command failed or the exit code is non-zero). After the command finishes, look for the summary that the coding agent produced at the end of its output and pass that along to the user as-is. Do not rewrite or add to it. Only add your own explanation if the command failed or the exit code is non-zero.
Do NOT use file reference blocks (e.g. \`\`\`file:path/to/file\`\`\`) when mentioning code files — they may not open correctly. Just refer to file paths as plain text. Do NOT use file reference blocks (e.g. \`\`\`file:path/to/file\`\`\`) when mentioning code files — they may not open correctly. Just refer to file paths as plain text.