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

Added the advanced section, for selecting the tab completion #144

122 changes: 109 additions & 13 deletions webviews/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ button:disabled {
.main-wrapper .form-group-wrapper .model-list--label {
display: flex;
align-items: center;
min-width: 200px;
min-width: 230px;
font-size: 15px;
font-weight: normal;
}
Expand Down Expand Up @@ -196,30 +196,126 @@ button:disabled {
color: var(--vscode-terminal-background);
}

/* Toggle Switch (with label) */
.switch-toggle-wrapper {
display: flex;
align-items: center;
justify-content: flex-end;
width: 100%;
margin-bottom: 15px;
}

@media (max-width: 767px) {
.switch-toggle {
--width: 130px;
--height: 30px;
--offset: 0px;
--radius: 35px;
position: relative;
width: var(--width);
height: var(--height);
padding: var(--offset);
background: var(--vscode-welcomePage-tileBackground);
border-radius: var(--radius);
font-size: 12px;
line-height: 1;
font-weight: 500;
line-height: normal;
font-style: normal;
margin-left: 5px;
}

.main-description,
.main-wrapper .form-group-wrapper {
width: calc(100% - 50px);
}
.switch-toggle input[type=checkbox] {
cursor: pointer;
position: absolute;
inset: 0;
appearance: none;
z-index: 2;
outline: none;
}

@media (max-width: 467px) {
.main-wrapper .form-group-wrapper .model-list--outer-wrapper {
flex-wrap: wrap;
gap: 8px 16px;
}
.switch-toggle input[type=checkbox]:checked+label.switch-toggle-label:before {
translate: 100% 0;
}

.switch-toggle input[type=checkbox]:checked+label.switch-toggle-label span:nth-child(1) {
color: var(--vscode-editor-foreground);
}

.switch-toggle input[type=checkbox]:checked+label.switch-toggle-label span:nth-child(2) {
color: var(--vscode-sideBar-background);
}

.switch-toggle input[type=checkbox]+label.switch-toggle-label {
position: absolute;
inset: var(--offset, 0);
padding: 5px 0;
display: block;
user-select: none;
pointer-events: none;
display: grid;
gap: 2px;
grid-auto-flow: column;
grid-auto-columns: 1fr;
place-items: center;
}

.switch-toggle input[type=checkbox]+label.switch-toggle-label:before {
content: "";
position: absolute;
width: 50%;
inset: 0;
background: var(--vscode-terminal-ansiWhite);
border-radius: 35px;
box-shadow: 0px 10px 20px 0px rgba(16, 39, 68, 0.1);
translate: 0 0;
transition: translate 250ms cubic-bezier(0.93, 0.26, 0.07, 0.69);
}

.switch-toggle input[type=checkbox]+label.switch-toggle-label span {
position: relative;
transition: 200ms linear;
}

.switch-toggle input[type=checkbox]+label.switch-toggle-label span:nth-child(1) {
color: var(--vscode-sideBar-background);
}

.switch-toggle input[type=checkbox]+label.switch-toggle-label span:nth-child(2) {
color: var(--vscode-editor-foreground);
}

.info-message {
width: 500px;
font-size: 0.8rem;
background-color: var(--vscode-editor-background);
color: var(--vscode-editor-foreground);
padding: 10px;
text-align: left;
border-radius: 5px;
margin: 0 auto;
opacity: 0.4;
display: flex;
flex-direction: column;
align-items: flex-start;
font-size: 12.5px;
}

.info-message>p {
margin-bottom: 0;
}


/* Don't add CSS below @media query section */
@media (max-width: 767px) {

.main-description,
.info-message,
.main-wrapper .form-group-wrapper {
width: calc(100% - 50px);
}
}

@media (max-width: 467px) {
.main-wrapper .form-group-wrapper .model-list--outer-wrapper {
flex-wrap: wrap;
gap: 8px 16px;
}
}
90 changes: 63 additions & 27 deletions webviews/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function App() {
const [installationModes, setInstallationModes] = useState<{ id: string, label: string, supportsRefresh: true }[]>([]);

const [enabled, setEnabled] = useState<boolean>(true);
const [uiMode, setUiMode] = useState<'simple' | 'advanced'>('simple');

const [isKeepExistingConfigSelected, setIsKeepExistingConfigSelected] = useState(false);

Expand Down Expand Up @@ -75,11 +76,12 @@ function App() {
}

function handleSetupGraniteClick() {
console.log("UiMode:",uiMode, "Test" , uiMode === "advanced" ? chatModel : null);
vscode.postMessage({
command: "setupGranite",
data: {
tabModelId: tabModel,
chatModelId: chatModel,
tabModelId: uiMode === "advanced" ? chatModel : null,
embeddingsModelId: embeddingsModel
}
});
Expand Down Expand Up @@ -235,30 +237,62 @@ function App() {
</div>
</div>

<ModelList
className="model-list"
label="Granite model"
value={chatModel}
onChange={(e) => setChatModel(e?.value ?? null)}
status={getModelStatus(chatModel)}
options={modelOptions}
progress={chatModel ? modelPullProgress[chatModel] : undefined}
disabled={!enabled}
tooltip="This model will be used for Chat and Tab Completion"
/>
<div className="switch-toggle-wrapper">
<label>Model Settings:</label>
<div className="switch-toggle">
<input
className="switch-toggle-checkbox"
type="checkbox"
id="uiModeSwitch"
checked={uiMode === 'advanced'}
onChange={() => setUiMode(uiMode === 'simple' ? 'advanced' : 'simple')}
/>
<label className="switch-toggle-label" htmlFor="uiModeSwitch">
<span>Simple</span>
<span>Advanced</span>
</label>
</div>
</div>

{/*
<ModelList
className="model-list"
label="Tab completion model"
value={tabModel}
onChange={(e) => setTabModel(e?.value ?? null)}
status={getModelStatus(tabModel)}
options={tabOptions}
progress={tabModel ? modelPullProgress[tabModel] : undefined}
disabled={!enabled}
/>
*/}
{uiMode === 'simple' ? (
<ModelList
className="model-list"
label="Granite model"
value={chatModel}
onChange={(e) => setChatModel(e?.value ?? null)}
status={getModelStatus(chatModel)}
options={modelOptions}
progress={chatModel ? modelPullProgress[chatModel] : undefined}
disabled={!enabled}
tooltip="This model will be used for Chat and Tab Completion"
/>

) : (
<>
<ModelList
className="model-list"
label="Chat model"
value={chatModel}
onChange={(e) => setChatModel(e?.value ?? null)}
status={getModelStatus(chatModel)}
options={modelOptions}
progress={chatModel ? modelPullProgress[chatModel] : undefined}
disabled={!enabled}
tooltip="This model will be used for Chat and Tab Completion"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This model will be used for Chat

/>

<ModelList
className="model-list"
label="Tab completion model"
value={tabModel}
onChange={(e) => setTabModel(e?.value ?? null)}
status={getModelStatus(tabModel)}
options={tabOptions}
progress={tabModel ? modelPullProgress[tabModel] : undefined}
disabled={!enabled}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltip="This model will be used for Tab Completion"

/>
</>
)}

<ModelList
className="model-list"
Expand All @@ -280,12 +314,14 @@ function App() {

<div className="info-message">
<p>
To reopen this wizard, open the command palette and run:
<p style={{ margin: 2, paddingLeft: 10 }}><strong>Paver: Setup Granite as code assistant</strong></p>.
** To reopen this wizard, open the command palette and run:<strong>Paver: Setup Granite as code assistant</strong>.
</p>
<p>
** To configure both Chat and Tab Completion, choose <strong><i>Advanced</i></strong>. Otherwise, only configure Chat Model
</p>
</div>
</main>
);
}

export default App;
export default App;
Loading