diff --git a/.changes/unreleased/Added-20240927-142940.yaml b/.changes/unreleased/Added-20240927-142940.yaml new file mode 100644 index 000000000..3a2785783 --- /dev/null +++ b/.changes/unreleased/Added-20240927-142940.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Improved loading/accept/reject UI for apply +time: 2024-09-27T14:29:40.283176-07:00 diff --git a/.changes/unreleased/Added-20240927-143005.yaml b/.changes/unreleased/Added-20240927-143005.yaml new file mode 100644 index 000000000..4dafa06cb --- /dev/null +++ b/.changes/unreleased/Added-20240927-143005.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Polished chat sidebar, especially context dropdown +time: 2024-09-27T14:30:05.576347-07:00 diff --git a/.changes/unreleased/Fixed-20240927-142924.yaml b/.changes/unreleased/Fixed-20240927-142924.yaml new file mode 100644 index 000000000..9a799ee51 --- /dev/null +++ b/.changes/unreleased/Fixed-20240927-142924.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Fixed +body: Fixed a number of apply bugs +time: 2024-09-27T14:29:24.69568-07:00 diff --git a/core/edit/lazy/deterministic.test.ts b/core/edit/lazy/deterministic.test.ts index e3db3f280..7194c0083 100644 --- a/core/edit/lazy/deterministic.test.ts +++ b/core/edit/lazy/deterministic.test.ts @@ -154,4 +154,8 @@ describe("deterministicApplyLazyEdit(", () => { test("no lazy blocks in single top level class", async () => { await expectDiff("no-lazy-single-class.js"); }); + + test("should acknowledge jsx_expression lazy comments", async () => { + await expectDiff("migration-page.tsx"); + }); }); diff --git a/core/edit/lazy/deterministic.ts b/core/edit/lazy/deterministic.ts index aa03c086b..e9cbdf921 100644 --- a/core/edit/lazy/deterministic.ts +++ b/core/edit/lazy/deterministic.ts @@ -135,10 +135,10 @@ export async function deterministicApplyLazyEdit( } } - const acc: AstReplacements = []; - findLazyBlockReplacements(oldTree.rootNode, newTree.rootNode, acc); + const replacements: AstReplacements = []; + findLazyBlockReplacements(oldTree.rootNode, newTree.rootNode, replacements); - const newFullFile = reconstructNewFile(oldFile, newLazyFile, acc); + const newFullFile = reconstructNewFile(oldFile, newLazyFile, replacements); const diff = myersDiff(oldFile, newFullFile); // If the diff is too messy and seems likely borked, we fall back to LLM strategy @@ -155,9 +155,27 @@ export function isLazyLine(text: string): boolean { } function isLazyBlock(node: Parser.SyntaxNode): boolean { + // Special case for "{/* ... existing code ... */}" + if ( + node.type === "jsx_expression" && + node.namedChildCount === 1 && + isLazyBlock(node.namedChildren[0]) + ) { + return true; + } + return node.type.includes("comment") && isLazyLine(node.text); } +function stringsWithinLevDistThreshold( + a: string, + b: string, + threshold: number, +) { + const dist = distance(a, b); + return dist / Math.min(a.length, b.length) <= threshold; +} + /** * Determine whether two nodes are similar * @param a @@ -184,11 +202,23 @@ function nodesAreSimilar(a: Parser.SyntaxNode, b: Parser.SyntaxNode): boolean { return true; } + // Matching jsx_elements needs to be different because they have such a minimal first line + if ( + a.type === "jsx_element" && + b.type === "jsx_element" && + // Check that the tag names match + a.namedChildren[0]?.children[1]?.text === + b.namedChildren[0]?.children[1]?.text + ) { + if (stringsWithinLevDistThreshold(a.text, b.text, 0.3)) { + return true; + } + } + const lineOneA = a.text.split("\n")[0]; const lineOneB = b.text.split("\n")[0]; - const levDist = distance(lineOneA, lineOneB); - return levDist / Math.min(lineOneA.length, lineOneB.length) <= 0.2; + return stringsWithinLevDistThreshold(lineOneA, lineOneB, 0.2); } function nodesAreExact(a: Parser.SyntaxNode, b: Parser.SyntaxNode): boolean { @@ -204,7 +234,7 @@ function nodesAreExact(a: Parser.SyntaxNode, b: Parser.SyntaxNode): boolean { function findLazyBlockReplacements( oldNode: Parser.SyntaxNode, newNode: Parser.SyntaxNode, - acc: AstReplacements, + replacements: AstReplacements, ): void { // Base case if (nodesAreExact(oldNode, newNode)) { @@ -254,7 +284,7 @@ function findLazyBlockReplacements( } // then recurse at the match - findLazyBlockReplacements(L, rightChildren[0], acc); + findLazyBlockReplacements(L, rightChildren[0], replacements); // then consume L and R leftChildren.shift(); @@ -263,7 +293,7 @@ function findLazyBlockReplacements( // Exit "lazy mode" if (isLazy) { // Record the replacement lines - acc.push({ + replacements.push({ nodeToReplace: currentLazyBlockNode!, replacementNodes: [...currentLazyBlockReplacementNodes], }); @@ -275,7 +305,7 @@ function findLazyBlockReplacements( } if (isLazy) { - acc.push({ + replacements.push({ nodeToReplace: currentLazyBlockNode!, replacementNodes: [...currentLazyBlockReplacementNodes, ...leftChildren], }); @@ -284,7 +314,7 @@ function findLazyBlockReplacements( // Cut out any extraneous lazy blocks for (const R of rightChildren) { if (isLazyBlock(R)) { - acc.push({ + replacements.push({ nodeToReplace: R, replacementNodes: [], }); diff --git a/core/edit/lazy/test-examples/migration-page.tsx.diff b/core/edit/lazy/test-examples/migration-page.tsx.diff new file mode 100644 index 000000000..3ff1810c5 --- /dev/null +++ b/core/edit/lazy/test-examples/migration-page.tsx.diff @@ -0,0 +1,166 @@ +import { useNavigate } from "react-router-dom"; +import ContinueButton from "../components/mainInput/ContinueButton"; + +function MigrationPage() { + const navigate = useNavigate(); + return ( +
+

