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

feat: diff-view #1246

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4af3ab5
feat: enhance workbench with code comparison
Toddyclipsgg Feb 2, 2025
c43aa9c
Merge branch 'stackblitz-labs:main' into diff-view
Toddyclipsgg Feb 2, 2025
40e09cb
fix: remove unused import in CodeComparison component
Toddyclipsgg Feb 2, 2025
64a5f95
feat: improve file changes tracking and diff view with enhanced histo…
Toddyclipsgg Feb 3, 2025
af444e6
chore: remove unused imports in DiffView and Workbench components
Toddyclipsgg Feb 3, 2025
854bd2f
fix: revert package.json
Toddyclipsgg Feb 3, 2025
de1891f
feat: add side-by-side diff view and enhance diff component flexibility
Toddyclipsgg Feb 6, 2025
5fac72f
feat: add fullscreen and syntax highlighting to diff views
Toddyclipsgg Feb 6, 2025
f0dff04
feat: improve diff view with robust file change detection and error h…
Toddyclipsgg Feb 7, 2025
50d7c43
feat: refactor file history tracking and add NoChangesView component
Toddyclipsgg Feb 8, 2025
7e7fcec
fix: change markdown language detection to plaintext in DiffView
Toddyclipsgg Feb 8, 2025
00bed77
refactor: update FileModifiedDropdown styling and toast notification
Toddyclipsgg Feb 8, 2025
25e636e
feat: add default action runner for BaseChat component
Toddyclipsgg Feb 8, 2025
db4411c
refactor: update action runner handling and module configuration
Toddyclipsgg Feb 8, 2025
d1579c7
refactor: simplify side-by-side diff view layout and remove unnecessa…
Toddyclipsgg Feb 8, 2025
9c9bcae
refactor: extract getLanguageFromExtension to a separate utility module
Toddyclipsgg Feb 8, 2025
71086f2
feat: Add Diff View feature to project roadmap
Toddyclipsgg Feb 8, 2025
eba5585
refactor: simplify file history tracking and remove save count
Toddyclipsgg Feb 10, 2025
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
4 changes: 4 additions & 0 deletions .github/actions/setup-and-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ runs:
run: |
pnpm install
pnpm run build

- name: Create history directory
shell: bash
run: mkdir -p .history
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ project, please check the [project management guide](./PROJECT.md) to get starte
- ✅ Add Starter Template Options (@thecodacus)
- ✅ Perplexity Integration (@meetpateltech)
- ✅ AWS Bedrock Integration (@kunjabijukchhe)
- ✅ Add a "Diff View" to see the changes (@toddyclipsgg)
- ⬜ **HIGH PRIORITY** - Prevent bolt from rewriting files as often (file locking and diffs)
- ⬜ **HIGH PRIORITY** - Better prompting for smaller LLMs (code window sometimes doesn't start)
- ⬜ **HIGH PRIORITY** - Run agents in the backend as opposed to a single model call
Expand Down
13 changes: 12 additions & 1 deletion app/components/chat/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import ChatAlert from './ChatAlert';
import type { ModelInfo } from '~/lib/modules/llm/types';
import ProgressCompilation from './ProgressCompilation';
import type { ProgressAnnotation } from '~/types/context';
import type { ActionRunner } from '~/lib/runtime/action-runner';

const TEXTAREA_MIN_HEIGHT = 76;

Expand Down Expand Up @@ -67,6 +68,7 @@ interface BaseChatProps {
actionAlert?: ActionAlert;
clearAlert?: () => void;
data?: JSONValue[] | undefined;
actionRunner?: ActionRunner;
}

export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
Expand Down Expand Up @@ -101,6 +103,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
actionAlert,
clearAlert,
data,
actionRunner,
},
ref,
) => {
Expand Down Expand Up @@ -602,7 +605,15 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
{!chatStarted && <StarterTemplates />}
</div>
</div>
<ClientOnly>{() => <Workbench chatStarted={chatStarted} isStreaming={isStreaming} />}</ClientOnly>
<ClientOnly>
{() => (
<Workbench
actionRunner={actionRunner ?? ({} as ActionRunner)}
chatStarted={chatStarted}
isStreaming={isStreaming}
/>
)}
</ClientOnly>
</div>
</div>
);
Expand Down
22 changes: 16 additions & 6 deletions app/components/ui/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ interface SliderOption<T> {
text: string;
}

export interface SliderOptions<T> {
left: SliderOption<T>;
right: SliderOption<T>;
}
export type SliderOptions<T> = {
left: { value: T; text: string };
middle?: { value: T; text: string };
right: { value: T; text: string };
};

interface SliderProps<T> {
selected: T;
Expand All @@ -21,14 +22,23 @@ interface SliderProps<T> {
}

export const Slider = genericMemo(<T,>({ selected, options, setSelected }: SliderProps<T>) => {
const isLeftSelected = selected === options.left.value;
const hasMiddle = !!options.middle;
const isLeftSelected = hasMiddle ? selected === options.left.value : selected === options.left.value;
const isMiddleSelected = hasMiddle && options.middle ? selected === options.middle.value : false;

return (
<div className="flex items-center flex-wrap shrink-0 gap-1 bg-bolt-elements-background-depth-1 overflow-hidden rounded-full p-1">
<SliderButton selected={isLeftSelected} setSelected={() => setSelected?.(options.left.value)}>
{options.left.text}
</SliderButton>
<SliderButton selected={!isLeftSelected} setSelected={() => setSelected?.(options.right.value)}>

{options.middle && (
<SliderButton selected={isMiddleSelected} setSelected={() => setSelected?.(options.middle!.value)}>
{options.middle.text}
</SliderButton>
)}

<SliderButton selected={!isLeftSelected && !isMiddleSelected} setSelected={() => setSelected?.(options.right.value)}>
{options.right.text}
</SliderButton>
</div>
Expand Down
Loading