Skip to content

Commit

Permalink
Merge branch 'staging' into building/more
Browse files Browse the repository at this point in the history
# Conflicts:
#	bui/src/islands/Chat.tsx
#	bui/src/utils/websocketManager.ts
#	deno.jsonc
  • Loading branch information
cngarrison committed Sep 3, 2024
2 parents ae26d63 + 266fb80 commit eaa63ac
Show file tree
Hide file tree
Showing 26 changed files with 409 additions and 282 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



## [0.0.10b-alpha] - 2024-09-03

### Changed

- Hotfix for bui


## [0.0.10a-alpha] - 2024-09-03

### Changed

- Hot fix for deno.lock and build command


## [0.0.10-alpha] - 2024-09-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion api/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbai-api",
"version": "0.0.10-alpha",
"version": "0.0.10b-alpha",
"exports": "./src/main.ts",
"tasks": {
"start": "deno run --allow-read --allow-write --allow-run --allow-net --allow-env src/main.ts",
Expand Down
56 changes: 42 additions & 14 deletions bui/BUI_INSTRUCTIONS.md
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.
32 changes: 32 additions & 0 deletions bui/deno.jsonc
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"]
}
}
18 changes: 9 additions & 9 deletions bui/src/components/Button.tsx
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'
/>
);
}
16 changes: 0 additions & 16 deletions bui/src/deno.json

This file was deleted.

18 changes: 0 additions & 18 deletions bui/src/deno.jsonc

This file was deleted.

8 changes: 4 additions & 4 deletions bui/src/dev.ts
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);
8 changes: 4 additions & 4 deletions bui/src/fresh.config.ts
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()],
});
44 changes: 22 additions & 22 deletions bui/src/fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.

import * as $_404 from "./routes/_404.tsx";
import * as $_app from "./routes/_app.tsx";
import * as $_middleware from "./routes/_middleware.ts";
import * as $api_joke from "./routes/api/joke.ts";
import * as $greet_name_ from "./routes/greet/[name].tsx";
import * as $index from "./routes/index.tsx";
import * as $Chat from "./islands/Chat.tsx";
import * as $Counter from "./islands/Counter.tsx";
import { type Manifest } from "$fresh/server.ts";
import * as $_404 from './routes/_404.tsx';
import * as $_app from './routes/_app.tsx';
import * as $_middleware from './routes/_middleware.ts';
import * as $api_joke from './routes/api/joke.ts';
import * as $greet_name_ from './routes/greet/[name].tsx';
import * as $index from './routes/index.tsx';
import * as $Chat from './islands/Chat.tsx';
import * as $Counter from './islands/Counter.tsx';
import { type Manifest } from '$fresh/server.ts';

const manifest = {
routes: {
"./routes/_404.tsx": $_404,
"./routes/_app.tsx": $_app,
"./routes/_middleware.ts": $_middleware,
"./routes/api/joke.ts": $api_joke,
"./routes/greet/[name].tsx": $greet_name_,
"./routes/index.tsx": $index,
},
islands: {
"./islands/Chat.tsx": $Chat,
"./islands/Counter.tsx": $Counter,
},
baseUrl: import.meta.url,
routes: {
'./routes/_404.tsx': $_404,
'./routes/_app.tsx': $_app,
'./routes/_middleware.ts': $_middleware,
'./routes/api/joke.ts': $api_joke,
'./routes/greet/[name].tsx': $greet_name_,
'./routes/index.tsx': $index,
},
islands: {
'./islands/Chat.tsx': $Chat,
'./islands/Counter.tsx': $Counter,
},
baseUrl: import.meta.url,
} satisfies Manifest;

export default manifest;
Loading

0 comments on commit eaa63ac

Please sign in to comment.