Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More keyboard shorcut UI stuff #3929

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions extensions/vscode/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import EditDecorationManager from "./quickEdit/EditDecorationManager";
import { QuickEdit, QuickEditShowParams } from "./quickEdit/QuickEditQuickPick";
import { Battery } from "./util/battery";
import { VsCodeIde } from "./VsCodeIde";
import { getMetaKeyLabel } from "./util/util";

import type { VsCodeWebviewProtocol } from "./webviewProtocol";

Expand Down Expand Up @@ -902,15 +903,18 @@ const getCommandsMap: (
? StatusBarStatus.Enabled
: StatusBarStatus.Disabled;
}

quickPick.items = [
{
label: "$(question) Open help center",
},
{
label: "$(comment) Open chat (Cmd+L)",
label: "$(comment) Open chat",
description: getMetaKeyLabel() + " + L",
},
{
label: "$(screen-full) Open full screen chat (Cmd+K Cmd+M)",
label: "$(screen-full) Open full screen chat",
description: getMetaKeyLabel() + " + K, " + getMetaKeyLabel() + " + M",
},
{
label: quickPickStatusText(targetStatus),
Expand Down
4 changes: 2 additions & 2 deletions extensions/vscode/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export function getMetaKeyLabel() {
return "⌘";
case "linux":
case "windows":
return "^";
return "Ctrl";
default:
return "^";
return "Ctrl";
}
}

Expand Down
7 changes: 3 additions & 4 deletions gui/src/components/History/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SessionMetadata } from "core";
import MiniSearch from "minisearch";
import React, { Fragment, useEffect, useMemo, useRef, useState } from "react";
import Glyph from '../gui/Glyph';

import { getFontSize, getMetaKeyLabel } from "../../util";
import { HistoryTableRow } from "./HistoryTableRow";
Expand Down Expand Up @@ -98,10 +99,8 @@ export function History() {

{filteredAndSortedSessions.length === 0 && (
<div className="m-4 text-center">
No past sessions found. To start a new session, either click the "+"
button or use the keyboard shortcut: <code>{getMetaKeyLabel()}</code>
{` `}
<code>L</code>
No past sessions found. To start a new session, either click the <Glyph>+</Glyph>
button or use the keyboard shortcut: <kbd>{getMetaKeyLabel()}</kbd> + <kbd>L</kbd>
</div>
)}

Expand Down
46 changes: 46 additions & 0 deletions gui/src/components/gui/Glyph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type React from "react"
import styled from "styled-components"
import { lightGray } from ".."

const StyledGlyph = styled.span`
position: relative;
display: inline-block;
font-family: var(--monaco-monospace-font);
font-size: 22px;
font-weight: lighter;
vertical-align: -0.1rem;
margin: 0 6px 0 2px;
line-height: 0.7;
color: --vscode-editor-foreground;
z-index: 1;

&::before {
content: "";
position: absolute;
top: 66%;
left: -10%;
transform: translateY(-50%);
width: 17px;
height: 17px;
border: 1px solid ${lightGray}33;
background-color: ${lightGray}33;
border-radius: 3px;
box-sizing: border-box;
z-index: -1;
}
`

interface GlyphProps {
children: string
}

const Glyph: React.FC<GlyphProps> = ({ children }) => {
if (children !== "+") {
console.warn('Currently, only the "+" glyph is supported.')
return null
}

return <StyledGlyph>{children}</StyledGlyph>
}

export default Glyph
4 changes: 2 additions & 2 deletions gui/src/components/mainInput/TutorialCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
<li className="flex items-start">
<PencilSquareIcon className="h-4 w-4 pr-3 align-middle" />
<span>
Highlight code and press <code>{getMetaKeyLabel() + "I"}</code> to
Highlight code and press <kbd>{getMetaKeyLabel()}</kbd> + <kbd>I</kbd> to
quickly make natural language edits
</span>
</li>
<li className="flex items-start">
<ClipboardDocumentIcon className="h-4 w-4 pr-3 align-middle" />
<span>
Highlight code and press <code>{getMetaKeyLabel() + "L"}</code> to
Highlight code and press <kbd>{getMetaKeyLabel()}</kbd> + <kbd>L</kbd> to
add it to the chat window
</span>
</li>
Expand Down
4 changes: 2 additions & 2 deletions gui/src/components/modelSelection/ModelSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,13 @@ function ModelSelect() {
<Divider className="!my-0" />

<span className="block px-3 py-3" style={{ color: lightGray }}>
<code>{getMetaKeyLabel()} + '</code> to toggle
<kbd>{getMetaKeyLabel()}</kbd> + <kbd>'</kbd> to toggle model
</span>
</div>
</StyledListboxOptions>
</div>
</Listbox>
);
}
}

export default ModelSelect;
6 changes: 6 additions & 0 deletions gui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,9 @@ body {
direction: rtl;
width: 100%;
}

kbd {
/* font-family: var(--monaco-monospace-font); */
font-size: 11px;
color: --vscode-editor-foreground;
}