feat(coding-agent): add fork position and duplicate session option (#3431)
This commit is contained in:
@@ -18,11 +18,12 @@ class UserMessageList implements Component {
|
||||
public onCancel?: () => void;
|
||||
private maxVisible: number = 10; // Max messages visible
|
||||
|
||||
constructor(messages: UserMessageItem[]) {
|
||||
constructor(messages: UserMessageItem[], initialSelectedId?: string) {
|
||||
// Store messages in chronological order (oldest to newest)
|
||||
this.messages = messages;
|
||||
// Start with the last (most recent) message selected
|
||||
this.selectedIndex = Math.max(0, messages.length - 1);
|
||||
const initialIndex = initialSelectedId ? messages.findIndex((message) => message.id === initialSelectedId) : -1;
|
||||
// Start with selected message if provided, else default to the most recent
|
||||
this.selectedIndex = initialIndex >= 0 ? initialIndex : Math.max(0, messages.length - 1);
|
||||
}
|
||||
|
||||
invalidate(): void {
|
||||
@@ -109,19 +110,24 @@ class UserMessageList implements Component {
|
||||
export class UserMessageSelectorComponent extends Container {
|
||||
private messageList: UserMessageList;
|
||||
|
||||
constructor(messages: UserMessageItem[], onSelect: (entryId: string) => void, onCancel: () => void) {
|
||||
constructor(
|
||||
messages: UserMessageItem[],
|
||||
onSelect: (entryId: string) => void,
|
||||
onCancel: () => void,
|
||||
initialSelectedId?: string,
|
||||
) {
|
||||
super();
|
||||
|
||||
// Add header
|
||||
this.addChild(new Spacer(1));
|
||||
this.addChild(new Text(theme.bold("Branch from Message"), 1, 0));
|
||||
this.addChild(new Text(theme.fg("muted", "Select a message to create a new branch from that point"), 1, 0));
|
||||
this.addChild(new Text(theme.fg("muted", "Select a message or duplicate the current session"), 1, 0));
|
||||
this.addChild(new Spacer(1));
|
||||
this.addChild(new DynamicBorder());
|
||||
this.addChild(new Spacer(1));
|
||||
|
||||
// Create message list
|
||||
this.messageList = new UserMessageList(messages);
|
||||
this.messageList = new UserMessageList(messages, initialSelectedId);
|
||||
this.messageList.onSelect = onSelect;
|
||||
this.messageList.onCancel = onCancel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user