@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
85 lines • 3.47 kB
TypeScript
/**
* A single footer segment: plain text drives the width math, colored text is
* what actually renders. Kept as a pair so truncation decisions never have to
* strip ANSI codes.
*/
export interface FooterSegment {
readonly plain: string;
readonly colored: string;
}
/**
* How much the left side may give up for a right-label form to be kept:
* `everything` means the form is used only when the whole footer fits as is,
* `middle-elision` lets the middle stats elide but never the pwd, and
* `pwd-elision` (the default) also lets the pwd shrink from its head.
*/
export type FooterRightFit = "everything" | "middle-elision" | "pwd-elision";
export interface FooterRightForm extends FooterSegment {
readonly fitsWith?: FooterRightFit;
}
export interface FooterRightLabel {
/**
* Right-label forms from richest to poorest, e.g. provider + model + level + key hint
* down to the bare model id. The planner keeps the first form that fits under its
* own `fitsWith` rule; the last one is the floor that must always fit and is what
* truncation falls back to.
*/
readonly forms: readonly [FooterRightForm, ...FooterRightForm[]];
}
export interface FooterLayoutInput {
readonly width: number;
/** Always-kept leading segments in display order. */
readonly anchor: readonly [FooterSegment, ...FooterSegment[]];
/** Index of the pwd segment inside anchor. */
readonly pwdIndex: number;
/** Droppable middle segments in display order; dropped from the right end first. */
readonly middle: readonly FooterSegment[];
/** Always-kept trailing segment (context usage). */
readonly tail: FooterSegment;
readonly right: FooterRightLabel;
/** Plain separator placed between left segments. */
readonly separator: string;
/** Minimum gap between the left block and the right label. */
readonly minPadding: number;
/** Marker shown where middle segments were elided. */
readonly ellipsisMarker: FooterSegment;
}
/**
* How the footer fits the terminal width, from "everything visible" down to
* "only the model label survives". The caller materializes the plan into text.
*/
export type FooterLayout = {
readonly kind: "full";
readonly rightForm: number;
} | {
readonly kind: "middle-elided";
readonly keptMiddleCount: number;
readonly showMarker: boolean;
/** Index into `right.forms` of the form this plan keeps. */
readonly rightForm: number;
} | {
readonly kind: "pwd-elided";
readonly pwdPlain: string;
readonly keptMiddleCount: number;
readonly showMarker: boolean;
readonly rightForm: number;
} | {
readonly kind: "left-elided";
readonly leftPlain: string;
} | {
readonly kind: "right-truncated";
readonly rightPlain: string;
};
/**
* Elide the head of a string so it fits maxWidth, keeping the tail (the most
* identifying part of a path) and marking the cut with a single "…".
*/
export declare function elideHead(text: string, maxWidth: number): string;
/**
* Pick the richest layout that fits the width. The model label is pinned to
* the right edge and the anchor/tail segments stay visible. The pwd shrinks
* from its head before middle stats yield from the right; the right label
* steps down its own ladder (`right.forms`) one form at a time before that.
*/
export declare function planFooterLayout(input: FooterLayoutInput): FooterLayout;
//# sourceMappingURL=footer-layout.d.ts.map