aaf2tbz 33b427ed33
feat(ui): improve mobile sidebar and dashboard layout (#67)
* feat(ui): improve mobile sidebar and dashboard layout

- Enlarge compass logo on dashboard page (size-14 idle, size-10 active)
- Reposition logo higher with -mt-16 margin
- Add 6rem spacing between logo and chat
- Remove feedback hover button from bottom right
- Add event-based feedback dialog opening for mobile sidebar
- Remove feedback buttons from site header (mobile and desktop)
- Add mobile theme toggle button to header
- Increase mobile menu hitbox to size-10
- Reduce search hitbox to separate clickable area
- Remove redundant Compass/Get Help/Assistant/Search from sidebar
- Rename "People" to "Team"
- Add mobile-only feedback button to sidebar footer
- Reduce mobile sidebar width to 10rem max-width
- Center sidebar menu icons and labels on mobile
- Clean up mobile-specific padding variants

* chore: add local development setup system

- Create .dev-setup directory with patches and scripts
- Add apply-dev.sh to easily enable local dev without WorkOS
- Add restore-dev.sh to revert to original code
- Document all changes in README.md
- Store cloudflare-context.ts in files/ as new dev-only file
- Support re-apply patches for fresh development sessions

This allows running Compass locally without WorkOS authentication
for development and testing purposes.

---------

Co-authored-by: Avery Felts <averyfelts@Averys-MacBook-Air.local>
2026-02-11 12:49:51 -07:00

105 lines
3.4 KiB
Markdown

# Local Development Setup
This directory contains patches and scripts to enable local development without WorkOS authentication.
## What This Does
These patches modify Compass to run in development mode without requiring WorkOS SSO authentication:
1. **Bypasses WorkOS auth checks** - Middleware redirects `/` to `/dashboard` when WorkOS isn't configured
2. **Mock D1 database** - Returns empty arrays for queries instead of throwing errors
3. **Wraps Cloudflare context** - Returns mock `{ env: { DB: null }, ctx: {} }` when WorkOS isn't configured
4. **Skips OpenNext initialization** - Only runs when WorkOS API keys are properly set
## How to Use
### Quick Start
From the compass directory:
```bash
.dev-setup/apply-dev.sh
```
This will apply all necessary patches to enable local development.
### Manual Application
If the automated script fails, you can apply patches manually:
1. **middleware.ts** - Redirects root to dashboard, allows all requests without auth
2. **lib/auth.ts** - Checks for "your_" and "placeholder" in WorkOS keys
3. **lib/cloudflare-context.ts** - New file that wraps `getCloudflareContext()`
4. **db/index.ts** - Returns mock DB when `d1` parameter is `null`
5. **next.config.ts** - Only initializes OpenNext Cloudflare when WorkOS is configured
6. **.gitignore** - Ignores `src/lib/cloudflare-context.ts` so it's not committed
### Undoing Changes
To remove dev setup and restore original behavior:
```bash
git restore src/middleware.ts
git restore src/lib/auth.ts
git restore src/db/index.ts
git restore next.config.ts
git restore .gitignore
rm src/lib/cloudflare-context.ts
```
## Environment Variables
To configure WorkOS auth properly (to disable dev mode):
```env
WORKOS_API_KEY=sk_dev_xxxxx
WORKOS_CLIENT_ID=client_xxxxx
WORKOS_REDIRECT_URI=http://localhost:3000
```
With these set, the dev patches will automatically skip and use real WorkOS authentication.
## Dev Mode Indicators
When in dev mode (WorkOS not configured):
- Dashboard loads directly without login redirect
- Database queries return empty arrays instead of errors
- Cloudflare context returns null DB instead of throwing
## Files Created/Modified
### New Files (dev only)
- `src/lib/cloudflare-context.ts` - Wraps `getCloudflareContext()` with dev bypass
### Modified Files
- `src/middleware.ts` - Added WorkOS detection and dev bypass
- `src/lib/auth.ts` - Enhanced WorkOS configuration detection
- `src/db/index.ts` - Added mock DB support for null D1 parameter
- `next.config.ts` - Conditional OpenNext initialization
- `.gitignore` - Added `cloudflare-context.ts` to prevent commits
## Future Development
Place any new dev-only components or patches in this directory following the same pattern:
1. **Patch files** - Store in `patches/` with `.patch` extension
2. **New files** - Store in `files/` directory
3. **Update apply-dev.sh** - Add your patches to the apply script
4. **Document here** - Update this README with changes
## Troubleshooting
**Build errors after applying patches:**
- Check that `src/lib/cloudflare-context.ts` exists
- Verify all patches applied cleanly
- Try manual patch application if automated script fails
**Auth still required:**
- Verify `.env.local` or `.dev.vars` doesn't have placeholder values
- Check that WorkOS environment variables aren't set (if you want dev mode)
- Restart dev server after applying patches
**Database errors:**
- Ensure `src/db/index.ts` patch was applied
- Check that mock DB is being returned when `d1` is null