Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.1",
"@types/debug": "^4.1.12",
"@types/diff": "^7.0.1",
"@types/js-cookie": "^3.0.6",
"@types/lodash.groupby": "^4.6.9",
"@types/lodash.isequal": "^4.5.8",
Expand All @@ -86,6 +87,7 @@
"@vitest/coverage-v8": "^1.1.0",
"@vitest/ui": "^1.1.0",
"classnames": "^2.3.2",
"diff": "^7.0.0",
"echarts": "^5.4.3",
"echarts-for-react": "^3.0.2",
"eslint": "^8.55.0",
Expand Down
1,104 changes: 1,104 additions & 0 deletions src/__fixtures__/chat_textdoc.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from "./integrations";
export * from "./survey_questions";
export * from "./chat_links_response";
export * from "./chat_config_thread";
export * from "./chat_textdoc";
13 changes: 13 additions & 0 deletions src/__fixtures__/msw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { STUB_SUB_RESPONSE, STUB_SUB_RESPONSE_WITH_STATUS } from "./knowledge";
import { GoodPollingResponse } from "../services/smallcloud";
import type { LinksForChatResponse } from "../services/refact/links";
import { CompressTrajectoryResponse } from "../services/refact/knowledge";
import { ToolConfirmationResponse } from "../services/refact";

export const goodPing: HttpHandler = http.get(
"http://127.0.0.1:8001/v1/ping",
Expand Down Expand Up @@ -287,3 +288,15 @@ export const telemetryNetwork = http.post(
});
},
);

export const ToolConfirmation = http.post(
"http://127.0.0.1:8001/v1/tools-check-if-confirmation-needed",
() => {
const response: ToolConfirmationResponse = {
pause: false,
pause_reasons: [],
};

return HttpResponse.json(response);
},
);
120 changes: 0 additions & 120 deletions src/__tests__/PinMessages.test.tsx

This file was deleted.

45 changes: 0 additions & 45 deletions src/app/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { promptsApi } from "../services/refact/prompts";
import { toolsApi } from "../services/refact/tools";
import { commandsApi, isDetailMessage } from "../services/refact/commands";
import { pathApi } from "../services/refact/path";
import { diffApi } from "../services/refact/diffs";
import { pingApi } from "../services/refact/ping";
import {
clearError,
Expand Down Expand Up @@ -66,7 +65,6 @@ startListening({
// promptsApi.util.resetApiState(),
toolsApi.util.resetApiState(),
commandsApi.util.resetApiState(),
diffApi.util.resetApiState(),
resetAttachedImagesSlice(),
resetConfirmationInteractedState(),
].forEach((api) => listenerApi.dispatch(api));
Expand Down Expand Up @@ -314,19 +312,6 @@ startListening({
) {
listenerApi.dispatch(setError(action.payload));
}

if (diffApi.endpoints.applyAllPatchesInMessages.matchRejected(action)) {
const errorStatus = action.payload?.status;
const isAuthError = errorStatus === 401;
const message = isAuthError
? AUTH_ERROR_MESSAGE
: isDetailMessage(action.payload?.data)
? action.payload.data.detail
: `Failed to apply diffs: ${action.payload?.status}`;

listenerApi.dispatch(setError(message));
listenerApi.dispatch(setIsAuthError(isAuthError));
}
},
});

Expand Down Expand Up @@ -404,8 +389,6 @@ startListening({
matcher: isAnyOf(
chatAskQuestionThunk.rejected.match,
chatAskQuestionThunk.fulfilled.match,
diffApi.endpoints.patchSingleFileFromTicket.matchFulfilled,
diffApi.endpoints.patchSingleFileFromTicket.matchRejected,
// give files api
pathApi.endpoints.getFullPath.matchFulfilled,
pathApi.endpoints.getFullPath.matchRejected,
Expand Down Expand Up @@ -458,34 +441,6 @@ startListening({
void listenerApi.dispatch(thunk);
}

if (diffApi.endpoints.patchSingleFileFromTicket.matchFulfilled(action)) {
const success = !action.payload.results.every(
(result) => result.already_applied,
);
const thunk = telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
scope: "handleShow",
success: success,
error_message: success
? ""
: "Already applied, no significant changes generated.",
});

void listenerApi.dispatch(thunk);
}

if (
diffApi.endpoints.patchSingleFileFromTicket.matchRejected(action) &&
!action.meta.condition
) {
const thunk = telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
scope: "handleShow",
success: false,
error_message: action.error.message ?? JSON.stringify(action.error),
});

void listenerApi.dispatch(thunk);
}

