refactor(chat): slim the selection menu down to comment and notes
Add to input leaves the desktop menu (mod+L owns it; mobile keeps the button) and the New session action is gone from both variants along with its handler and dead locale keys.
This commit is contained in:
@@ -108,7 +108,6 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
|
||||
const mouseUpTimeoutRef = React.useRef<number | null>(null);
|
||||
const isMenuVisibleRef = React.useRef(false);
|
||||
const activeAddToChatCleanupRef = React.useRef<(() => void) | null>(null);
|
||||
const createSession = useSessionUIStore((state) => state.createSession);
|
||||
const currentSessionId = useSessionUIStore((state) => state.currentSessionId);
|
||||
const newSessionDraftOpen = useSessionUIStore((state) => state.newSessionDraft?.open);
|
||||
const addContextDraft = useInlineCommentDraftStore((state) => state.addDraft);
|
||||
@@ -487,18 +486,6 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
|
||||
});
|
||||
}, [addContextDraft, commentText, currentSessionId, effectiveDirectory, hideMenu, newSessionDraftOpen, selectedMessageId, selectedTextMarkdown]);
|
||||
|
||||
const handleCreateNewSession = React.useCallback(async () => {
|
||||
if (!selectedText) return;
|
||||
|
||||
const session = await createSession(undefined, null, null);
|
||||
if (session) {
|
||||
setPendingInputText(selectedText, 'replace');
|
||||
}
|
||||
|
||||
hideMenu();
|
||||
window.getSelection()?.removeAllRanges();
|
||||
}, [selectedText, createSession, setPendingInputText, hideMenu]);
|
||||
|
||||
const currentSession = React.useMemo(() => {
|
||||
if (!currentSessionId) {
|
||||
return null;
|
||||
@@ -700,22 +687,6 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
|
||||
<span className="min-w-0 whitespace-normal">{t('chat.textSelection.actions.addToInput')}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={handleCreateNewSession}
|
||||
className={cn(
|
||||
'flex min-w-0 items-center gap-2 rounded-xl px-3 py-2.5 text-left',
|
||||
'text-sm font-medium leading-tight',
|
||||
'bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]',
|
||||
'active:opacity-80',
|
||||
'transition-opacity duration-150'
|
||||
)}
|
||||
title={t('chat.textSelection.title.newSessionWithSelection')}
|
||||
type="button"
|
||||
>
|
||||
<Icon name="chat-new" className="h-5 w-5 flex-shrink-0" />
|
||||
<span className="min-w-0 whitespace-normal">{t('chat.textSelection.actions.newSession')}</span>
|
||||
</button>
|
||||
|
||||
{!isVSCodeRuntime() ? (
|
||||
<button
|
||||
onClick={handleAddToNotes}
|
||||
@@ -777,39 +748,6 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
|
||||
{t('chat.textSelection.actions.comment')}
|
||||
</button>
|
||||
|
||||
<div className="mx-0.5 h-5 w-px shrink-0 bg-[var(--interactive-border)]" />
|
||||
|
||||
<button
|
||||
onClick={handleAddToChat}
|
||||
className={cn(
|
||||
'px-3.5 py-1.5 rounded-full',
|
||||
'text-sm font-medium',
|
||||
'text-[var(--surface-foreground)]',
|
||||
'hover:bg-[var(--interactive-hover)]',
|
||||
'transition-colors duration-150'
|
||||
)}
|
||||
title={t('chat.textSelection.title.addToCurrentChat')}
|
||||
type="button"
|
||||
>
|
||||
{t('chat.textSelection.actions.addToInput')}
|
||||
</button>
|
||||
|
||||
<div className="mx-0.5 h-5 w-px shrink-0 bg-[var(--interactive-border)]" />
|
||||
|
||||
<button
|
||||
onClick={handleCreateNewSession}
|
||||
className={cn(
|
||||
'px-3.5 py-1.5 rounded-full',
|
||||
'text-sm font-medium',
|
||||
'text-[var(--surface-foreground)]',
|
||||
'hover:bg-[var(--interactive-hover)]',
|
||||
'transition-colors duration-150'
|
||||
)}
|
||||
title={t('chat.textSelection.title.newSessionWithSelection')}
|
||||
type="button"
|
||||
>
|
||||
{t('chat.textSelection.actions.newSession')}
|
||||
</button>
|
||||
|
||||
{!isVSCodeRuntime() ? (
|
||||
<>
|
||||
|
||||
@@ -2014,10 +2014,8 @@ export const dict = {
|
||||
'chat.textSelection.title.commentOnSelection': 'Auswahl kommentieren',
|
||||
'chat.textSelection.comment.placeholder': 'Optionalen Kommentar hinzufügen...',
|
||||
'chat.textSelection.comment.attach': 'Anhängen',
|
||||
'chat.textSelection.actions.newSession': 'Neue Sitzung',
|
||||
'chat.textSelection.actions.addToNotes': 'Zu Notizen hinzufügen',
|
||||
'chat.textSelection.title.addToCurrentChat': 'Zum aktuellen Chat hinzufügen',
|
||||
'chat.textSelection.title.newSessionWithSelection': 'Neue Sitzung mit Auswahl erstellen',
|
||||
'chat.textSelection.title.saveInsightToNotes': 'Ausgewählten Text zu Notizen speichern',
|
||||
'chat.messageBody.actions.revertAria': 'Zu dieser Nachricht zurückkehren',
|
||||
'chat.messageBody.actions.revert': 'Von hier zurückkehren',
|
||||
|
||||
@@ -2206,10 +2206,8 @@ export const dict = {
|
||||
'chat.textSelection.title.commentOnSelection': 'Comment on selection',
|
||||
'chat.textSelection.comment.placeholder': 'Add an optional comment...',
|
||||
'chat.textSelection.comment.attach': 'Attach',
|
||||
'chat.textSelection.actions.newSession': 'New session',
|
||||
'chat.textSelection.actions.addToNotes': 'Add to notes',
|
||||
'chat.textSelection.title.addToCurrentChat': 'Add to current chat',
|
||||
'chat.textSelection.title.newSessionWithSelection': 'Create new session with selection',
|
||||
'chat.textSelection.title.saveInsightToNotes': 'Save selected text to notes',
|
||||
'chat.messageBody.actions.revertAria': 'Revert to this message',
|
||||
'chat.messageBody.actions.revert': 'Revert from here',
|
||||
|
||||
@@ -2184,10 +2184,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
"chat.textSelection.title.commentOnSelection": "Comentar la selección",
|
||||
"chat.textSelection.comment.placeholder": "Añade un comentario opcional...",
|
||||
"chat.textSelection.comment.attach": "Adjuntar",
|
||||
"chat.textSelection.actions.newSession": "Nueva sesión",
|
||||
"chat.textSelection.actions.addToNotes": "Añadir a las notas",
|
||||
"chat.textSelection.title.addToCurrentChat": "Añadir al chat actual",
|
||||
"chat.textSelection.title.newSessionWithSelection": "Crear nueva sesión con selección",
|
||||
"chat.textSelection.title.saveInsightToNotes": "Guardar texto seleccionado en notas",
|
||||
"chat.messageBody.actions.revertAria": "Volver a este mensaje",
|
||||
"chat.messageBody.actions.revert": "Volver desde aquí",
|
||||
|
||||
@@ -1933,10 +1933,8 @@ export const dict = {
|
||||
'chat.textSelection.title.commentOnSelection': 'Commenter la sélection',
|
||||
'chat.textSelection.comment.placeholder': 'Ajouter un commentaire facultatif...',
|
||||
'chat.textSelection.comment.attach': 'Joindre',
|
||||
'chat.textSelection.actions.newSession': 'Nouvelle session',
|
||||
'chat.textSelection.actions.addToNotes': 'Ajouter aux notes',
|
||||
'chat.textSelection.title.addToCurrentChat': 'Ajouter au chat actuel',
|
||||
'chat.textSelection.title.newSessionWithSelection': 'Créer une nouvelle session avec sélection',
|
||||
'chat.textSelection.title.saveInsightToNotes': 'Enregistrer le texte sélectionné dans les notes',
|
||||
'chat.messageBody.actions.revertAria': 'Revenir à ce message',
|
||||
'chat.messageBody.actions.revert': 'Revenir à partir d\'ici',
|
||||
|
||||
@@ -2202,10 +2202,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
'chat.textSelection.title.commentOnSelection': '選択範囲にコメント',
|
||||
'chat.textSelection.comment.placeholder': '任意のコメントを追加...',
|
||||
'chat.textSelection.comment.attach': '添付',
|
||||
'chat.textSelection.actions.newSession': '新しいセッション',
|
||||
'chat.textSelection.actions.addToNotes': 'メモに追加',
|
||||
'chat.textSelection.title.addToCurrentChat': '現在のチャットに追加',
|
||||
'chat.textSelection.title.newSessionWithSelection': '選択範囲で新しいセッションを作成',
|
||||
'chat.textSelection.title.saveInsightToNotes': '選択テキストをメモに保存',
|
||||
'chat.messageBody.actions.revertAria': 'このメッセージに戻す',
|
||||
'chat.messageBody.actions.revert': 'ここから元に戻す',
|
||||
|
||||
@@ -2208,10 +2208,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
'chat.textSelection.title.commentOnSelection': '선택 영역에 댓글 달기',
|
||||
'chat.textSelection.comment.placeholder': '선택적 댓글 추가...',
|
||||
'chat.textSelection.comment.attach': '첨부',
|
||||
'chat.textSelection.actions.newSession': '새 세션',
|
||||
'chat.textSelection.actions.addToNotes': '메모에 추가',
|
||||
'chat.textSelection.title.addToCurrentChat': '현재 채팅에 추가',
|
||||
'chat.textSelection.title.newSessionWithSelection': '선택한 내용으로 새 세션 생성',
|
||||
'chat.textSelection.title.saveInsightToNotes': '선택한 텍스트를 메모에 저장',
|
||||
'chat.messageBody.actions.revertAria': '이 메시지로 되돌리기',
|
||||
'chat.messageBody.actions.revert': '여기부터 되돌리기',
|
||||
|
||||
@@ -897,10 +897,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
'chat.textSelection.title.commentOnSelection': 'Skomentuj zaznaczenie',
|
||||
'chat.textSelection.comment.placeholder': 'Dodaj opcjonalny komentarz...',
|
||||
'chat.textSelection.comment.attach': 'Załącz',
|
||||
'chat.textSelection.actions.newSession': 'Nowa sesja',
|
||||
'chat.textSelection.actions.addToNotes': 'Dodaj do notatek',
|
||||
'chat.textSelection.title.addToCurrentChat': 'Dodaj do obecnego czatu',
|
||||
'chat.textSelection.title.newSessionWithSelection': 'Utwórz nową sesję z zaznaczeniem',
|
||||
'chat.textSelection.title.saveInsightToNotes': 'Zapisz zaznaczony tekst do notatek',
|
||||
'chat.messageBody.actions.revertAria': 'Cofnij do tej wiadomości',
|
||||
'chat.messageBody.actions.revert': 'Cofnij od tego miejsca',
|
||||
|
||||
@@ -2184,10 +2184,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
"chat.textSelection.title.commentOnSelection": "Comentar a seleção",
|
||||
"chat.textSelection.comment.placeholder": "Adicione um comentário opcional...",
|
||||
"chat.textSelection.comment.attach": "Anexar",
|
||||
"chat.textSelection.actions.newSession": "Nova sessão",
|
||||
"chat.textSelection.actions.addToNotes": "Adicionar às notas",
|
||||
"chat.textSelection.title.addToCurrentChat": "Adicionar ao chat atual",
|
||||
"chat.textSelection.title.newSessionWithSelection": "Criar nova sessão com seleção",
|
||||
"chat.textSelection.title.saveInsightToNotes": "Salvar texto selecionado em notas",
|
||||
"chat.messageBody.actions.revertAria": "Voltar para esta mensagem",
|
||||
"chat.messageBody.actions.revert": "Voltar daqui",
|
||||
|
||||
@@ -2184,10 +2184,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
"chat.textSelection.title.commentOnSelection": "Коментувати виділене",
|
||||
"chat.textSelection.comment.placeholder": "Додайте коментар за бажанням...",
|
||||
"chat.textSelection.comment.attach": "Прикріпити",
|
||||
"chat.textSelection.actions.newSession": "Нова сесія",
|
||||
"chat.textSelection.actions.addToNotes": "Додати до нотаток",
|
||||
"chat.textSelection.title.addToCurrentChat": "Додати до поточного чату",
|
||||
"chat.textSelection.title.newSessionWithSelection": "Створити нову сесію із виділенням",
|
||||
"chat.textSelection.title.saveInsightToNotes": "Зберегти вибраний текст у нотатках",
|
||||
"chat.messageBody.actions.revertAria": "Повернутися до цього повідомлення",
|
||||
"chat.messageBody.actions.revert": "Повернутися звідси",
|
||||
|
||||
@@ -2172,10 +2172,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
'chat.textSelection.title.commentOnSelection': '评论所选内容',
|
||||
'chat.textSelection.comment.placeholder': '添加可选评论...',
|
||||
'chat.textSelection.comment.attach': '附加',
|
||||
'chat.textSelection.actions.newSession': '新建会话',
|
||||
'chat.textSelection.actions.addToNotes': '添加到笔记',
|
||||
'chat.textSelection.title.addToCurrentChat': '添加到当前聊天',
|
||||
'chat.textSelection.title.newSessionWithSelection': '使用选中内容创建新会话',
|
||||
'chat.textSelection.title.saveInsightToNotes': '将选中文本保存到笔记',
|
||||
'chat.messageBody.actions.revertAria': '回退到这条消息',
|
||||
'chat.messageBody.actions.revert': '从此处回退',
|
||||
|
||||
@@ -2176,10 +2176,8 @@ export const dict: Record<I18nKey, string> = {
|
||||
'chat.textSelection.title.commentOnSelection': '對所選內容留言',
|
||||
'chat.textSelection.comment.placeholder': '新增選填留言...',
|
||||
'chat.textSelection.comment.attach': '附加',
|
||||
'chat.textSelection.actions.newSession': '新增會話',
|
||||
'chat.textSelection.actions.addToNotes': '加入筆記',
|
||||
'chat.textSelection.title.addToCurrentChat': '加入目前聊天',
|
||||
'chat.textSelection.title.newSessionWithSelection': '使用選取內容建立新會話',
|
||||
'chat.textSelection.title.saveInsightToNotes': '將選取文字儲存到筆記',
|
||||
'chat.messageBody.actions.revertAria': '收回到這條訊息',
|
||||
'chat.messageBody.actions.revert': '從此處收回',
|
||||
|
||||
Reference in New Issue
Block a user