diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index f629f9331..ccc9e8a44 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -1,7 +1,7 @@ name: PR checks on: - pull_request: + pull_request_target: branches: - main paths: @@ -22,10 +22,22 @@ on: - ".github/workflows/**" jobs: + validate-pr: + runs-on: ubuntu-latest + environment: tests-requiring-secrets + steps: + - uses: actions/checkout@v4 + install-root: + needs: validate-pr runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -45,6 +57,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -70,8 +86,13 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest + environment: tests-requiring-secrets steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -97,10 +118,14 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} install-gui: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -132,6 +157,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -158,10 +187,14 @@ jobs: npx tsc --noEmit binary-checks: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -194,10 +227,14 @@ jobs: npx tsc --noEmit install-vscode: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -231,6 +268,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -262,6 +303,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -283,11 +328,14 @@ jobs: vscode-get-test-file-matrix: runs-on: ubuntu-latest - needs: [ install-root, install-vscode ] + needs: [install-root, install-vscode] outputs: test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Cache node modules uses: actions/cache@v3 @@ -312,9 +360,13 @@ jobs: vscode-package-extension: runs-on: ubuntu-latest - needs: [ install-vscode, install-core ] + needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -344,9 +396,13 @@ jobs: vscode-download-e2e-dependencies: runs-on: ubuntu-latest - needs: [ install-vscode, install-core ] + needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -386,13 +442,19 @@ jobs: install-core, ] runs-on: ubuntu-latest + # Tests requiring secrets need approval from maintainers + environment: tests-requiring-secrets strategy: fail-fast: false matrix: test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }} - command: [ "e2e:ci:run", "e2e:ci:run-yaml" ] + command: ["e2e:ci:run", "e2e:ci:run-yaml"] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -451,10 +513,14 @@ jobs: path: extensions/vscode/e2e/storage/screenshots gui-tests: - needs: [ install-gui, install-core ] + needs: [install-gui, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -482,10 +548,13 @@ jobs: npm test jetbrains-tests: - needs: [ install-root, core-checks ] + needs: [install-root, core-checks] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/cache@v4 with: @@ -578,4 +647,35 @@ jobs: with: name: jb-failure-report path: | - ${{ github.workspace }}/extensions/intellij/build/reports \ No newline at end of file + ${{ github.workspace }}/extensions/intellij/build/reports + + # GitHub does not have a way of requiring that all checks pass (you must manually select each job) + # This action at least lets us manage the list of required tests via source control + # so that creators of new jobs can add them to this list + require-all-checks-to-pass: + if: always() + runs-on: ubuntu-latest + needs: + - install-root + - install-core + - core-checks + - install-gui + - gui-checks + - binary-checks + - install-vscode + - vscode-checks + - core-tests + - vscode-get-test-file-matrix + - vscode-package-extension + - vscode-download-e2e-dependencies + - vscode-e2e-tests + - gui-tests + - jetbrains-tests + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + allowed-failures: + allowed-skips: + jobs: ${{ toJSON(needs) }} diff --git a/core/index.d.ts b/core/index.d.ts index b5a4f40ef..f65c10622 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -433,6 +433,13 @@ interface ToolCallState { output?: ContextItem[]; } +interface Reasoning { + active: boolean; + text: string; + startAt: number; + endAt?: number; +} + export interface ChatHistoryItem { message: ChatMessage; contextItems: ContextItemWithId[]; @@ -443,6 +450,7 @@ export interface ChatHistoryItem { isGatheringContext?: boolean; checkpoint?: Checkpoint; isBeforeCheckpoint?: boolean; + reasoning?: Reasoning; } export interface LLMFullCompletionOptions extends BaseCompletionOptions { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3fa74f274..3149ab142 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.257", + "version": "0.9.255", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.257", + "version": "0.9.255", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index bd24737a5..257b6a4d4 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.257", + "version": "0.9.258", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/gui/src/components/StepContainer/Reasoning.tsx b/gui/src/components/StepContainer/Reasoning.tsx new file mode 100644 index 000000000..d5537c82b --- /dev/null +++ b/gui/src/components/StepContainer/Reasoning.tsx @@ -0,0 +1,138 @@ +import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/solid"; +import { ChatHistoryItem } from "core"; +import { stripImages } from "core/util/messageContent"; +import { useEffect, useState } from "react"; +import styled from "styled-components"; +import { + defaultBorderRadius, + lightGray, + vscBackground, + vscQuickInputBackground, +} from ".."; +import { getFontSize } from "../../util"; +import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; + +interface ReasoningProps { + item: ChatHistoryItem; + index: number; + isLast: boolean; +} + +const SpoilerButton = styled.div` + margin: 8px 6px 16px 6px; + background-color: ${vscBackground}; + width: fit-content; + font-size: ${getFontSize() - 2}px; + border: 0.5px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + padding: 4px 8px; + color: ${lightGray}; + cursor: pointer; + box-shadow: + 0 4px 6px rgba(0, 0, 0, 0.1), + 0 1px 3px rgba(0, 0, 0, 0.08); + transition: box-shadow 0.3s ease; + + &:hover { + box-shadow: + 0 6px 8px rgba(0, 0, 0, 0.15), + 0 3px 6px rgba(0, 0, 0, 0.1); + } +`; + +const ButtonContent = styled.div` + display: flex; + align-items: center; + gap: 6px; +`; + +const ContentDiv = styled.div<{ fontSize?: number }>` + margin: 4px; + padding: 4px; + padding-bottom: 8px; + font-size: ${getFontSize()}px; + overflow: hidden; + border-left: 4px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + background-color: ${vscQuickInputBackground}; +`; + +const ThinkingText = styled.span` + position: relative; + padding-right: 12px; + + &:after { + content: "..."; + position: absolute; + animation: ellipsis 1s steps(4, end) infinite; + width: 0px; + display: inline-block; + overflow: hidden; + } + + @keyframes ellipsis { + 0%, + 100% { + width: 0px; + } + 33% { + width: 8px; + } + 66% { + width: 16px; + } + 90% { + width: 24px; + } + } +`; + +export default function Reasoning(props: ReasoningProps) { + const [open, setOpen] = useState(false); + const [reasoningTime, setReasoningTime] = useState(""); + const isThinking = !props.item.reasoning?.endAt; + + useEffect(() => { + if (!props.item.reasoning) return; + if (!props.item.reasoning?.endAt) return; + + const startAt = props.item.reasoning?.startAt || Date.now(); + const endAt = props.item.reasoning?.endAt || Date.now(); + const diff = endAt - startAt; + const diffString = `${(diff / 1000).toFixed(1)}s`; + setReasoningTime(diffString); + }, [props.item.reasoning?.startAt, props.item.reasoning?.endAt]); + + if (!props.item.reasoning?.text) { + return null; + } + + return ( + <> + setOpen(!open)}> + + {isThinking ? ( + Thinking + ) : ( + `Thought for ${reasoningTime}` + )} + {open ? ( + + ) : ( + + )} + + + {open && ( + + + + )} + + ); +} diff --git a/gui/src/components/StepContainer/StepContainer.tsx b/gui/src/components/StepContainer/StepContainer.tsx index 5709f7f60..b395db076 100644 --- a/gui/src/components/StepContainer/StepContainer.tsx +++ b/gui/src/components/StepContainer/StepContainer.tsx @@ -11,6 +11,7 @@ import { getFontSize } from "../../util"; import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; import ResponseActions from "./ResponseActions"; import ThinkingIndicator from "./ThinkingIndicator"; +import Reasoning from "./Reasoning"; interface StepContainerProps { item: ChatHistoryItem; @@ -90,11 +91,15 @@ export default function StepContainer(props: StepContainerProps) { {renderChatMessage(props.item.message)} ) : ( - + <> + + + + )} {props.isLast && } diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 52d343fe4..931c8c045 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -34,6 +34,7 @@ import { remarkTables } from "./utils/remarkTables"; const StyledMarkdown = styled.div<{ fontSize?: number; whiteSpace: string; + bgColor: string; }>` pre { white-space: ${(props) => props.whiteSpace}; @@ -63,7 +64,7 @@ const StyledMarkdown = styled.div<{ color: #f78383; } - background-color: ${vscBackground}; + background-color: ${(props) => props.bgColor}; font-family: var(--vscode-font-family), system-ui, @@ -104,6 +105,7 @@ interface StyledMarkdownPreviewProps { isRenderingInStepContainer?: boolean; // Currently only used to control the rendering of codeblocks scrollLocked?: boolean; itemIndex?: number; + useParentBackgroundColor?: boolean; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -332,7 +334,11 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( const uiConfig = useAppSelector(selectUIConfig); const codeWrapState = uiConfig?.codeWrap ? "pre-wrap" : "pre"; return ( - + {reactContent} ); diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 33ba33f59..2ece67b85 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -362,9 +362,26 @@ export const sessionSlice = createSlice({ } else { // Add to the existing message if (message.content) { - // Note this only works because new message above - // was already rendered from parts to string - lastMessage.content += renderChatMessage(message); + const messageContent = renderChatMessage(message); + if (messageContent.includes("")) { + lastItem.reasoning = { + startAt: Date.now(), + active: true, + text: messageContent.replace("", "").trim(), + } + } else if (lastItem.reasoning?.active && messageContent.includes("")) { + const [reasoningEnd, answerStart] = messageContent.split(""); + lastItem.reasoning.text += reasoningEnd.trimEnd(); + lastItem.reasoning.active = false; + lastItem.reasoning.endAt = Date.now(); + lastMessage.content += answerStart.trimStart(); + } else if (lastItem.reasoning?.active) { + lastItem.reasoning.text += messageContent; + } else { + // Note this only works because new message above + // was already rendered from parts to string + lastMessage.content += messageContent; + } } else if ( message.role === "assistant" && message.toolCalls?.[0] &&