if (pathApi.endpoints.getFullPath.matchFulfilled(action)) {
const thunk = telemetryApi.endpoints.sendTelemetryNetEvent.initiate({
url: FULL_PATH_URL,
Expand Down
3 changes: 0 additions & 3 deletions src/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
promptsApi,
toolsApi,
commandsApi,
diffApi,
pathApi,
pingApi,
integrationsApi,
Expand Down Expand Up @@ -94,7 +93,6 @@ const rootReducer = combineSlices(
[promptsApi.reducerPath]: promptsApi.reducer,
[toolsApi.reducerPath]: toolsApi.reducer,
[commandsApi.reducerPath]: commandsApi.reducer,
[diffApi.reducerPath]: diffApi.reducer,
[smallCloudApi.reducerPath]: smallCloudApi.reducer,
[pathApi.reducerPath]: pathApi.reducer,
[pingApi.reducerPath]: pingApi.reducer,
Expand Down Expand Up @@ -180,7 +178,6 @@ export function setUpStore(preloadedState?: Partial<RootState>) {
promptsApi.middleware,
toolsApi.middleware,
commandsApi.middleware,
diffApi.middleware,
smallCloudApi.middleware,
pathApi.middleware,
linksApi.middleware,
Expand Down
4 changes: 4 additions & 0 deletions src/components/Callout/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const Callout: React.FC<CalloutProps> = ({
type = "info",
timeout = null,
onClick = () => void 0,
preventRetry = false,
...props
}) => {
const [isOpened, setIsOpened] = useState(false);
Expand All @@ -47,6 +48,8 @@ export const Callout: React.FC<CalloutProps> = ({
}, []);

const handleRetryClick = () => {
// TBD: why was this added, it won't close on click :/?
if (preventRetry) return;
setIsOpened(false);
const timeoutId = setTimeout(() => {
onClick();
Expand Down Expand Up @@ -84,6 +87,7 @@ export const Callout: React.FC<CalloutProps> = ({
);
};

// TODO: Authcall out should not be generic ErrorCallout
export const ErrorCallout: React.FC<Omit<CalloutProps, "type">> = ({
timeout = null,
onClick,
Expand Down
34 changes: 34 additions & 0 deletions src/components/ChatContent/ChatContent.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@ import {
CHAT_WITH_MULTI_MODAL,
CHAT_CONFIG_THREAD,
STUB_LINKS_FOR_CHAT_RESPONSE,
CHAT_WITH_TEXTDOC,
} from "../../__fixtures__";
import { http, HttpResponse } from "msw";
import { CHAT_LINKS_URL } from "../../services/refact/consts";
import {
goodCaps,
goodPing,
goodPrompts,
goodUser,
makeKnowledgeFromChat,
noCommandPreview,
noCompletions,
noTools,
ToolConfirmation,
} from "../../__fixtures__/msw";

const MockedStore: React.FC<{
messages?: ChatMessages;
Expand Down Expand Up @@ -145,3 +157,25 @@ export const IntegrationChat: Story = {
},
},
};

export const TextDoc: Story = {
args: {
thread: CHAT_WITH_TEXTDOC,
},
parameters: {
msw: {
handlers: [
goodCaps,
goodPing,
goodPrompts,
goodUser,
// noChatLinks,
noTools,
makeKnowledgeFromChat,
ToolConfirmation,
noCompletions,
noCommandPreview,
],
},
},
};
Loading