mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-21 13:21:17 +08:00
sub agent tabs
This commit is contained in:
@@ -35,10 +35,35 @@ function statusIcon(status: FooterSubagentTab["status"]) {
|
||||
return "◔"
|
||||
}
|
||||
|
||||
function tabText(input: {
|
||||
tab: FooterSubagentTab
|
||||
slot: string
|
||||
count: number
|
||||
width: number
|
||||
}) {
|
||||
const perTab = Math.max(1, Math.floor((input.width - 4 - Math.max(0, input.count - 1) * 3) / Math.max(1, input.count)))
|
||||
if (input.count >= 8 || perTab < 12) {
|
||||
return `[${input.slot}]`
|
||||
}
|
||||
|
||||
const label = `[${input.slot}] ${input.tab.label}`
|
||||
if (input.count >= 5 || perTab < 24) {
|
||||
return label
|
||||
}
|
||||
|
||||
const detail = input.tab.description || input.tab.title
|
||||
if (!detail) {
|
||||
return label
|
||||
}
|
||||
|
||||
return `${label} · ${detail}`
|
||||
}
|
||||
|
||||
export function RunFooterSubagentTabs(props: {
|
||||
tabs: FooterSubagentTab[]
|
||||
selected?: string
|
||||
theme: RunFooterTheme
|
||||
width: number
|
||||
}) {
|
||||
return (
|
||||
<box
|
||||
@@ -68,7 +93,12 @@ export function RunFooterSubagentTabs(props: {
|
||||
</text>
|
||||
)}
|
||||
<text fg={active() ? props.theme.text : props.theme.muted} wrapMode="none" truncate>
|
||||
{`[${slot}] ${tab.label}`}
|
||||
{tabText({
|
||||
tab,
|
||||
slot,
|
||||
count: props.tabs.length,
|
||||
width: props.width,
|
||||
})}
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
@@ -87,11 +87,12 @@ function subagentShortcut(event: {
|
||||
return
|
||||
}
|
||||
|
||||
if (!/^[1-9]$/.test(event.name)) {
|
||||
if (!/^[0-9]$/.test(event.name)) {
|
||||
return
|
||||
}
|
||||
|
||||
return Number(event.name) - 1
|
||||
const slot = Number(event.name)
|
||||
return slot === 0 ? 9 : slot - 1
|
||||
}
|
||||
|
||||
export { TEXTAREA_MIN_ROWS, TEXTAREA_MAX_ROWS } from "./footer.prompt"
|
||||
@@ -280,7 +281,7 @@ export function RunFooterView(props: RunFooterViewProps) {
|
||||
<box id="run-direct-footer-top-spacer" width="100%" height={1} flexShrink={0} backgroundColor="transparent" />
|
||||
|
||||
<Show when={showTabs()}>
|
||||
<RunFooterSubagentTabs tabs={tabs()} selected={selected()} theme={theme()} />
|
||||
<RunFooterSubagentTabs tabs={tabs()} selected={selected()} theme={theme()} width={term().width} />
|
||||
</Show>
|
||||
|
||||
<Show
|
||||
|
||||
Reference in New Issue
Block a user