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
2 changes: 1 addition & 1 deletion .postal/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ debug = false
# command='python3 ./scripts/test_tool.py'

[model]
name = "baidu/ernie-5.5-flash-preview:free"
name = "deepseek/deepseek-v4.1-flash-1017"
temperature = 1.0
context_window = 256000

Expand Down
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ These go before the command, or on their own with the bare `postal`.

`postal` opens a full-screen Ink interface with a centered cloud logo and prompt bar. The bar moves below the conversation after the first message. Its input grows to five visible text rows, then scrolls. Tools show compact previews. Reasoning shows the latest four wrapped rows while running; expand it to read the full live text. Agent activity opens in an overlay.

The prompt bar's `+` menu adds workspace text/code file references, requests web search for the next prompt, or opens slash commands. File and web chips can be removed before sending. The model picker accepts a model ID and lists models used during the session; the effort picker uses the supported reasoning levels. The arrow sends the prompt and becomes a stop button while Postal is working. Use `Tab` to reach these controls or click them. Settings changes preserve the current draft.
The prompt bar's model picker accepts a model ID and lists models used during the session; the effort picker uses the supported reasoning levels; the approval picker switches between the six policies. Slash commands remain available with `/` or `Ctrl+P`. The arrow sends the prompt and becomes a stop button while Postal is working. Use `Tab` to reach these controls or click them. Settings changes preserve the current draft.

| Key | Action |
| --- | --- |
Expand Down
12 changes: 11 additions & 1 deletion tests/test_ui_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from client.llm_client import LLMClient
from client.response import StreamEvent, StreamEventType, TextDelta, ToolCall
from config.config import Config
from config.config import ApprovalPolicy, Config
from ui.bridge import BridgeSession


Expand Down Expand Up @@ -68,6 +68,16 @@ async def test_streaming_settings_and_clear_stay_in_python(self):
self.assertEqual(session.agent.session.turns, 0)
self.assertIn({"type": "transcript", "messages": []}, messages)

async def test_approval_mode_changes_the_live_policy(self):
async with self.session() as (session, messages):
with self.assertRaises(ValueError):
await session.dispatch("approval", {"mode": "sideways"})
self.assertEqual(session.config.approval, ApprovalPolicy.ON_REQUEST)
await session.dispatch("approval", {"mode": "yolo"})
self.assertEqual(session.config.approval, ApprovalPolicy.YOLO)
self.assertEqual(session.agent.session.approval_manager.approval_policy, ApprovalPolicy.YOLO)
self.assertEqual(session.settings()["approval"], "yolo")

async def test_approval_is_explicit_and_correlated(self):
for approve in (True, False):
with self.subTest(approve=approve):
Expand Down
8 changes: 7 additions & 1 deletion ui/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from rich.console import Console

from agent.agent import Agent
from config.config import Config
from config.config import ApprovalPolicy, Config
from tools.base import ToolConfirmation
from ui.components.logo import POSTAL_BLOB, POSTAL_VERSION
from ui.repl.commands import SlashCommands
Expand Down Expand Up @@ -190,6 +190,12 @@ async def dispatch(self, method: str, params: dict) -> dict:
effort = "on"
await self.command(f"/thinking {effort}", quiet=True)
return self.settings()
if method == "approval":
mode = params.get("mode")
if mode not in {policy.value for policy in ApprovalPolicy}:
raise ValueError("Unsupported approval mode.")
await self.command(f"/approval {mode}", quiet=True)
return self.settings()
if method == "submit":
text = params.get("text", "")
if not isinstance(text, str) or not text.strip():
Expand Down
3 changes: 1 addition & 2 deletions ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ui.components.memory import render_memory
from ui.components.plan import render_plan
from ui.components.permission_prompt import permission_choices, permission_prompt
from ui.components.shimmer import shimmer, shimmer_tool_label, shimmers
from ui.components.shimmer import shimmer, shimmer_tool_label
from ui.components.spinner import SPINNER_INTERVAL, Spinner
from ui.components.status_bar import status_bar
from ui.components.tool_progress import tool_progress_panel
Expand Down Expand Up @@ -66,7 +66,6 @@
'render_transcript',
'shimmer',
'shimmer_tool_label',
'shimmers',
'status_bar',
'permission_choices',
'permission_prompt',
Expand Down
6 changes: 0 additions & 6 deletions ui/components/shimmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
SHIMMER_SPEED = 0.4
SHIMMER_GAP = 10