+ Migration to config.json +

+ +

+ Continue now uses a .json config file. We hope that this takes the + guesswork out of setting up. +

+ +

+ Your configuration should have been automatically migrated, but we + recommend double-checking that everything looks correct. +

+ +

+ For a summary of what changed and examples of config.json, + please see the{" "} + + migration walkthrough + + , and if you have any questions please reach out to us on{" "} + + Discord + + . +

+ + + Note: If you are running the server manually and have not updated the + server, this message does not apply. + + + { + navigate("/"); + }} + disabled={false} + /> +
+ ); +} + +export default MigrationPage; + +--- + +import { useNavigate } from "react-router-dom"; +import ContinueButton from "../components/mainInput/ContinueButton"; + +function MigrationPage() { + const navigate = useNavigate(); + return ( +
+

+ Migration to config.json +

+ +

+ Continue now uses a .json config file. We hope that this takes the + guesswork out of setting up. +

+ +

+ Your configuration should have been automatically migrated, but we + recommend double-checking that everything looks correct. +

+ +

+ For a summary of what changed and examples of config.json, + please see the{" "} + + migration walkthrough + + , and if you have any questions please reach out to us on{" "} + + Discord + + . +

+ + + Note: If you are running the server manually and have not updated the + server, this message does not apply. + + + {/* ... existing code ... */} +
+ ); +} + +export default MigrationPage; + +--- + +import { useNavigate } from "react-router-dom"; +import ContinueButton from "../components/mainInput/ContinueButton"; + +function MigrationPage() { + const navigate = useNavigate(); + return ( +
+

+ Migration to config.json +

+ +-

++

+ Continue now uses a .json config file. We hope that this takes the + guesswork out of setting up. +

+ +-

++

+ Your configuration should have been automatically migrated, but we + recommend double-checking that everything looks correct. +

+ +-

++

+ For a summary of what changed and examples of config.json, + please see the{" "} + + migration walkthrough + + , and if you have any questions please reach out to us on{" "} + + Discord + + . +

+ +- ++ + Note: If you are running the server manually and have not updated the + server, this message does not apply. + + + { + navigate("/"); + }} + disabled={false} + /> +
+ ); +} + +export default MigrationPage; \ No newline at end of file diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index d339134e3..13d538be8 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -5,9 +5,10 @@ const SYSTEM_MESSAGE = `When generating new code: 1. Always produce a single code block. 2. Never separate the code into multiple code blocks. 3. Only include the code that is being added. -4. Replace existing code with a "lazy" block like this: "// ... existing code ..." -5. You must always provide 1-2 lines of context above and below a "lazy" block -6. If the user submits a code block that contains a filename in the language specifier, always include the filename in any code block you generate based on that file. The filename should be on the same line as the language specifier in your code block. +4. Replace existing code with a "lazy" comment like this: "// ... existing code ..." +5. The "lazy" comment must always be a valid comment in the current context (e.g. "" for HTML, "// ... existing code ..." for JavaScript, "{/* ... existing code */}" for TSX, etc.) +6. You must always provide 1-2 lines of context above and below a "lazy" comment +7. If the user submits a code block that contains a filename in the language specifier, always include the filename in any code block you generate based on that file. The filename should be on the same line as the language specifier in your code block. Example 1: Input: diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 8ccc6d007..774da7ee5 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -15,7 +15,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { }, ]; openUrl: [string, void]; - applyToCurrentFile: [{ text: string }, void]; + applyToCurrentFile: [{ text: string; streamId: string }, void]; showTutorial: [undefined, void]; showFile: [{ filepath: string }, void]; openConfigJson: [undefined, void]; @@ -32,6 +32,11 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { rejectDiff: [{ filepath: string }, void]; }; +export interface ApplyState { + streamId: string; + status: "streaming" | "done" | "closed"; +} + export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { setInactive: [undefined, void]; setTTSActive: [boolean, void]; @@ -65,4 +70,5 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { incrementFtc: [undefined, void]; openOnboardingCard: [undefined, void]; applyCodeFromChat: [undefined, void]; + updateApplyState: [ApplyState, void]; }; diff --git a/docs/docs/chat/how-to-use-it.md b/docs/docs/chat/how-to-use-it.md index 53cd85d17..509702b4f 100644 --- a/docs/docs/chat/how-to-use-it.md +++ b/docs/docs/chat/how-to-use-it.md @@ -28,7 +28,7 @@ If there is information from the codebase, documentation, IDE, or other tools th ## Apply generated code to your file -When the LLM replies with code, you can hover over the top right of the code block and select “Apply to current file” to update the existing code in the editor to this new version. +When the LLM replies with edits to a file, you can click the “Apply” button. This will update the existing code in the editor to reflect the suggested changes. ## Start a fresh session for a new task diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 34fbfa779..6a7d5faf7 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension pluginName = continue-intellij-extension pluginRepositoryUrl = https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion = 0.0.69 +pluginVersion = 0.0.70 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 223 diff --git a/extensions/vscode/CHANGELOG.md b/extensions/vscode/CHANGELOG.md index ffa85e2d1..ace7c5398 100644 --- a/extensions/vscode/CHANGELOG.md +++ b/extensions/vscode/CHANGELOG.md @@ -6,10 +6,14 @@ and is generated by [Changie](https://github.com/miniscruff/changie). Pre-release Changes +### Added +* Improved loading/accept/reject UI for apply +* Polished chat sidebar, especially context dropdown ### Changed * Updated tutorial file ### Fixed * Continue for teams auth bug fix +* Fixed a number of apply bugs ## 0.9.210 - 2024-09-15 diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 653922315..5f3265799 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.212", + "version": "0.9.213", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 6bec8b754..17140eaf8 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -223,6 +223,7 @@ const commandsMap: ( await verticalDiffManager.streamEdit( config.experimental?.contextMenuPrompts?.[promptName] ?? fallbackPrompt, modelTitle, + undefined, onlyOneInsertion, undefined, range, diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 9259cb38e..5aa5b070b 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -1,4 +1,5 @@ import type { DiffLine } from "core"; +import { ApplyState } from "core/protocol/ideWebview"; import * as vscode from "vscode"; import { DecorationTypeRangeManager, @@ -12,6 +13,7 @@ import type { VerticalDiffCodeLens } from "./manager"; export interface VerticalDiffHandlerOptions { input?: string; instant?: boolean; + onStatusUpdate: (status: ApplyState["status"]) => void; } export class VerticalDiffHandler implements vscode.Disposable { @@ -268,6 +270,8 @@ export class VerticalDiffHandler implements vscode.Disposable { }, ); + this.options.onStatusUpdate("closed"); + this.cancelled = true; this.refreshCodeLens(); this.dispose(); @@ -352,6 +356,8 @@ export class VerticalDiffHandler implements vscode.Disposable { this.refreshCodeLens(); + this.options.onStatusUpdate("done"); + // Reject on user typing // const listener = vscode.workspace.onDidChangeTextDocument((e) => { // if (e.document.uri.fsPath === this.filepath) { diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index c84fa4397..2ecf6d596 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -5,6 +5,7 @@ import { getMarkdownLanguageTagForFile } from "core/util"; import { DiffLine } from "core"; import { streamDiffLines } from "core/edit/streamDiffLines"; import * as vscode from "vscode"; +import { VsCodeWebviewProtocol } from "../../webviewProtocol"; import { VerticalDiffHandler, VerticalDiffHandlerOptions } from "./handler"; export interface VerticalDiffCodeLens { @@ -22,7 +23,10 @@ export class VerticalDiffManager { private userChangeListener: vscode.Disposable | undefined; - constructor(private readonly configHandler: ConfigHandler) { + constructor( + private readonly configHandler: ConfigHandler, + private readonly webviewProtocol: VsCodeWebviewProtocol, + ) { this.userChangeListener = undefined; } @@ -176,6 +180,7 @@ export class VerticalDiffManager { async streamDiffLines( diffStream: AsyncGenerator, instant: boolean, + streamId: string, ) { vscode.commands.executeCommand("setContext", "continue.diffVisible", true); @@ -205,6 +210,11 @@ export class VerticalDiffManager { endLine, { instant, + onStatusUpdate: (status) => + this.webviewProtocol.request("updateApplyState", { + streamId, + status, + }), }, ); @@ -271,6 +281,7 @@ export class VerticalDiffManager { async streamEdit( input: string, modelTitle: string | undefined, + streamId?: string, onlyOneInsertion?: boolean, quickEdit?: string, range?: vscode.Range, @@ -339,7 +350,15 @@ export class VerticalDiffManager { filepath, startLine, endLine, - { input }, + { + input, + onStatusUpdate: (status) => + streamId && + this.webviewProtocol.request("updateApplyState", { + streamId, + status, + }), + }, ); if (!diffHandler) { diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 68714b106..ce12a0a6b 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -124,7 +124,10 @@ export class VsCodeExtension { resolveConfigHandler?.(this.configHandler); this.configHandler.reloadConfig(); - this.verticalDiffManager = new VerticalDiffManager(this.configHandler); + this.verticalDiffManager = new VerticalDiffManager( + this.configHandler, + this.sidebar.webviewProtocol, + ); resolveVerticalDiffManager?.(this.verticalDiffManager); this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler); diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 0e5b91b88..c0b62fdbc 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -191,10 +191,30 @@ export class VsCodeMessenger { ); const verticalDiffManager = await this.verticalDiffManagerPromise; if (instant) { - verticalDiffManager.streamDiffLines(diffLines, instant); + verticalDiffManager.streamDiffLines( + diffLines, + instant, + msg.data.streamId, + ); } else { const prompt = `The following code was suggested as an edit:\n\`\`\`\n${msg.data.text}\n\`\`\`\nPlease apply it to the previous code.`; - verticalDiffManager.streamEdit(prompt, llm.title); + const fullEditorRange = new vscode.Range( + 0, + 0, + editor.document.lineCount - 1, + editor.document.lineAt(editor.document.lineCount - 1).text.length, + ); + const rangeToApplyTo = editor.selection.isEmpty + ? fullEditorRange + : editor.selection; + verticalDiffManager.streamEdit( + prompt, + llm.title, + msg.data.streamId, + undefined, + undefined, + rangeToApplyTo, + ); } }); diff --git a/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts index 94a68bac7..a96cf5660 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/VerticalPerLineCodeLensProvider.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode"; import { VerticalDiffCodeLens } from "../../../diff/vertical/manager"; -import { getAltOrOption, getMetaKeyLabel } from "../../../util/util"; +import { getMetaKeyLabel } from "../../../util/util"; export class VerticalDiffCodeLensProvider implements vscode.CodeLensProvider { private _eventEmitter: vscode.EventEmitter = @@ -33,9 +33,6 @@ export class VerticalDiffCodeLensProvider implements vscode.CodeLensProvider { const codeLenses: vscode.CodeLens[] = []; for (let i = 0; i < blocks.length; i++) { - const isFirstBlockInMultiBlockDocument = - codeLenses.length === 0 && blocks.length > 1; - const block = blocks[i]; const start = new vscode.Position(block.start, 0); const range = new vscode.Range( @@ -43,43 +40,20 @@ export class VerticalDiffCodeLensProvider implements vscode.CodeLensProvider { start.translate(block.numGreen + block.numRed), ); - if (isFirstBlockInMultiBlockDocument) { - codeLenses.push( - new vscode.CodeLens(range, { - title: `Accept All (${getMetaKeyLabel()}⇧↩)`, - command: "continue.acceptDiff", - arguments: [filepath, i], - }), - new vscode.CodeLens(range, { - title: `Reject All (${getMetaKeyLabel()}⇧⌫)`, - command: "continue.rejectDiff", - arguments: [filepath, i], - }), - ); - } - codeLenses.push( new vscode.CodeLens(range, { - title: `Accept${ - codeLenses.length === 2 - ? ` (${getAltOrOption()}${getMetaKeyLabel()}Y)` - : "" - }`, + title: `Accept`, command: "continue.acceptVerticalDiffBlock", arguments: [filepath, i], }), new vscode.CodeLens(range, { - title: `Reject${ - codeLenses.length === 2 - ? ` (${getAltOrOption()}${getMetaKeyLabel()}N)` - : "" - }`, + title: `Reject`, command: "continue.rejectVerticalDiffBlock", arguments: [filepath, i], }), ); - if (codeLenses.length === 4) { + if (codeLenses.length === 2) { codeLenses.push( new vscode.CodeLens(range, { title: `${getMetaKeyLabel()}I to add instructions`, diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 877d94ad3..0c0b276a8 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -296,6 +296,7 @@ export class QuickEdit { prompt, modelTitle, undefined, + undefined, this.previousInput, this.range, ); diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts index a2f2e3f9f..b71f8e095 100644 --- a/extensions/vscode/src/util/ideUtils.ts +++ b/extensions/vscode/src/util/ideUtils.ts @@ -136,10 +136,30 @@ export class VsCodeIdeUtils { ); } - openFile(filepath: string, range?: vscode.Range) { + private async resolveAbsFilepathInWorkspace( + filepath: string, + ): Promise { + // If the filepath is already absolute, return it as is + if (this.path.isAbsolute(filepath)) { + return filepath; + } + + // Try to resolve for each workspace directory + const workspaceDirectories = this.getWorkspaceDirectories(); + for (const dir of workspaceDirectories) { + const resolvedPath = this.path.resolve(dir, filepath); + if (await this.fileExists(resolvedPath)) { + return resolvedPath; + } + } + + return filepath; + } + + async openFile(filepath: string, range?: vscode.Range) { // vscode has a builtin open/get open files return openEditorAndRevealRange( - filepath, + await this.resolveAbsFilepathInWorkspace(filepath), range, vscode.ViewColumn.One, false, diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 7eda88c9f..30e9d2276 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -2,19 +2,21 @@ import { useContext, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Outlet, useLocation, useNavigate } from "react-router-dom"; import styled from "styled-components"; -import { - CustomScrollbarDiv, - defaultBorderRadius, - vscForeground, - vscInputBackground, -} from "."; +import { CustomScrollbarDiv, defaultBorderRadius, vscInputBackground } from "."; import { IdeMessengerContext } from "../context/IdeMessenger"; import { useWebviewListener } from "../hooks/useWebviewListener"; +import { defaultModelSelector } from "../redux/selectors/modelSelectors"; +import { setShowDialog, updateApplyState } from "../redux/slices/uiStateSlice"; import { RootState } from "../redux/store"; import { getFontSize, isMetaEquivalentKeyPressed } from "../util"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; +import ButtonWithTooltip from "./ButtonWithTooltip"; import TextDialog from "./dialogs"; +import ProgressBar from "./loaders/ProgressBar"; +import { useOnboardingCard } from "./OnboardingCard"; +import { isNewUserOnboarding } from "./OnboardingCard/utils"; import PostHogPageView from "./PosthogPageView"; +import ProfileSwitcher from "./ProfileSwitcher"; import { isNewUserOnboarding } from "./OnboardingCard/utils"; import { useOnboardingCard } from "./OnboardingCard"; import { @@ -22,7 +24,9 @@ import { setBottomMessageCloseTimeout, setShowDialog, } from "../redux/slices/uiStateSlice"; -import Footer from "./Footer"; +import ButtonWithTooltip from "./ButtonWithTooltip"; + +const FOOTER_HEIGHT = "1.8em"; const LayoutTopDiv = styled(CustomScrollbarDiv)` height: 100%; @@ -41,21 +45,20 @@ const LayoutTopDiv = styled(CustomScrollbarDiv)` } `; -const BottomMessageDiv = styled.div<{ displayOnBottom: boolean }>` - position: fixed; - bottom: ${(props) => (props.displayOnBottom ? "50px" : undefined)}; - top: ${(props) => (props.displayOnBottom ? undefined : "50px")}; - left: 0; - right: 0; - margin: 8px; - margin-top: 0; - background-color: ${vscInputBackground}; - color: ${vscForeground}; - border-radius: ${defaultBorderRadius}; - padding: 12px; - z-index: 100; - box-shadow: 0px 0px 2px 0px ${vscForeground}; - max-height: 35vh; +const Footer = styled.footer` + display: flex; + flex-direction: row; + gap: 8px; + justify-content: right; + padding: 8px; + align-items: center; + width: calc(100% - 16px); + height: ${FOOTER_HEIGHT}; + background-color: transparent; + backdrop-filter: blur(12px); + border-top: 1px solid rgba(136, 136, 136, 0.3); + border-bottom: 1px solid rgba(136, 136, 136, 0.3); + overflow: hidden; `; const GridDiv = styled.div` @@ -95,12 +98,7 @@ const Layout = () => { (state: RootState) => state.uiState.showDialog, ); - const bottomMessage = useSelector( - (state: RootState) => state.uiState.bottomMessage, - ); - const displayBottomMessageOnBottom = useSelector( - (state: RootState) => state.uiState.displayBottomMessageOnBottom, - ); + const defaultModel = useSelector(defaultModelSelector); const timeline = useSelector((state: RootState) => state.state.history); @@ -162,6 +160,14 @@ const Layout = () => { [], ); + useWebviewListener( + "updateApplyState", + async (state) => { + dispatch(updateApplyState(state)); + }, + [], + ); + useWebviewListener( "openOnboardingCard", async () => { @@ -215,21 +221,6 @@ const Layout = () => {