-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into building/more
# Conflicts: # bui/src/islands/Chat.tsx # bui/src/utils/websocketManager.ts # deno.jsonc
- Loading branch information
Showing
26 changed files
with
409 additions
and
282 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,87 @@ | ||
# BBai Browser User Interface (BUI) Development Instructions | ||
|
||
## Overview | ||
The BBai Browser User Interface (BUI) is being developed using Deno Fresh to provide a web-based interface for the BBai project. The BUI aims to offer the same core functionality as the CLI, with a focus on conversation management and interaction with the BBai system. | ||
|
||
The BBai Browser User Interface (BUI) is being developed using Deno Fresh to | ||
provide a web-based interface for the BBai project. The BUI aims to offer the | ||
same core functionality as the CLI, with a focus on conversation management and | ||
interaction with the BBai system. | ||
|
||
## Key Features | ||
|
||
1. WebSocket-based real-time communication with the BBai API | ||
2. Conversation management (start new, continue existing) | ||
3. Chat interface for interacting with BBai | ||
4. Setting and using the current working directory for project context | ||
|
||
## Current Implementation | ||
The main component of the BUI is the `Chat.tsx` file located in `bui/src/islands/Chat.tsx`. This component handles: | ||
|
||
The main component of the BUI is the `Chat.tsx` file located in | ||
`bui/src/islands/Chat.tsx`. This component handles: | ||
|
||
1. WebSocket connection management with retry logic | ||
2. User input for messages and current working directory | ||
3. Displaying conversation history | ||
4. Error handling and display | ||
|
||
## Important Notes | ||
1. The `generateConversationId` function is imported from `shared/conversationManagement.ts`. This import should not be changed without explicit instruction. | ||
2. The `startDir` (current working directory) is crucial for the BBai system and must be sent with each message. | ||
3. A greeting message is sent automatically when the WebSocket connection is established. | ||
|
||
1. The `generateConversationId` function is imported from | ||
`shared/conversationManagement.ts`. This import should not be changed without | ||
explicit instruction. | ||
2. The `startDir` (current working directory) is crucial for the BBai system and | ||
must be sent with each message. | ||
3. A greeting message is sent automatically when the WebSocket connection is | ||
established. | ||
4. The default `startDir` is set to `/Users/cng/working/bbai/`. | ||
5. The WebSocket server is expected to be running on `localhost:3002`. | ||
|
||
## WebSocket Implementation | ||
- The WebSocket connection is established using the browser's native WebSocket API. | ||
- The connection URL is constructed using `localhost:3002` as the host and the generated conversation ID. | ||
- Reconnection attempts use exponential backoff with jitter to avoid overwhelming the server. | ||
|
||
- The WebSocket connection is established using the browser's native WebSocket | ||
API. | ||
- The connection URL is constructed using `localhost:3002` as the host and the | ||
generated conversation ID. | ||
- Reconnection attempts use exponential backoff with jitter to avoid | ||
overwhelming the server. | ||
|
||
## Future Improvements | ||
1. Implement input validation for the `startDir` to ensure it's a valid directory path. | ||
2. Add a visual indicator to show the WebSocket connection status (connected, disconnected, reconnecting). | ||
3. Implement error handling for cases where the server rejects the `startDir` as invalid. | ||
|
||
1. Implement input validation for the `startDir` to ensure it's a valid | ||
directory path. | ||
2. Add a visual indicator to show the WebSocket connection status (connected, | ||
disconnected, reconnecting). | ||
3. Implement error handling for cases where the server rejects the `startDir` as | ||
invalid. | ||
4. Improve the UI/UX of the chat interface. | ||
5. Add more robust error handling or input validation. | ||
6. Implement additional features like conversation history or file uploads. | ||
7. Optimize performance if needed. | ||
|
||
## Testing | ||
|
||
When testing the BUI, focus on: | ||
|
||
1. Setting and using custom working directories. | ||
2. Verifying that the greeting message is sent and received properly. | ||
3. Testing the conversation flow by sending and receiving messages. | ||
4. Checking the reconnection mechanism by intentionally disconnecting. | ||
5. Ensure the WebSocket connection is properly established with the server at `localhost:3002`. | ||
5. Ensure the WebSocket connection is properly established with the server at | ||
`localhost:3002`. | ||
|
||
## Development Guidelines | ||
|
||
1. Maintain consistency in import statements, especially for shared utilities. | ||
2. Ensure all user inputs are properly sanitized and validated. | ||
3. Keep error messages informative and user-friendly. | ||
4. Maintain a responsive and accessible design for various screen sizes. | ||
5. Document any new features or significant changes in this file. | ||
|
||
## API Integration | ||
The BUI communicates with the BBai API primarily through WebSocket connections. Ensure that any changes to the API are reflected in the BUI, particularly in the message structure and handling. | ||
|
||
Remember to update this document as the BUI evolves to keep it as a current and useful reference for ongoing development. | ||
The BUI communicates with the BBai API primarily through WebSocket connections. | ||
Ensure that any changes to the API are reflected in the BUI, particularly in the | ||
message structure and handling. | ||
|
||
Remember to update this document as the BUI evolves to keep it as a current and | ||
useful reference for ongoing development. |
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,32 @@ | ||
{ | ||
"lock": false, | ||
"tasks": { | ||
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx", | ||
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -", | ||
"manifest": "deno task cli manifest $(pwd)/src", | ||
"start": "deno run -A --watch=static/,routes/ src/dev.ts", | ||
"start-prod": "deno run -A src/dev.ts", | ||
"build-site": "deno run -A src/dev.ts build", | ||
"build": "deno compile -A --output ../build/bbai-bui src/main.ts", | ||
"preview": "deno run -A src/main.ts", | ||
"update": "deno run -A -r https://fresh.deno.dev/update .", | ||
"format": "deno fmt", | ||
"check-format": "deno fmt --check", | ||
"check-types": "deno check src/main.ts", | ||
"update-deps": "deno cache src/main.ts && deno cache tests/deps.ts" | ||
}, | ||
"lint": { "rules": { "tags": ["fresh", "recommended"] } }, | ||
"exclude": ["**/src/_fresh/*"], | ||
"importMap": "../import_map.json", | ||
"compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" }, | ||
"fmt": { | ||
"useTabs": true, | ||
"lineWidth": 120, | ||
"indentWidth": 4, | ||
"semiColons": true, | ||
"singleQuote": true, | ||
"proseWrap": "preserve", | ||
"include": ["src/", "tests/"], | ||
"exclude": ["src/testdata/", "src/fixtures/**/*.ts"] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { JSX } from "preact"; | ||
import { IS_BROWSER } from "$fresh/runtime.ts"; | ||
import { JSX } from 'preact'; | ||
import { IS_BROWSER } from '$fresh/runtime.ts'; | ||
|
||
export function Button(props: JSX.HTMLAttributes<HTMLButtonElement>) { | ||
return ( | ||
<button | ||
{...props} | ||
disabled={!IS_BROWSER || props.disabled} | ||
class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors" | ||
/> | ||
); | ||
return ( | ||
<button | ||
{...props} | ||
disabled={!IS_BROWSER || props.disabled} | ||
class='px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors' | ||
/> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/usr/bin/env -S deno run -A --watch=static/,routes/ | ||
|
||
import dev from "$fresh/dev.ts"; | ||
import config from "./fresh.config.ts"; | ||
import dev from '$fresh/dev.ts'; | ||
import config from './fresh.config.ts'; | ||
|
||
import "$std/dotenv/load.ts"; | ||
import '$std/dotenv/load.ts'; | ||
|
||
await dev(import.meta.url, "./main.ts", config); | ||
await dev(import.meta.url, './main.ts', config); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { defineConfig } from "$fresh/server.ts"; | ||
import tailwind from "$fresh/plugins/tailwind.ts"; | ||
import { defineConfig } from '$fresh/server.ts'; | ||
import tailwind from '$fresh/plugins/tailwind.ts'; | ||
|
||
export default defineConfig({ | ||
plugins: [tailwind()], | ||
}); | ||
plugins: [tailwind()], | ||
}); |
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
Oops, something went wrong.