Get tsc passing (vibe-kanban) (#193)

* Great! I've successfully fixed the TypeScript compilation issues. Here's what was done:

1. **Added missing `DirectoryListResponse` type**: Added `vibe_kanban::routes::filesystem::DirectoryListResponse::decl()` to the [`generate_types.rs`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vibe-kanban/vk-049a-get-tsc-pa/backend/src/bin/generate_types.rs) file

2. **Regenerated types**: Ran `npm run generate-types` to regenerate the [`shared/types.ts`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vibe-kanban/vk-049a-get-tsc-pa/shared/types.ts) file

3. **Added frontend-specific types**: Added the missing frontend-specific types that were being used but not generated from the backend:
   - `AttemptData`
   - `StartGitHubDeviceFlowType` 
   - `ProcessedLine`
   - `ProcessedSection`

4. **Verified fix**: The command `cd frontend && npx tsc --noEmit` now passes successfully.

The TypeScript compilation is now working properly with all types synchronized between the backend and frontend.

* Excellent! I've successfully fixed the TypeScript compilation issues by properly synchronizing the shared types between the Rust backend and TypeScript frontend. 

**Summary of what was completed:**

1. **Added missing `DirectoryListResponse` to generate_types.rs** - This was a backend struct that was missing from the type generation.

2. **Created missing backend structs** with proper TS export annotations:
   - `AttemptData` - Combined activities, processes, and running process details
   - `StartGitHubDeviceFlowType` - GitHub OAuth device flow response
   - `ProcessedLine` - Represents processed diff lines with chunk type and line numbers
   - `ProcessedSection` - Represents sections of processed diff content

3. **Added proper serde renaming** - Used `#[serde(rename = "...")]` to convert Rust snake_case field names to TypeScript camelCase conventions.

4. **Fixed frontend code** - Updated the TypeScript code to provide required null fields when creating ProcessedLine and ProcessedSection objects.

5. **Updated generate_types.rs** - Added all the new structs to the type generation script.

The command `cd frontend && npx tsc --noEmit` now passes successfully, and the types are properly synchronized between backend and frontend. All types are now generated from the Rust backend code rather than being manually maintained in the shared/types.ts file.

* Excellent! I've successfully fixed the TypeScript compilation issues properly this time. Here's what was accomplished:

## Summary of changes:

1. **Removed frontend-only types from backend** - Removed `AttemptData`, `ProcessedLine`, and `ProcessedSection` from the backend since they were only used in the frontend.

2. **Eliminated duplicate types** - Removed the duplicate `StartGitHubDeviceFlowType` and instead made the existing `DeviceStartResponse` exportable to TypeScript with proper type conversion.

3. **Created frontend-only types file** - Created [`frontend/src/types/frontend-only.ts`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vibe-kanban/vk-049a-get-tsc-pa/frontend/src/types/frontend-only.ts) to house types that are only used in the frontend.

4. **Updated imports** - Updated all frontend components to import the frontend-only types from the new location instead of from shared types.

5. **Fixed type generation** - Updated [`backend/src/bin/generate_types.rs`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vibe-kanban/vk-049a-get-tsc-pa/backend/src/bin/generate_types.rs) to only export `DeviceStartResponse` instead of the duplicated and frontend-only types.

The command `cd frontend && npx tsc --noEmit` now passes successfully, and the types are properly organized:
- **Backend types** are generated from Rust and shared via `shared/types.ts`
- **Frontend-only types** are maintained in `frontend/src/types/frontend-only.ts`
- **No duplicates** exist between backend and frontend types

This approach ensures that `npm run generate-types` can be run periodically without overwriting manually maintained types, while still maintaining proper type safety across the entire application.

* Excellent! You were absolutely right. The types are now much better organized and co-located with their usage:

## Summary of the improved organization:

1. **`ProcessedLine` and `ProcessedSection`** - Now defined in [`DiffFile.tsx`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vibe-kanban/vk-049a-get-tsc-pa/frontend/src/components/tasks/TaskDetails/DiffFile.tsx) where they're primarily used for diff processing
2. **`AttemptData`** - Now defined in [`taskDetailsContext.ts`](file:///private/var/folders/kr/jdxkcn7129j376nrg0stj9zm0000gn/T/vibe-kanban/vk-049a-get-tsc-pa/frontend/src/components/context/taskDetailsContext.ts) where it's used for task attempt data management
3. **No separate types directory** - Eliminated the unnecessary `frontend/src/types/frontend-only.ts` file

The types are now:
- **Co-located** with their usage
- **Easier to maintain** since they're close to the code that uses them
- **Still properly typed** and exported for use by other components that need them

The command `cd frontend && npx tsc --noEmit` continues to pass, and the shared types from the backend remain properly managed through the generate-types process. This is a much cleaner organization that follows the principle of keeping related code together.

* prettier
This commit is contained in:
Louis Knight-Webb
2025-07-15 16:59:38 +01:00
committed by GitHub
parent fc0ede7538
commit 5697cead32
9 changed files with 110 additions and 88 deletions

View File

@@ -70,29 +70,10 @@ export type TaskAttemptActivityWithPrompt = { id: string, execution_process_id:
export type CreateTaskAttemptActivity = { execution_process_id: string, status: TaskAttemptStatus | null, note: string | null, };
export type AttemptData = {
activities: TaskAttemptActivityWithPrompt[];
processes: ExecutionProcessSummary[];
runningProcessDetails: Record<string, ExecutionProcess>;
}
export interface ProcessedLine {
content: string;
chunkType: DiffChunkType;
oldLineNumber?: number;
newLineNumber?: number;
}
export interface ProcessedSection {
type: 'context' | 'change' | 'expanded';
lines: ProcessedLine[];
expandKey?: string;
expandedAbove?: boolean;
expandedBelow?: boolean;
}
export type DirectoryEntry = { name: string, path: string, is_directory: boolean, is_git_repo: boolean, };
export type DirectoryListResponse = { entries: Array<DirectoryEntry>, current_path: string, };
export type DiffChunkType = "Equal" | "Insert" | "Delete";
export type DiffChunk = { chunk_type: DiffChunkType, content: string, };
@@ -133,65 +114,59 @@ export type NormalizedEntryType = { "type": "user_message" } | { "type": "assist
export type ActionType = { "action": "file_read", path: string, } | { "action": "file_write", path: string, } | { "action": "command_run", command: string, } | { "action": "search", query: string, } | { "action": "web_fetch", url: string, } | { "action": "task_create", description: string, } | { "action": "other", description: string, };
export type StartGitHubDeviceFlowType = {
device_code: string;
user_code: string;
verification_uri: string;
expires_in: number;
interval: number;
};
export type DeviceStartResponse = { device_code: string, user_code: string, verification_uri: string, expires_in: number, interval: number, };
// Generated constants
export const EXECUTOR_TYPES: string[] = [
"echo",
"claude",
"amp",
"gemini",
"charmopencode"
"echo",
"claude",
"amp",
"gemini",
"charmopencode"
];
export const EDITOR_TYPES: EditorType[] = [
"vscode",
"cursor",
"windsurf",
"intellij",
"zed",
"custom"
"vscode",
"cursor",
"windsurf",
"intellij",
"zed",
"custom"
];
export const EXECUTOR_LABELS: Record<string, string> = {
"echo": "Echo (Test Mode)",
"claude": "Claude",
"amp": "Amp",
"gemini": "Gemini",
"charmopencode": "Charm Opencode"
"echo": "Echo (Test Mode)",
"claude": "Claude",
"amp": "Amp",
"gemini": "Gemini",
"charmopencode": "Charm Opencode"
};
export const EDITOR_LABELS: Record<string, string> = {
"vscode": "VS Code",
"cursor": "Cursor",
"windsurf": "Windsurf",
"intellij": "IntelliJ IDEA",
"zed": "Zed",
"custom": "Custom"
"vscode": "VS Code",
"cursor": "Cursor",
"windsurf": "Windsurf",
"intellij": "IntelliJ IDEA",
"zed": "Zed",
"custom": "Custom"
};
export const SOUND_FILES: SoundFile[] = [
"abstract-sound1",
"abstract-sound2",
"abstract-sound3",
"abstract-sound4",
"cow-mooing",
"phone-vibration",
"rooster"
"abstract-sound1",
"abstract-sound2",
"abstract-sound3",
"abstract-sound4",
"cow-mooing",
"phone-vibration",
"rooster"
];
export const SOUND_LABELS: Record<string, string> = {
"abstract-sound1": "Gentle Chime",
"abstract-sound2": "Soft Bell",
"abstract-sound3": "Digital Tone",
"abstract-sound4": "Subtle Alert",
"cow-mooing": "Cow Mooing",
"phone-vibration": "Phone Vibration",
"rooster": "Rooster Call"
};
"abstract-sound1": "Gentle Chime",
"abstract-sound2": "Soft Bell",
"abstract-sound3": "Digital Tone",
"abstract-sound4": "Subtle Alert",
"cow-mooing": "Cow Mooing",
"phone-vibration": "Phone Vibration",
"rooster": "Rooster Call"
};