Skip to content

Commit

Permalink
fix: imports and typing
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 committed Jan 18, 2024
1 parent a0fda99 commit aacece4
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { ModelResponse } from '@shared/src/models/IModelResponse';

import path from 'node:path';
import * as http from 'node:http';
import { getFreePort } from './utils/ports';
import { getFreePort } from '../utils/ports';
import type { QueryState } from '@shared/src/models/IPlaygroundQueryState';
import { MSG_NEW_PLAYGROUND_QUERIES_STATE } from '@shared/Messages';

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/studio-api-impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import userContent from './ai-user-test.json';
import type { ApplicationManager } from './managers/applicationManager';
import type { RecipeStatusRegistry } from './registries/RecipeStatusRegistry';
import { StudioApiImpl } from './studio-api-impl';
import type { PlayGroundManager } from './playground';
import type { PlayGroundManager } from './managers/playground';
import type { TaskRegistry } from './registries/TaskRegistry';

import * as fs from 'node:fs';
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { RecipeStatus } from '@shared/src/models/IRecipeStatus';
import type { ModelInfo } from '@shared/src/models/IModelInfo';
import type { TaskRegistry } from './registries/TaskRegistry';
import type { Task } from '@shared/src/models/ITask';
import type { PlayGroundManager } from './playground';
import type { PlayGroundManager } from './managers/playground';
import * as podmanDesktopApi from '@podman-desktop/api';
import type { QueryState } from '@shared/src/models/IPlaygroundQueryState';
import type { Catalog } from '@shared/src/models/ICatalog';
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import type { ExtensionContext, WebviewOptions, WebviewPanel } from '@podman-desktop/api';
import { Uri, window } from '@podman-desktop/api';
import { RpcExtension } from '@shared/src/MessageProxy';
import { RpcExtension } from '@shared/src/messages/MessageProxy';
import { StudioApiImpl } from './studio-api-impl';
import { ApplicationManager } from './managers/applicationManager';
import { GitManager } from './managers/gitManager';
import { RecipeStatusRegistry } from './registries/RecipeStatusRegistry';

import * as fs from 'node:fs';
import { TaskRegistry } from './registries/TaskRegistry';
import { PlayGroundManager } from './playground';
import { PlayGroundManager } from './managers/playground';

export class Studio {
readonly #extensionContext: ExtensionContext;
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/ModelPlayground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
result = undefined;
// do not display anything before we get a response from askPlayground
// (we can receive a new queryState before the new QueryId)
queryId = -1;
queryId = -1;
queryId = await studioClient.askPlayground(model.id, prompt);
}
</script>
Expand All @@ -73,8 +73,8 @@
rows="4"
class="w-full p-2 outline-none text-sm bg-charcoal-800 rounded-sm text-gray-700 placeholder-gray-700"
placeholder="Type your prompt here"></textarea>
<div class="mt-4 text-right">

<div class="mt-4 text-right">
<Button inProgress={inProgress} on:click={() => askPlayground()}>Send Request</Button>
</div>

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/utils/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StudioAPI } from '@shared/src/StudioAPI';
import { RpcBrowser } from '@shared/src/MessageProxy';
import { RpcBrowser } from '@shared/src/messages/MessageProxy';

export const RECENT_CATEGORY_ID = 'recent-category';
const podmanDesktopApi = acquirePodmanDesktopApi();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { test, expect, beforeAll } from 'vitest';
import { RpcBrowser, RpcExtension } from './MessageProxy';
import type { PodmanDesktopApi } from '../../../types/podman-desktop-api';
import type { Webview } from '@podman-desktop/api';

let webview: Webview;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
***********************************************************************/
/* eslint-disable @typescript-eslint/no-explicit-any */

import type { PodmanDesktopApi } from '../../../types/podman-desktop-api';
import type { Webview } from '@podman-desktop/api';

export interface IMessage {
Expand All @@ -40,6 +39,8 @@ export interface ISubscribedMessage {
body: any;
}

type UnaryRPC = (...args: unknown[]) => Promise<unknown>;

export function isMessageRequest(content: unknown): content is IMessageRequest {
return (
content !== undefined && content !== null && typeof content === 'object' && 'id' in content && 'channel' in content
Expand Down Expand Up @@ -90,7 +91,7 @@ export class RpcExtension {
});
}

registerInstance<T>(classType: { new (...args: any[]): T }, instance: T) {
registerInstance<T extends Record<keyof T, UnaryRPC>>(classType: { new (...args: any[]): T }, instance: T) {
const methodNames = Object.getOwnPropertyNames(classType.prototype).filter(
name => name !== 'constructor' && typeof instance[name as keyof T] === 'function',
);
Expand Down Expand Up @@ -156,8 +157,7 @@ export class RpcBrowser {
getProxy<T>(): T {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const thisRef = this;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const proxyHandler: ProxyHandler<any> = {
const proxyHandler: ProxyHandler<object> = {
get(target, prop, receiver) {
if (typeof prop === 'string') {
return (...args: unknown[]) => {
Expand Down

0 comments on commit aacece4

Please sign in to comment.