SHIMMERING_KINDS = frozenset({"subagent"})


def shimmers(tool_kind: str | None) -> bool:
return (tool_kind or "") in SHIMMERING_KINDS


def shimmer(label: str, frame: int) -> Text:
head = (frame * SHIMMER_SPEED) % (len(label) + SHIMMER_GAP)
Expand Down
7 changes: 2 additions & 5 deletions ui/components/tool_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rich.panel import Panel
from rich.text import Text

from ui.components.shimmer import shimmer_tool_label, shimmers
from ui.components.shimmer import shimmer_tool_label


def tool_progress_panel(
Expand All @@ -19,10 +19,7 @@ def tool_progress_panel(
"""Render the compact live panel shown while a tool is running."""

line = Text.assemble((f"{spinner} ", "tool"))
if shimmers(tool_kind):
line.append_text(shimmer_tool_label(name, frame))
else:
line.append(name, style="highlight")
line.append_text(shimmer_tool_label(name, frame))
if headline:
line.append(" ")
line.append(headline, style="subtitle")
Expand Down
33 changes: 17 additions & 16 deletions ui/terminal/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {TOOL_COMPACT_DELAY, type DetailKey} from './toolPresentation.js';
import {expandTools, toggleDetail} from './toolNavigation.js';
import {useConversationScroll} from './scroll.js';

type MenuKind = 'context' | 'model' | 'effort' | 'file' | 'commands' | 'agents';
type MenuKind = 'model' | 'effort' | 'approval' | 'file' | 'commands' | 'agents';
interface OpenMenu {kind: MenuKind; input: Draft; index: number; error?: string; scroll: number}
export function layout(columns: number, rows: number, home: boolean, draft: Draft, sources: boolean) {
const width = Math.max(26, Math.min(home ? 70 : 96, columns - 4));
Expand Down Expand Up @@ -167,21 +167,23 @@ export function PostalApp({backend, size}: {backend: Transport; size?: {columns:
};
const action = (target: Focus) => {
setFocus(target);
if (target === 'send') void submit();
else if (target !== 'input' && state.ready && !state.busy && !sending) openMenu(target === 'add' ? 'context' : target);
if (target !== 'input' && state.ready && !state.busy && !sending) openMenu(target);
};
const agents = Object.values(state.agents);
const choices: Choice[] = useMemo(() => {
if (!menu) return [];
const query = menu.input.text.toLowerCase();
switch (menu.kind) {
case 'context': return [
...(state.capabilities.read ? [{key: 'file', label: 'Add a file', detail: 'Text and code from this workspace'}] : []),
...(state.capabilities.search ? [{key: 'web', label: web ? 'Remove web search' : 'Web search', detail: 'Use live sources for this prompt'}] : []),
{key: 'commands', label: 'Commands', detail: 'Browse slash commands'},
];
case 'effort': return ['auto', 'minimal', 'low', 'medium', 'high', 'none'].map(value => ({key: value,
label: value === 'none' ? 'Off' : value[0]!.toUpperCase() + value.slice(1), detail: value === 'auto' ? 'Let the model decide' : ''}));
case 'approval': return [
{key: 'on_request', label: 'Ask', detail: 'Confirm every mutating tool'},
{key: 'on_fail', label: 'On fail', detail: 'Run freely, ask only after a failure'},
{key: 'auto', label: 'Auto', detail: 'Run everything except dangerous commands'},
{key: 'auto_edit', label: 'Auto-edit', detail: 'Edit freely, confirm bash commands'},
{key: 'never', label: 'Read-only', detail: 'Reject anything that is not known safe'},
{key: 'yolo', label: 'Yolo', detail: 'Approve everything, including dangerous commands'},
].filter(choice => choice.label.toLowerCase().startsWith(query));
case 'model': {
const values = [...new Set([menu.input.text.trim(), ...state.recentModels.toReversed()])].filter(Boolean);
return values.filter(value => value.toLowerCase().includes(query)).map(value => ({key: value, label: value,
Expand All @@ -191,21 +193,20 @@ export function PostalApp({backend, size}: {backend: Transport; size?: {columns:
case 'agents': return agents.map(agent => ({key: agent.agent_id, label: `${' '.repeat(agent.depth)}${agent.name} · ${agent.status}`}));
default: return [];
}
}, [menu, state.capabilities, state.commands, state.recentModels, state.settings.model, state.agents, web]);
}, [menu, state.commands, state.recentModels, state.settings.model, state.agents]);
const selected = Math.max(0, Math.min(menu?.index ?? 0, choices.length - 1));
const closeMenu = () => { setMenu(undefined); setFocus('input'); };
const choose = async (choice?: Choice) => {
if (!menu || choice?.disabled) return;
try {
if (menu.kind === 'context') {
if (choice?.key === 'web') { setWeb(current => !current); closeMenu(); }
else if (choice) openMenu(choice.key as MenuKind);
} else if (menu.kind === 'commands' && choice) {
if (menu.kind === 'commands' && choice) {
const text = `/${choice.key} `; setDraft({text, cursor: text.length}); closeMenu();
} else if (menu.kind === 'model' && choice) {
await backend.request('model', {model: choice.key}); closeMenu();
} else if (menu.kind === 'effort' && choice) {
await backend.request('effort', {effort: choice.key}); closeMenu();
} else if (menu.kind === 'approval' && choice) {
await backend.request('approval', {mode: choice.key}); closeMenu();
} else if (menu.kind === 'file') {
const result = await backend.request<{path: string}>('file', {path: menu.input.text});
setFiles(current => [...new Set([...current, result.path])]); closeMenu();
Expand Down Expand Up @@ -263,9 +264,9 @@ export function PostalApp({backend, size}: {backend: Transport; size?: {columns:
setHistoryIndex(next);
const text = history[next]; setDraft(text === undefined ? savedDraft.current : {text, cursor: text.length}); return;
}
if (key.tab) { setFocus(focusOrder[(focusOrder.indexOf(focus) + (key.shift ? 4 : 1)) % focusOrder.length]!); return; }
if (key.tab) { setFocus(focusOrder[(focusOrder.indexOf(focus) + (key.shift ? focusOrder.length - 1 : 1)) % focusOrder.length]!); return; }
if ((key.return && (key.shift || key.meta)) || (key.ctrl && input === 'j') || input === '\n') { setDraft(current => insert(current, '\n')); setFocus('input'); return; }
if (key.return) { if (focus === 'input' || focus === 'send') void submit(); else action(focus); return; }
if (key.return) { if (focus === 'input') void submit(); else action(focus); return; }
if (focus === 'input') {
if (input === '/' && !draft.text) { openMenu('commands'); return; }
setDraft(current => edit(current, input, key, dimensions.width - 6));
Expand Down Expand Up @@ -294,7 +295,7 @@ export function PostalApp({backend, size}: {backend: Transport; size?: {columns:
<Text color={colors.dim}>↑↓ select · c cancel · pgup/pgdn scroll · esc</Text>
</Box>;
} else if (menu) {
overlay = <Menu title={{context: 'Add to your prompt', model: 'Choose a model', effort: 'Reasoning effort', file: 'Add a workspace file', commands: 'Commands'}[menu.kind]}
overlay = <Menu title={{model: 'Choose a model', effort: 'Reasoning effort', approval: 'Choose an approval mode', file: 'Add a workspace file', commands: 'Commands'}[menu.kind]}
choices={choices} selected={selected} input={['model', 'file', 'commands'].includes(menu.kind) ? menu.input : undefined}
width={panelWidth} height={panelHeight} error={menu.error} onChoose={choice => { void choose(choice); }} onClose={closeMenu}/>;
}
Expand Down
5 changes: 4 additions & 1 deletion ui/terminal/src/ToolRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {useEffect, useState} from 'react';
import {Box, Text} from 'ink';
import stringWidth from 'string-width';
import {fit} from './editor.js';
import {FRAME_INTERVAL, ShimmerText} from './activity.js';
import {formatElapsed, LatticeIcon} from './LatticeLoader.js';
import {middleTruncate, shortPath, toolSummary, toolTarget, TOOL_SETTLE_DURATION, type ToolPresentation} from './toolPresentation.js';
export {toolSummary, toolTarget} from './toolPresentation.js';
Expand Down Expand Up @@ -46,7 +47,9 @@ export default function ToolRow({tool: {activity: tool, indent = 0, expanded = f
: <Text color={foreground}>{running ? '·' : tool.status === 'completed' ? '✓' : tool.status === 'cancelled' ? '■' : '×'} </Text>}</Box>
<Text> </Text>
<Box width={labelWidth} overflow="hidden" flexShrink={0}>
<Text wrap="truncate"><Text color={foreground} bold>{name}</Text>
<Text wrap="truncate">{running && animate
? <ShimmerText text={name} frame={Math.floor(now / FRAME_INTERVAL)} bold/>
: <Text color={foreground} bold>{name}</Text>}
{target && <Text color={path ? '#737373' : '#a0a0a0'}> {target.slice(0, directoryEnd)}<Text bold={path} color={path ? foreground : '#a0a0a0'}>{target.slice(directoryEnd)}</Text></Text>}
{summaryText && <Text color="#737373">{summaryText}</Text>}
</Text>
Expand Down
10 changes: 8 additions & 2 deletions ui/terminal/src/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ export function shimmerColor(index: number, frame: number, length: number) {
return `#${shade.repeat(3)}`;
}

export function LoadingText({text, frame}: {text: string; frame: number}) {
export function ShimmerText({text, frame, bold}: {text: string; frame: number; bold?: boolean}) {
const characters = [...text];
return <Text wrap="truncate"><LatticeIcon elapsed={frame * FRAME_INTERVAL / 1000}/>{' '}
return <Text bold={bold} wrap="truncate">
{characters.map((character, index) => <Text key={index} color={shimmerColor(index, frame, characters.length)}>{character}</Text>)}
</Text>;
}

export function LoadingText({text, frame}: {text: string; frame: number}) {
return <Text wrap="truncate"><LatticeIcon elapsed={frame * FRAME_INTERVAL / 1000}/>{' '}
<ShimmerText text={text} frame={frame}/>
</Text>;
}
14 changes: 7 additions & 7 deletions ui/terminal/src/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const markdown = new Marked(markedTerminal({reflowText: false, showSectionPrefix
heading: plain, firstHeading: plain, codespan: plain, link: plain, href: plain,
tableOptions: {style: {head: [], border: []}},
}) as any, {renderer: {code: ({text}) => `${clean(text).split('\n').map(line => ` ${line}`).join('\n')}\n\n`}});
export type Focus = 'input' | 'add' | 'model' | 'effort' | 'send';
export const focusOrder: Focus[] = ['input', 'add', 'model', 'effort', 'send'];
export type Focus = 'input' | 'model' | 'effort' | 'approval';
export const focusOrder: Focus[] = ['input', 'model', 'effort', 'approval'];

export function Editor({draft, width, rows, focused, placeholder = 'Ask anything…'}: {
draft: Draft; width: number; rows: number; focused: boolean; placeholder?: string;
Expand Down Expand Up @@ -57,7 +57,9 @@ export function PromptBar({state, draft, width, inputRows, padding, focus, files
const inner = width - 6, narrow = width < 55;
const effort = !state.settings.reasoning.enabled ? 'Off' : state.settings.reasoning.max_tokens ? 'Custom' : state.settings.reasoning.effort ?? 'Auto';
const model = state.settings.model.split('/').at(-1) || 'Choose model';
const modelWidth = Math.max(6, Math.min(narrow ? 14 : 28, inner - 24));
const mode = state.settings.approval || 'ask';
const approval = {ask: 'Ask', 'on fail': 'On fail', auto: 'Auto', 'auto-edit': 'Auto-edit', 'read-only': 'Read-only', yolo: 'Yolo'}[mode] ?? 'Ask';
const modelWidth = Math.max(6, Math.min(narrow ? 14 : 28, inner - 32));
const disabled = !state.ready || state.busy || sending;
return <Box width={width} flexDirection="column" paddingX={2} paddingY={padding} borderStyle="round"
borderColor={focus === 'input' && active ? colors.line : colors.panel} borderBackgroundColor={colors.background} backgroundColor={colors.panel} flexShrink={0}>
Expand All @@ -67,14 +69,12 @@ export function PromptBar({state, draft, width, inputRows, padding, focus, files
</Box>}
<HitBox onClick={() => action('input')} active={active}><Editor draft={draft} width={inner} rows={inputRows} focused={focus === 'input' && active}/></HitBox>
<Box height={1} width={inner} alignItems="center">
<Control label="+" width={3} selected={focus === 'add'} disabled={disabled} onClick={() => active && action('add')}/>
<Box width={1}/>
<Control label={`${fit(model, modelWidth - 2)} ▾`} selected={focus === 'model'} disabled={disabled} onClick={() => active && action('model')}/>
{!narrow && <Text color={colors.line}> · </Text>}
<Control label={`${fit(effort[0]!.toUpperCase() + effort.slice(1), narrow ? 4 : 7)} ▾`} selected={focus === 'effort'} disabled={disabled} onClick={() => active && action('effort')}/>
{!narrow && <Text color={colors.line}> · </Text>}
<Control label={`${fit(approval, narrow ? 8 : 10)} ▾`} selected={focus === 'approval'} disabled={disabled} onClick={() => active && action('approval')}/>
<Box flexGrow={1}/>
<Control label={state.busy ? '■' : '↑'} width={3} selected={focus === 'send'} strong
disabled={!state.ready || sending || (!state.busy && !draft.text.trim())} onClick={() => active && action('send')}/>
</Box>
</Box>;
}
Expand Down
5 changes: 4 additions & 1 deletion ui/terminal/src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class DemoBackend implements Transport {
async request<T = Record<string, unknown>>(method: string, params: Record<string, unknown> = {}): Promise<T> {
if (method === 'model') this.settings = {...this.settings, model: String(params.model)};
if (method === 'effort') this.settings = {...this.settings, reasoning: {...this.settings.reasoning, effort: String(params.effort)}};
if (method === 'model' || method === 'effort') this.emit({type: 'settings', settings: this.settings});
if (method === 'approval') this.settings = {...this.settings, approval: {
on_request: 'ask', on_fail: 'on fail', auto: 'auto', auto_edit: 'auto-edit', never: 'read-only', yolo: 'yolo',
}[String(params.mode)] ?? this.settings.approval};
if (method === 'model' || method === 'effort' || method === 'approval') this.emit({type: 'settings', settings: this.settings});
if (method === 'submit') {
const text = String(params.text);
if (text === '/clear') this.emit({type: 'transcript', messages: []});
Expand Down
Loading
Loading