-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding stories for tool confirmation & better highlighting of r…
…ules and links
- Loading branch information
1 parent
5c1676a
commit a5e81c3
Showing
5 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ToolConfirmationPauseReason } from "../services/refact"; | ||
|
||
export const CONFIRMATIONAL_PAUSE_REASONS_WITH_PATH: ToolConfirmationPauseReason[] = | ||
[ | ||
{ | ||
command: "SELECT *", | ||
rule: "*", | ||
type: "confirmation", | ||
tool_call_id: "1", | ||
integr_config_path: | ||
"\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", | ||
}, | ||
]; | ||
export const CONFIRMATIONAL_PAUSE_REASONS: ToolConfirmationPauseReason[] = [ | ||
{ | ||
command: "patch", | ||
rule: "default", | ||
type: "confirmation", | ||
tool_call_id: "1", | ||
integr_config_path: null, | ||
}, | ||
]; | ||
|
||
export const DENIAL_PAUSE_REASONS_WITH_PATH: ToolConfirmationPauseReason[] = [ | ||
{ | ||
command: "SELECT *", | ||
rule: "*", | ||
type: "denial", | ||
tool_call_id: "1", | ||
integr_config_path: | ||
"\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", | ||
}, | ||
]; | ||
|
||
export const MIXED_PAUSE_REASONS: ToolConfirmationPauseReason[] = [ | ||
{ | ||
command: "SELECT *", | ||
rule: "*", | ||
type: "denial", | ||
tool_call_id: "1", | ||
integr_config_path: | ||
"\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", | ||
}, | ||
{ | ||
command: "DROP *", | ||
rule: "*", | ||
type: "confirmation", | ||
tool_call_id: "1", | ||
integr_config_path: | ||
"\\\\?\\d:\\work\\refact.ai\\refact-lsp\\.refact\\integrations\\postgres.yaml", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { ToolConfirmation } from "./ToolConfirmation"; | ||
import { Provider } from "react-redux"; | ||
import { setUpStore } from "../../app/store"; | ||
import { Theme } from "../Theme"; | ||
import { ToolConfirmationPauseReason } from "../../services/refact"; | ||
import { AbortControllerProvider } from "../../contexts/AbortControllers"; | ||
import { | ||
CONFIRMATIONAL_PAUSE_REASONS, | ||
CONFIRMATIONAL_PAUSE_REASONS_WITH_PATH, | ||
DENIAL_PAUSE_REASONS_WITH_PATH, | ||
MIXED_PAUSE_REASONS, | ||
} from "../../__fixtures__/confirmation"; | ||
|
||
const MockedStore: React.FC<{ | ||
pauseReasons: ToolConfirmationPauseReason[]; | ||
}> = ({ pauseReasons }) => { | ||
const store = setUpStore({ | ||
confirmation: { | ||
pauseReasons, | ||
pause: true, | ||
status: { | ||
wasInteracted: false, | ||
confirmationStatus: false, | ||
}, | ||
}, | ||
}); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<AbortControllerProvider> | ||
<Theme accentColor="gray"> | ||
<ToolConfirmation pauseReasons={pauseReasons} /> | ||
</Theme> | ||
</AbortControllerProvider> | ||
</Provider> | ||
); | ||
}; | ||
|
||
const meta: Meta<typeof MockedStore> = { | ||
title: "ToolConfirmation", | ||
component: MockedStore, | ||
args: { | ||
pauseReasons: [], | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
pauseReasons: CONFIRMATIONAL_PAUSE_REASONS_WITH_PATH, | ||
}, | ||
}; | ||
|
||
export const WithDenial: Story = { | ||
args: { | ||
pauseReasons: DENIAL_PAUSE_REASONS_WITH_PATH, | ||
}, | ||
}; | ||
|
||
export const Patch: Story = { | ||
args: { | ||
pauseReasons: CONFIRMATIONAL_PAUSE_REASONS, | ||
}, | ||
}; | ||
|
||
export const Mixed: Story = { | ||
args: { | ||
pauseReasons: MIXED_PAUSE_REASONS, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters