fix: disable Delete button for main session instead of hiding
- Add isMainSession prop to ChatProps - Show Delete button for all sessions but disable for main - Add tooltip explaining why main session cannot be deleted
This commit is contained in:
parent
0831ee3865
commit
b57d85264c
@ -497,13 +497,12 @@ export function renderApp(state: AppViewState) {
|
|||||||
onSplitRatioChange: (ratio: number) => state.handleSplitRatioChange(ratio),
|
onSplitRatioChange: (ratio: number) => state.handleSplitRatioChange(ratio),
|
||||||
assistantName: state.assistantName,
|
assistantName: state.assistantName,
|
||||||
assistantAvatar: state.assistantAvatar,
|
assistantAvatar: state.assistantAvatar,
|
||||||
// Delete session (hidden for main session)
|
// Delete session (disabled for main session)
|
||||||
showDeleteConfirm: state.chatDeleteConfirm,
|
showDeleteConfirm: state.chatDeleteConfirm,
|
||||||
onDeleteClick:
|
isMainSession:
|
||||||
state.sessionKey === "main" ||
|
state.sessionKey === "main" ||
|
||||||
parseAgentSessionKey(state.sessionKey)?.rest === "main"
|
parseAgentSessionKey(state.sessionKey)?.rest === "main",
|
||||||
? undefined
|
onDeleteClick: () => (state.chatDeleteConfirm = true),
|
||||||
: () => (state.chatDeleteConfirm = true),
|
|
||||||
onDeleteConfirm: async () => {
|
onDeleteConfirm: async () => {
|
||||||
state.chatDeleteConfirm = false;
|
state.chatDeleteConfirm = false;
|
||||||
const { deleteSession } = await import("./controllers/sessions");
|
const { deleteSession } = await import("./controllers/sessions");
|
||||||
|
|||||||
@ -70,6 +70,7 @@ export type ChatProps = {
|
|||||||
onChatScroll?: (event: Event) => void;
|
onChatScroll?: (event: Event) => void;
|
||||||
// Delete session
|
// Delete session
|
||||||
showDeleteConfirm?: boolean;
|
showDeleteConfirm?: boolean;
|
||||||
|
isMainSession?: boolean;
|
||||||
onDeleteClick?: () => void;
|
onDeleteClick?: () => void;
|
||||||
onDeleteConfirm?: () => void;
|
onDeleteConfirm?: () => void;
|
||||||
onDeleteCancel?: () => void;
|
onDeleteCancel?: () => void;
|
||||||
@ -407,9 +408,9 @@ export function renderChat(props: ChatProps) {
|
|||||||
? html`
|
? html`
|
||||||
<button
|
<button
|
||||||
class="btn danger"
|
class="btn danger"
|
||||||
?disabled=${!props.connected || isBusy}
|
?disabled=${!props.connected || isBusy || props.isMainSession}
|
||||||
@click=${props.onDeleteClick}
|
@click=${props.onDeleteClick}
|
||||||
title="Delete this session"
|
title=${props.isMainSession ? "Cannot delete main session" : "Delete this session"}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user