Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ddfa66d9b | ||
|
|
1566a67da4 | ||
|
|
6ff25096d4 | ||
|
|
222b27c8c8 | ||
|
|
43fec2a462 | ||
|
|
a9e3e81195 | ||
|
|
b270651a9c | ||
|
|
5b302cc40b | ||
|
|
3db9848497 | ||
|
|
b0e85aaa60 | ||
|
|
9390ae4152 | ||
|
|
7ecab519ed | ||
|
|
85afb6828e | ||
|
|
d4d6ff0d89 | ||
|
|
f29510ed00 | ||
|
|
62f6bd439e | ||
|
|
37c19be7ee | ||
|
|
b7ce705b2b | ||
|
|
380e6f3b84 | ||
|
|
ed55e600d4 | ||
|
|
ed40469af4 | ||
|
|
049ad5bd04 | ||
|
|
34bfbb971b | ||
|
|
2641252c6a | ||
|
|
d6e8b9bc84 | ||
|
|
113fc0a326 | ||
|
|
ee240cdfda | ||
|
|
9e29153a95 | ||
|
|
a8c19bd0ad | ||
|
|
4f103d6ad4 | ||
|
|
d51fee34e3 | ||
|
|
c5ed881af0 | ||
|
|
459311bd7b | ||
|
|
119b28d0f5 | ||
|
|
3741782c62 | ||
|
|
50bc875423 | ||
|
|
9c2984f69f | ||
|
|
a5c293bcc9 | ||
|
|
5a431ae5f2 | ||
|
|
a6f0822700 | ||
|
|
c2664fc6d2 | ||
|
|
556cc10f3a | ||
|
|
7a2873aefb | ||
|
|
a063615e86 | ||
|
|
43a3d46023 | ||
|
|
fd7674124e | ||
|
|
0ffdc39b59 | ||
|
|
10ff3e9196 | ||
|
|
bacac24ee3 | ||
|
|
b8a3571e10 | ||
|
|
236eb0c16a | ||
|
|
1393a13df7 | ||
|
|
3d0a643617 | ||
|
|
f488429d5f | ||
|
|
72747cd7aa | ||
|
|
b255534224 | ||
|
|
360bea790a | ||
|
|
078d843b78 | ||
|
|
1a7397b502 | ||
|
|
86d0e6fd8e | ||
|
|
fb7b7e7155 | ||
|
|
3d3aa07554 | ||
|
|
3bd33332f6 | ||
|
|
7ef349563d | ||
|
|
a2c472bfef | ||
|
|
8d6f5e6320 | ||
|
|
ec5dc6d963 | ||
|
|
87956df961 | ||
|
|
79b336f967 | ||
|
|
bb28e71e50 | ||
|
|
2971a91fbb | ||
|
|
48f1a59c2a | ||
|
|
2bc5f45512 | ||
|
|
b0a48accf3 | ||
|
|
24e367315e | ||
|
|
18bdf741d3 | ||
|
|
765652ec67 | ||
|
|
47a7835797 | ||
|
|
949e7bb1f7 | ||
|
|
dd5f9fe379 | ||
|
|
a27317ea10 | ||
|
|
c9178643fb | ||
|
|
6ba5cf9bb2 | ||
|
|
d5e267103c | ||
|
|
ac6d4643af | ||
|
|
9f60a72621 | ||
|
|
f289735da9 | ||
|
|
71631d3375 | ||
|
|
79759af337 | ||
|
|
6473b6c57a | ||
|
|
add3c62bda | ||
|
|
46c2539543 | ||
|
|
c95a1a3278 | ||
|
|
5dfc1d8897 | ||
|
|
428b1bee2a | ||
|
|
65495ba1dd | ||
|
|
5c842bed9a | ||
|
|
c8e8ef714e | ||
|
|
16d4f814e5 | ||
|
|
31ab27a79a | ||
|
|
13ea7c192e | ||
|
|
0d6bee2025 | ||
|
|
fba950aeb5 | ||
|
|
5348ab1fda | ||
|
|
3d36c35baa | ||
|
|
f1e2823882 | ||
|
|
4842ac8fa4 | ||
|
|
7a4cd6cd00 | ||
|
|
eb381bc37e | ||
|
|
05100d295e | ||
|
|
a4271de370 | ||
|
|
5b2359d671 | ||
|
|
a047f913b4 | ||
|
|
44805ce481 | ||
|
|
a8eec32842 | ||
|
|
5d075e02ab |
No files matched your search
@@ -0,0 +1,121 @@
|
|||||||
|
---
|
||||||
|
name: plausible-analytics
|
||||||
|
description: Add Plausible Analytics tracking to the application, configured through AppConfig and environment variables.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Plausible Analytics
|
||||||
|
|
||||||
|
Add privacy-friendly analytics with [Plausible](https://plausible.io/) using the `@plausible-analytics/tracker` npm package. Configuration lives in `AppConfig` so it can be set via `VITE_` environment variables.
|
||||||
|
|
||||||
|
## 1. Install the package
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @plausible-analytics/tracker
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Add fields to `AppConfig`
|
||||||
|
|
||||||
|
In `src/contexts/AppContext.ts`, add two fields to the `AppConfig` interface:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export interface AppConfig {
|
||||||
|
// ...existing fields...
|
||||||
|
/** Plausible Analytics domain (empty string = disabled). */
|
||||||
|
plausibleDomain: string;
|
||||||
|
/** Plausible Analytics API endpoint (empty string = use default). */
|
||||||
|
plausibleEndpoint: string;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Update the Zod schema in `AppProvider.tsx`
|
||||||
|
|
||||||
|
Add the new fields to the `AppConfigSchema`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const AppConfigSchema = z.object({
|
||||||
|
// ...existing fields...
|
||||||
|
plausibleDomain: z.string(),
|
||||||
|
plausibleEndpoint: z.string(),
|
||||||
|
}) satisfies z.ZodType<AppConfig>;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Create `PlausibleProvider`
|
||||||
|
|
||||||
|
Create `src/components/PlausibleProvider.tsx`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { ReactNode, useEffect, useRef } from 'react';
|
||||||
|
import { useAppContext } from '@/hooks/useAppContext';
|
||||||
|
|
||||||
|
interface PlausibleProviderProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reactively initializes Plausible Analytics from AppConfig.
|
||||||
|
* Plausible's `init()` can only be called once, so we guard with a ref.
|
||||||
|
*/
|
||||||
|
export function PlausibleProvider({ children }: PlausibleProviderProps) {
|
||||||
|
const { config } = useAppContext();
|
||||||
|
const initializedRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initializedRef.current || !config.plausibleDomain) return;
|
||||||
|
initializedRef.current = true;
|
||||||
|
|
||||||
|
import('@plausible-analytics/tracker').then(({ init }) => {
|
||||||
|
init({
|
||||||
|
domain: config.plausibleDomain,
|
||||||
|
...(config.plausibleEndpoint && { endpoint: config.plausibleEndpoint }),
|
||||||
|
});
|
||||||
|
}).catch(console.error);
|
||||||
|
}, [config.plausibleDomain, config.plausibleEndpoint]);
|
||||||
|
|
||||||
|
return <>{children}</>;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Wire into `App.tsx`
|
||||||
|
|
||||||
|
Import `PlausibleProvider` and add it inside `AppProvider` (it needs access to `useAppContext`):
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { PlausibleProvider } from '@/components/PlausibleProvider';
|
||||||
|
|
||||||
|
// In the defaultConfig, add:
|
||||||
|
const defaultConfig: AppConfig = {
|
||||||
|
// ...existing fields...
|
||||||
|
plausibleDomain: import.meta.env.VITE_PLAUSIBLE_DOMAIN || '',
|
||||||
|
plausibleEndpoint: import.meta.env.VITE_PLAUSIBLE_ENDPOINT || '',
|
||||||
|
};
|
||||||
|
|
||||||
|
// In the JSX, wrap children of AppProvider:
|
||||||
|
<AppProvider storageKey="nostr:app-config" defaultConfig={defaultConfig}>
|
||||||
|
<PlausibleProvider>
|
||||||
|
{/* ...rest of providers... */}
|
||||||
|
</PlausibleProvider>
|
||||||
|
</AppProvider>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 6. Update `TestApp.tsx`
|
||||||
|
|
||||||
|
Add the new fields to the test default config with empty strings (disabled):
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const defaultConfig: AppConfig = {
|
||||||
|
// ...existing fields...
|
||||||
|
plausibleDomain: '',
|
||||||
|
plausibleEndpoint: '',
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## 7. Configure via environment variables
|
||||||
|
|
||||||
|
Create or update `.env`:
|
||||||
|
|
||||||
|
```
|
||||||
|
VITE_PLAUSIBLE_DOMAIN="example.com"
|
||||||
|
VITE_PLAUSIBLE_ENDPOINT="https://plausible.example.com/api/event"
|
||||||
|
```
|
||||||
|
|
||||||
|
`VITE_PLAUSIBLE_ENDPOINT` is optional -- it defaults to Plausible Cloud's endpoint if omitted. Set it when using a self-hosted Plausible instance.
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
---
|
||||||
|
name: release
|
||||||
|
description: Publish a new app release with versioning, changelog, and git tagging. Triggered by "publish a new release" or similar requests.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Release Skill
|
||||||
|
|
||||||
|
This skill guides you through publishing a new release of the app. It handles version bumping, changelog generation, and git tagging/pushing.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
- **Version format**: Marketing version (X.Y.Z), starting from 9.9.1. **This is NOT semver.** Version numbers are chosen based on how the release looks to end users, not based on API compatibility or breaking changes. Think of it like an app store version -- the number reflects the perceived significance of the update to a regular user.
|
||||||
|
- **Version source of truth**: `package.json` `version` field
|
||||||
|
- **Changelog**: `CHANGELOG.md` in repo root, using [Keep a Changelog](https://keepachangelog.com/) format
|
||||||
|
- **Version bumping**:
|
||||||
|
- **Patch (Z)**: Most releases. Bug fixes, tweaks, internal improvements, anything a user wouldn't specifically notice or seek out.
|
||||||
|
- **Minor (Y)**: Releases with headline features -- things worth announcing. A user should be able to look at the minor bump and think "oh, something new happened."
|
||||||
|
- **Major (X)**: Only when the user explicitly requests it (milestones, rebrands, major redesigns)
|
||||||
|
- **CI trigger**: Pushing a version tag (`v9.9.0`) triggers the CI pipeline to build and create a GitLab release
|
||||||
|
|
||||||
|
## Release Procedure
|
||||||
|
|
||||||
|
Follow these steps in order. Do NOT skip any step.
|
||||||
|
|
||||||
|
### Step 1: Required Reading
|
||||||
|
|
||||||
|
Before writing any release notes, you MUST read these pages to understand the product context, voice, and values:
|
||||||
|
|
||||||
|
1. **https://soapbox.pub/** -- Soapbox company overview and product suite
|
||||||
|
2. **https://soapbox.pub/shakespeare/** -- Shakespeare product page
|
||||||
|
|
||||||
|
These pages define what Shakespeare is, how it's positioned, and the tone of voice to use. Changelog entries should reflect this identity: creative, empowering, user-focused, emphasizing building and self-expression. Avoid dry technical jargon -- write for people who use the app, not developers.
|
||||||
|
|
||||||
|
### Step 2: Pre-flight Checks
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Ensure working directory is clean
|
||||||
|
git status
|
||||||
|
|
||||||
|
# Ensure we're on main branch
|
||||||
|
git branch --show-current
|
||||||
|
|
||||||
|
# Run the full test suite
|
||||||
|
npm run test
|
||||||
|
```
|
||||||
|
|
||||||
|
- If the working directory has uncommitted changes, ask the user whether to commit them first or abort.
|
||||||
|
- If not on `main`, warn the user and ask whether to proceed.
|
||||||
|
- If tests fail, stop and fix the issues before continuing.
|
||||||
|
|
||||||
|
### Step 3: Determine What Changed
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Get the current version from package.json
|
||||||
|
node -p "require('./package.json').version"
|
||||||
|
|
||||||
|
# Get commits since the last version tag
|
||||||
|
git log v$(node -p "require('./package.json').version")..HEAD --oneline
|
||||||
|
```
|
||||||
|
|
||||||
|
- If there are no commits since the last tag, inform the user there is nothing to release and stop.
|
||||||
|
- Review the commit list to understand the scope of changes.
|
||||||
|
|
||||||
|
### Step 4: Decide the Version Bump
|
||||||
|
|
||||||
|
Analyze the commits from Step 3 and determine the appropriate bump level:
|
||||||
|
|
||||||
|
| Bump | When to use | Example |
|
||||||
|
|------|-------------|---------|
|
||||||
|
| **Patch** | Bug fixes, minor tweaks, dependency updates, small UI polish, internal tooling, developer-facing pages, CI/build changes, settings/admin screens | 9.9.0 -> 9.9.1 |
|
||||||
|
| **Minor** | Significant new product features that change how users interact with the app -- the kind of thing you'd highlight in an app store update or announce on social media (e.g., new template support, new AI features, new deployment options, major UI overhaul) | 9.9.1 -> 9.10.0 |
|
||||||
|
| **Major** | ONLY when the user explicitly instructs a major bump | 9.10.0 -> 10.0.0 |
|
||||||
|
|
||||||
|
**Default to patch** when in doubt. The bar for a minor bump is high -- ask yourself: "Would a regular user notice and care about this change?" If the answer is no, it's a patch. Internal pages (changelog, settings, about screens), infrastructure improvements, CI fixes, and developer tooling are always patch-level regardless of whether they technically add a new page or screen.
|
||||||
|
|
||||||
|
When bumping minor, reset patch to 0 (e.g., 9.9.3 -> 9.10.0).
|
||||||
|
When bumping major, reset minor and patch to 0 (e.g., 9.3.1 -> 10.0.0).
|
||||||
|
|
||||||
|
### Step 5: Write the Changelog Entry
|
||||||
|
|
||||||
|
Prepend a new section to `CHANGELOG.md` directly below the `# Changelog` heading.
|
||||||
|
|
||||||
|
**Format:**
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## [X.Y.Z] - YYYY-MM-DD
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Description of new features
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Description of changes to existing features
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Description of bug fixes
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Description of removed features
|
||||||
|
```
|
||||||
|
|
||||||
|
**Rules:**
|
||||||
|
- Only include categories that have entries (omit empty categories)
|
||||||
|
- Write **user-facing descriptions**, not raw commit messages
|
||||||
|
- Keep descriptions concise -- one line per change
|
||||||
|
- Group related commits into single entries where appropriate
|
||||||
|
- Use present tense ("Add dark mode toggle", not "Added dark mode toggle")
|
||||||
|
- Focus on what the user sees/experiences, not internal implementation details
|
||||||
|
- Use the current date in YYYY-MM-DD format
|
||||||
|
- **Collapse related work into one entry.** If a feature was added and then fixed/tweaked across multiple commits in the same release, present the finished result as a single "Added" entry. Never list something as "Added" and then also list fixes for that same thing -- the user sees the end product, not the development history.
|
||||||
|
- **Omit purely internal changes.** CI fixes, build pipeline tweaks, developer tooling, and infrastructure changes should be omitted from the changelog entirely unless they have a direct, visible impact on the user experience. The changelog is for users, not developers.
|
||||||
|
- **Compare the actual code between versions** to understand what really changed, rather than just reading commit messages. Commit messages may over- or under-represent the significance of changes.
|
||||||
|
|
||||||
|
### Step 6: Update Version in All Files
|
||||||
|
|
||||||
|
#### 6a. `package.json`
|
||||||
|
|
||||||
|
Update the `version` field:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"version": "X.Y.Z"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 7: Copy Changelog to Public Directory
|
||||||
|
|
||||||
|
The changelog is served at runtime by the app from the `public/` directory. After updating `CHANGELOG.md`, copy it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp CHANGELOG.md public/CHANGELOG.md
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 8: Pull Latest Changes
|
||||||
|
|
||||||
|
Before committing the release, pull the latest changes from the remote to ensure the release commit sits on top of the latest code. This **must** happen before committing and tagging.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
**CRITICAL**: Always use `git pull` (merge), NEVER `git pull --rebase`. Rebasing rewrites commit hashes, which would orphan any tag pointing to the original commit. Since version tags are often protected on the remote and cannot be deleted or updated, a broken tag cannot be easily fixed.
|
||||||
|
|
||||||
|
If there are merge conflicts with the pulled changes, resolve them before proceeding.
|
||||||
|
|
||||||
|
### Step 9: Commit the Release
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add package.json CHANGELOG.md public/CHANGELOG.md
|
||||||
|
git commit -m "release: vX.Y.Z"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 10: Tag the Release
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag vX.Y.Z
|
||||||
|
```
|
||||||
|
|
||||||
|
The tag format is `v` followed by the version with no suffix. Examples: `v9.9.0`, `v9.10.0`, `v10.0.0`.
|
||||||
|
|
||||||
|
### Step 11: Push
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git push origin main vX.Y.Z
|
||||||
|
```
|
||||||
|
|
||||||
|
**CRITICAL**: Push only the specific tag being released. NEVER use `--tags` -- that pushes ALL local tags, including stale or deleted ones.
|
||||||
|
|
||||||
|
### Step 12: Confirm
|
||||||
|
|
||||||
|
After pushing, inform the user:
|
||||||
|
- The new version number
|
||||||
|
- A brief summary of what was released
|
||||||
|
- That CI will handle building and publishing the artifacts
|
||||||
|
|
||||||
|
## File Reference
|
||||||
|
|
||||||
|
| File | What to update | Notes |
|
||||||
|
|------|---------------|-------|
|
||||||
|
| `package.json` | `version` field | Source of truth for the version |
|
||||||
|
| `CHANGELOG.md` | Prepend new section | User-facing changelog |
|
||||||
|
| `public/CHANGELOG.md` | Copy from `CHANGELOG.md` | Served at runtime by the app |
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### "Nothing to release"
|
||||||
|
If `git log` shows no commits since the last tag, there genuinely is nothing to release.
|
||||||
|
|
||||||
|
### Tests fail
|
||||||
|
Fix the failing tests before proceeding. The release must not contain broken code.
|
||||||
|
|
||||||
|
### Wrong version bumped
|
||||||
|
If you tagged the wrong version and haven't pushed yet:
|
||||||
|
```bash
|
||||||
|
git tag -d vX.Y.Z # delete the local tag
|
||||||
|
git reset --soft HEAD~1 # undo the commit but keep changes staged
|
||||||
|
```
|
||||||
|
Then redo steps 4-10 with the correct version.
|
||||||
|
|
||||||
|
### Already pushed a bad release
|
||||||
|
This requires manual intervention. Inform the user and suggest they delete the tag and release from GitLab manually, then re-run the release process.
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
# Sentry
|
# Sentry
|
||||||
VITE_SENTRY_DSN="https://********************************@*****************.example.com/****************"
|
VITE_SENTRY_DSN="https://********************************@*****************.example.com/****************"
|
||||||
|
|
||||||
|
# Plausible Analytics
|
||||||
|
VITE_PLAUSIBLE_DOMAIN="example.com"
|
||||||
|
VITE_PLAUSIBLE_ENDPOINT="https://plausible.example.com/api/event"
|
||||||
|
|
||||||
# GitHub OAuth Configuration
|
# GitHub OAuth Configuration
|
||||||
VITE_GITHUB_OAUTH_CLIENT_ID="********************"
|
VITE_GITHUB_OAUTH_CLIENT_ID="********************"
|
||||||
VITE_GITHUB_OAUTH_CLIENT_SECRET="****************************************"
|
VITE_GITHUB_OAUTH_CLIENT_SECRET="****************************************"
|
||||||
|
|||||||
@@ -1,15 +1,28 @@
|
|||||||
image: node:22
|
image: node:25
|
||||||
|
|
||||||
default:
|
default:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
timeout: 1 minute
|
timeout: 1 minute
|
||||||
|
cache:
|
||||||
|
key:
|
||||||
|
files:
|
||||||
|
- package-lock.json
|
||||||
|
paths:
|
||||||
|
- node_modules/
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- deploy
|
- deploy
|
||||||
|
- build
|
||||||
|
- release
|
||||||
|
- publish
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
|
when: never
|
||||||
|
- when: always
|
||||||
script:
|
script:
|
||||||
- npm run typecheck
|
- npm run typecheck
|
||||||
- npm run build
|
- npm run build
|
||||||
@@ -17,6 +30,10 @@ test:
|
|||||||
|
|
||||||
pages:
|
pages:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
||||||
script:
|
script:
|
||||||
- npm run build
|
- npm run build
|
||||||
- rm -rf public
|
- rm -rf public
|
||||||
@@ -24,6 +41,198 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
only:
|
|
||||||
|
deploy-nsite:
|
||||||
|
stage: deploy
|
||||||
|
timeout: 10 minutes
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
||||||
variables:
|
variables:
|
||||||
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
|
NSYTE_VERSION: "v0.24.1"
|
||||||
|
script:
|
||||||
|
# Build the web app
|
||||||
|
- npm ci
|
||||||
|
- npm run build
|
||||||
|
- cp dist/index.html dist/404.html
|
||||||
|
|
||||||
|
# Remove sourcemaps to stay under nsite's 65KB manifest limit
|
||||||
|
- find dist -name '*.map' -delete
|
||||||
|
|
||||||
|
# Download nsyte binary
|
||||||
|
- curl -fsSL "https://github.com/sandwichfarm/nsyte/releases/download/${NSYTE_VERSION}/nsyte-linux" -o /usr/local/bin/nsyte
|
||||||
|
- chmod +x /usr/local/bin/nsyte
|
||||||
|
|
||||||
|
# Deploy to nsite via nsyte using the nbunksec credential
|
||||||
|
- >-
|
||||||
|
nsyte deploy ./dist
|
||||||
|
-i
|
||||||
|
--sec "$NSITE_NBUNKSEC"
|
||||||
|
--name shakespeare
|
||||||
|
--relays "wss://relay.ditto.pub,wss://relay.nsite.lol,wss://relay.dreamith.to,wss://relay.primal.net"
|
||||||
|
--servers "https://blossom.primal.net,https://blossom.ditto.pub,https://blossom.dreamith.to"
|
||||||
|
--fallback "/index.html"
|
||||||
|
--publish-server-list
|
||||||
|
--use-fallback-relays
|
||||||
|
--use-fallback-servers
|
||||||
|
|
||||||
|
build-apk:
|
||||||
|
stage: build
|
||||||
|
image: eclipse-temurin:21-jdk
|
||||||
|
timeout: 15 minutes
|
||||||
|
needs: []
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
|
||||||
|
variables:
|
||||||
|
ANDROID_SDK_ROOT: /opt/android-sdk
|
||||||
|
ANDROID_HOME: /opt/android-sdk
|
||||||
|
before_script:
|
||||||
|
# Install system dependencies
|
||||||
|
- apt-get update -qq
|
||||||
|
- apt-get install -y -qq curl unzip > /dev/null
|
||||||
|
|
||||||
|
# Install Node.js 22
|
||||||
|
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||||
|
- apt-get install -y -qq nodejs > /dev/null
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
|
||||||
|
# Install Android SDK command-line tools
|
||||||
|
- mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
|
||||||
|
- curl -fsSL https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o cmdline-tools.zip
|
||||||
|
- unzip -q cmdline-tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools
|
||||||
|
- mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
|
||||||
|
- export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
|
||||||
|
|
||||||
|
# Accept licenses and install SDK components
|
||||||
|
- printf 'y\ny\ny\ny\ny\ny\ny\n' | sdkmanager --licenses > /dev/null 2>&1 || true
|
||||||
|
- sdkmanager --install "platforms;android-36" "build-tools;36.0.0" "platform-tools" > /dev/null
|
||||||
|
|
||||||
|
# Write local.properties for Gradle
|
||||||
|
- echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
|
||||||
|
|
||||||
|
# Decode signing keystore and migrate JKS -> PKCS12 for Gradle compatibility
|
||||||
|
- echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > android/app/my-upload-key.jks
|
||||||
|
- keytool -importkeystore
|
||||||
|
-srckeystore android/app/my-upload-key.jks
|
||||||
|
-destkeystore android/app/my-upload-key.keystore
|
||||||
|
-deststoretype pkcs12
|
||||||
|
-srcstorepass "$KEYSTORE_PASSWORD"
|
||||||
|
-deststorepass "$KEYSTORE_PASSWORD"
|
||||||
|
-srcalias upload
|
||||||
|
-destalias upload
|
||||||
|
-noprompt
|
||||||
|
- rm android/app/my-upload-key.jks
|
||||||
|
|
||||||
|
# Write key.properties from CI/CD variables
|
||||||
|
- |
|
||||||
|
cat > android/key.properties << EOF
|
||||||
|
storePassword=$KEYSTORE_PASSWORD
|
||||||
|
keyPassword=$KEY_PASSWORD
|
||||||
|
keyAlias=upload
|
||||||
|
storeFile=my-upload-key.keystore
|
||||||
|
EOF
|
||||||
|
script:
|
||||||
|
# Extract semver version from git tag (e.g., v9.9.2 -> 9.9.2)
|
||||||
|
- TAG="${CI_COMMIT_TAG#v}"
|
||||||
|
- VERSION_NAME="${TAG}"
|
||||||
|
- VERSION_CODE="${CI_PIPELINE_IID}"
|
||||||
|
- echo "Building version $VERSION_NAME (code $VERSION_CODE) from tag $CI_COMMIT_TAG"
|
||||||
|
|
||||||
|
# Stamp version into build.gradle
|
||||||
|
- sed -i "s/versionCode [0-9]*/versionCode ${VERSION_CODE}/" android/app/build.gradle
|
||||||
|
- sed -i "s/versionName \"[^\"]*\"/versionName \"${VERSION_NAME}\"/" android/app/build.gradle
|
||||||
|
|
||||||
|
# Build web assets
|
||||||
|
- npm ci
|
||||||
|
- npx vite build -l error
|
||||||
|
- cp dist/index.html dist/404.html
|
||||||
|
|
||||||
|
# Sync web assets to Capacitor Android project
|
||||||
|
- npx cap sync android
|
||||||
|
|
||||||
|
# Build signed release APK
|
||||||
|
- cd android && chmod +x gradlew && ./gradlew assembleRelease bundleRelease && cd ..
|
||||||
|
|
||||||
|
# Copy APK to a predictable artifact path
|
||||||
|
- mkdir -p artifacts
|
||||||
|
- cp android/app/build/outputs/apk/release/app-release.apk "artifacts/Shakespeare.apk"
|
||||||
|
- cp android/app/build/outputs/bundle/release/app-release.aab "artifacts/Shakespeare.aab"
|
||||||
|
- ls -lh artifacts/
|
||||||
|
|
||||||
|
# Upload to Generic Packages registry for a stable public download URL
|
||||||
|
- |
|
||||||
|
curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
||||||
|
--upload-file "artifacts/Shakespeare.apk" \
|
||||||
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.apk"
|
||||||
|
- |
|
||||||
|
curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
|
||||||
|
--upload-file "artifacts/Shakespeare.aab" \
|
||||||
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.aab"
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- artifacts/Shakespeare.apk
|
||||||
|
- artifacts/Shakespeare.aab
|
||||||
|
expire_in: 90 days
|
||||||
|
cache:
|
||||||
|
key: android-gradle
|
||||||
|
paths:
|
||||||
|
- android/.gradle/
|
||||||
|
- .gradle/
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||||
|
needs:
|
||||||
|
- build-apk
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
|
||||||
|
script:
|
||||||
|
- echo "Creating release for $CI_COMMIT_TAG"
|
||||||
|
# Extract the latest changelog section for the release description.
|
||||||
|
# Reads from "## [version]" to the next "## [" or end of file.
|
||||||
|
- |
|
||||||
|
VERSION="${CI_COMMIT_TAG#v}"
|
||||||
|
RELEASE_NOTES=$(awk "/^## \\[${VERSION}\\]/{found=1; next} /^## \\[/{if(found) exit} found{print}" CHANGELOG.md)
|
||||||
|
if [ -z "$RELEASE_NOTES" ]; then
|
||||||
|
RELEASE_NOTES="Shakespeare ${CI_COMMIT_TAG}"
|
||||||
|
fi
|
||||||
|
- echo "$RELEASE_NOTES" > release-notes.md
|
||||||
|
release:
|
||||||
|
tag_name: $CI_COMMIT_TAG
|
||||||
|
name: $CI_COMMIT_TAG
|
||||||
|
description: './release-notes.md'
|
||||||
|
assets:
|
||||||
|
links:
|
||||||
|
- name: Shakespeare-${CI_COMMIT_TAG}.apk
|
||||||
|
url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.apk
|
||||||
|
link_type: package
|
||||||
|
- name: Shakespeare-${CI_COMMIT_TAG}.aab
|
||||||
|
url: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/shakespeare/${CI_COMMIT_TAG}/Shakespeare-${CI_COMMIT_TAG}.aab
|
||||||
|
link_type: package
|
||||||
|
|
||||||
|
publish-zapstore:
|
||||||
|
stage: publish
|
||||||
|
image: golang:1.24
|
||||||
|
needs:
|
||||||
|
- build-apk
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
|
||||||
|
variables:
|
||||||
|
SIGN_WITH: $ZAPSTORE_BUNKER_URL
|
||||||
|
script:
|
||||||
|
- go install github.com/zapstore/zsp@latest
|
||||||
|
|
||||||
|
# Restore the persistent NIP-46 client key so the bunker recognizes us across CI runs.
|
||||||
|
# zsp stores client keys at ~/.config/zsp/bunker-keys/<bunker-pubkey>.key
|
||||||
|
- BUNKER_PUBKEY=$(echo "$ZAPSTORE_BUNKER_URL" | sed 's|bunker://||;s|?.*||')
|
||||||
|
- mkdir -p ~/.config/zsp/bunker-keys
|
||||||
|
- echo "$ZAPSTORE_CLIENT_KEY" > ~/.config/zsp/bunker-keys/${BUNKER_PUBKEY}.key
|
||||||
|
|
||||||
|
- APK_PATH="artifacts/Shakespeare.apk"
|
||||||
|
- VERSION="${CI_COMMIT_TAG#v}"
|
||||||
|
- sed -i "2i release_source:\ ./${APK_PATH}" zapstore.yaml
|
||||||
|
- sed -i "2i version:\ ${VERSION}" zapstore.yaml
|
||||||
|
- zsp publish --quiet --skip-preview zapstore.yaml
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
# Agent Rules
|
||||||
|
|
||||||
|
- ALWAYS commit after you finish your turn. No exceptions. Don't ask for permission, just do it.
|
||||||
|
|
||||||
# Shakespeare - AI-Powered App Builder
|
# Shakespeare - AI-Powered App Builder
|
||||||
|
|
||||||
Shakespeare is a browser-based AI chat application that allows users to build custom web applications through natural language conversation. All operations including AI chat and Git operations are executed in client-side JavaScript, with API keys stored in browser storage. Simply describe what you want to build, and AI will help you create it.
|
Shakespeare is a browser-based AI chat application that allows users to build custom web applications through natural language conversation. All operations including AI chat and Git operations are executed in client-side JavaScript, with API keys stored in browser storage. Simply describe what you want to build, and AI will help you create it.
|
||||||
@@ -41,7 +45,8 @@ Shakespeare provides AI agents with specialized tools for project development (n
|
|||||||
- **NpmAddPackageTool**: Add npm packages to projects
|
- **NpmAddPackageTool**: Add npm packages to projects
|
||||||
- **NpmRemovePackageTool**: Remove npm packages from projects
|
- **NpmRemovePackageTool**: Remove npm packages from projects
|
||||||
- **GitCommitTool**: Commit changes to Git repositories
|
- **GitCommitTool**: Commit changes to Git repositories
|
||||||
- **ReadWebpageTool**: Fetch and read web pages
|
- **WebFetchTool**: Fetch and read web pages with support for markdown, text, and HTML formats
|
||||||
|
- **WebSearchTool**: Search the web using Exa AI for real-time web searches
|
||||||
- **NostrReadNipTool**: Read Nostr protocol NIP documents
|
- **NostrReadNipTool**: Read Nostr protocol NIP documents
|
||||||
- **NostrReadKindTool**: Read Nostr event kind documentation
|
- **NostrReadKindTool**: Read Nostr event kind documentation
|
||||||
- **NostrReadTagTool**: Read Nostr tag documentation
|
- **NostrReadTagTool**: Read Nostr tag documentation
|
||||||
@@ -49,6 +54,9 @@ Shakespeare provides AI agents with specialized tools for project development (n
|
|||||||
- **NostrReadNipsIndexTool**: Read the full list of NIPs, kinds, and tags
|
- **NostrReadNipsIndexTool**: Read the full list of NIPs, kinds, and tags
|
||||||
- **NostrFetchEventTool**: Fetch Nostr events using NIP-19 identifiers
|
- **NostrFetchEventTool**: Fetch Nostr events using NIP-19 identifiers
|
||||||
- **NostrGenerateKindTool**: Generate unused Nostr event kind numbers
|
- **NostrGenerateKindTool**: Generate unused Nostr event kind numbers
|
||||||
|
- **NostrEncodeTool**: Encode hex values into NIP-19 bech32 entities (npub, note, nprofile, nevent, naddr)
|
||||||
|
- **NostrDecodeTool**: Decode NIP-19 bech32 entities into hex and structured data
|
||||||
|
- **BlossomUploadTool**: Upload files from the project to Blossom media hosting, returns a public URL
|
||||||
- **ReadConsoleMessagesTool**: Read console messages from project preview with filtering capabilities
|
- **ReadConsoleMessagesTool**: Read console messages from project preview with filtering capabilities
|
||||||
|
|
||||||
#### Shell Commands
|
#### Shell Commands
|
||||||
@@ -232,7 +240,7 @@ This project is a Nostr client application built with React 18.x, TailwindCSS 3.
|
|||||||
- Package management: `NpmAddPackageTool`, `NpmRemovePackageTool`
|
- Package management: `NpmAddPackageTool`, `NpmRemovePackageTool`
|
||||||
- Git integration: `GitCommitTool`
|
- Git integration: `GitCommitTool`
|
||||||
- Shell access: `ShellTool`
|
- Shell access: `ShellTool`
|
||||||
- Web access: `ReadWebpageTool`
|
- Web access: `WebFetchTool`, `WebSearchTool`
|
||||||
- Nostr tools: `NostrReadNipTool`, `NostrFetchEventTool`, `NostrGenerateKindTool`, etc.
|
- Nostr tools: `NostrReadNipTool`, `NostrFetchEventTool`, `NostrGenerateKindTool`, etc.
|
||||||
- `/src/contexts/`: React context providers
|
- `/src/contexts/`: React context providers
|
||||||
- `AppContext`: Global app configuration and theme
|
- `AppContext`: Global app configuration and theme
|
||||||
@@ -1091,7 +1099,7 @@ const defaultConfig: AppConfig = {
|
|||||||
relayMetadata: {
|
relayMetadata: {
|
||||||
relays: [
|
relays: [
|
||||||
{ url: 'wss://relay.ditto.pub', read: true, write: true },
|
{ url: 'wss://relay.ditto.pub', read: true, write: true },
|
||||||
{ url: 'wss://relay.nostr.band', read: true, write: true },
|
{ url: 'wss://relay.primal.net', read: true, write: true },
|
||||||
],
|
],
|
||||||
updatedAt: 0,
|
updatedAt: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [9.10.1] - 2026-04-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix Android app showing default Capacitor icon instead of Shakespeare logo in app drawer
|
||||||
|
|
||||||
|
## [9.10.0] - 2026-04-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Android app powered by Capacitor with deep links, splash screen, and signed release builds
|
||||||
|
- CI pipeline for building APKs, publishing to GitLab releases, and distributing via Zapstore
|
||||||
|
- Nsite deployment for decentralized hosting via Nostr
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Make version number on mobile settings a clickable link to the changelog with build date
|
||||||
|
|
||||||
|
## [9.9.2] - 2026-04-02
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Simplify nsite deployment to always use named sites, removing the root site option
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix crash in "What's new" toast when used outside the router context
|
||||||
|
- Truncate long changelog excerpts in update notifications so they fit neatly in the toast
|
||||||
|
- Left-align changelog page content for better readability
|
||||||
|
|
||||||
|
## [9.9.1] - 2026-04-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Changelog page and versioning system with "What's new" toast notifications on updates
|
||||||
|
- Release skill for managing versioned releases with changelog generation and git tagging
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
|
||||||
|
|
||||||
|
# Built application files
|
||||||
|
*.apk
|
||||||
|
*.aar
|
||||||
|
*.ap_
|
||||||
|
*.aab
|
||||||
|
|
||||||
|
# Files for the ART/Dalvik VM
|
||||||
|
*.dex
|
||||||
|
|
||||||
|
# Java class files
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
bin/
|
||||||
|
gen/
|
||||||
|
out/
|
||||||
|
# Uncomment the following line in case you need and you don't have the release build type files in your app
|
||||||
|
# release/
|
||||||
|
|
||||||
|
# Gradle files
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Local configuration file (sdk path, etc)
|
||||||
|
local.properties
|
||||||
|
|
||||||
|
# Proguard folder generated by Eclipse
|
||||||
|
proguard/
|
||||||
|
|
||||||
|
# Log Files
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Android Studio Navigation editor temp files
|
||||||
|
.navigation/
|
||||||
|
|
||||||
|
# Android Studio captures folder
|
||||||
|
captures/
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
*.iml
|
||||||
|
.idea/workspace.xml
|
||||||
|
.idea/tasks.xml
|
||||||
|
.idea/gradle.xml
|
||||||
|
.idea/assetWizardSettings.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
.idea/libraries
|
||||||
|
# Android Studio 3 in .gitignore file.
|
||||||
|
.idea/caches
|
||||||
|
.idea/modules.xml
|
||||||
|
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||||
|
.idea/navEditor.xml
|
||||||
|
|
||||||
|
# Keystore files
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
key.properties
|
||||||
|
|
||||||
|
# External native build folder generated in Android Studio 2.2 and later
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx/
|
||||||
|
|
||||||
|
# Google Services (e.g. APIs or Firebase)
|
||||||
|
# google-services.json
|
||||||
|
|
||||||
|
# Freeline
|
||||||
|
freeline.py
|
||||||
|
freeline/
|
||||||
|
freeline_project_description.json
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
fastlane/report.xml
|
||||||
|
fastlane/Preview.html
|
||||||
|
fastlane/screenshots
|
||||||
|
fastlane/test_output
|
||||||
|
fastlane/readme.md
|
||||||
|
|
||||||
|
# Version control
|
||||||
|
vcs.xml
|
||||||
|
|
||||||
|
# lint
|
||||||
|
lint/intermediates/
|
||||||
|
lint/generated/
|
||||||
|
lint/outputs/
|
||||||
|
lint/tmp/
|
||||||
|
# lint/reports/
|
||||||
|
|
||||||
|
# Android Profiling
|
||||||
|
*.hprof
|
||||||
|
|
||||||
|
# Cordova plugins for Capacitor
|
||||||
|
capacitor-cordova-android-plugins
|
||||||
|
|
||||||
|
# Copied web assets
|
||||||
|
app/src/main/assets/public
|
||||||
|
|
||||||
|
# Generated Config files
|
||||||
|
app/src/main/assets/capacitor.config.json
|
||||||
|
app/src/main/assets/capacitor.plugins.json
|
||||||
|
app/src/main/res/xml/config.xml
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>android</name>
|
||||||
|
<comment>Project android created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1775119841750</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
arguments=--init-script /home/alex/.cache/opencode/bin/jdtls/config_linux/org.eclipse.osgi/58/0/.cp/gradle/init/init.gradle
|
||||||
|
auto.sync=false
|
||||||
|
build.scans.enabled=false
|
||||||
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||||
|
connection.project.dir=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
gradle.user.home=
|
||||||
|
java.home=/usr/lib/jvm/java-21-openjdk-amd64
|
||||||
|
jvm.arguments=
|
||||||
|
offline.mode=false
|
||||||
|
override.workspace.settings=true
|
||||||
|
show.console.view=true
|
||||||
|
show.executions.view=true
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
</classpath>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/build/*
|
||||||
|
!/build/.npmkeep
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>app</name>
|
||||||
|
<comment>Project app created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1775119841776</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
connection.project.dir=..
|
||||||
|
eclipse.preferences.version=1
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
def keystorePropertiesFile = rootProject.file("key.properties")
|
||||||
|
def keystoreProperties = new Properties()
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "diy.shakespeare.app"
|
||||||
|
compileSdk = rootProject.ext.compileSdkVersion
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "diy.shakespeare.app"
|
||||||
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
|
versionCode 1
|
||||||
|
versionName "9.9.2"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
aaptOptions {
|
||||||
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
||||||
|
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
signingConfigs {
|
||||||
|
release {
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keyAlias keystoreProperties['keyAlias']
|
||||||
|
keyPassword keystoreProperties['keyPassword']
|
||||||
|
storeFile file(keystoreProperties['storeFile'])
|
||||||
|
storePassword keystoreProperties['storePassword']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
signingConfig signingConfigs.release
|
||||||
|
minifyEnabled true
|
||||||
|
shrinkResources true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
flatDir{
|
||||||
|
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
||||||
|
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
||||||
|
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
||||||
|
implementation project(':capacitor-android')
|
||||||
|
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
||||||
|
testImplementation "junit:junit:$junitVersion"
|
||||||
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
||||||
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
||||||
|
implementation project(':capacitor-cordova-android-plugins')
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: 'capacitor.build.gradle'
|
||||||
|
|
||||||
|
try {
|
||||||
|
def servicesJSON = file('google-services.json')
|
||||||
|
if (servicesJSON.text) {
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_21
|
||||||
|
targetCompatibility JavaVersion.VERSION_21
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||||
|
dependencies {
|
||||||
|
implementation project(':capacitor-app')
|
||||||
|
implementation project(':capacitor-status-bar')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (hasProperty('postBuildExtras')) {
|
||||||
|
postBuildExtras()
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Keep Capacitor classes (WebView JS bridge)
|
||||||
|
-keep class com.getcapacitor.** { *; }
|
||||||
|
-keep class diy.shakespeare.app.** { *; }
|
||||||
|
|
||||||
|
# Keep WebView JS interfaces
|
||||||
|
-keepclassmembers class * {
|
||||||
|
@android.webkit.JavascriptInterface <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep OkHttp (used by Capacitor)
|
||||||
|
-dontwarn okhttp3.**
|
||||||
|
-dontwarn okio.**
|
||||||
|
-keep class okhttp3.** { *; }
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.getcapacitor.myapp;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void useAppContext() throws Exception {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
|
||||||
|
assertEquals("com.getcapacitor.app", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/title_activity_main"
|
||||||
|
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:exported="true">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Deep links: open shakespeare.diy URLs in the app -->
|
||||||
|
<intent-filter android:autoVerify="true">
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="https" android:host="shakespeare.diy" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths"></meta-data>
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
<!-- Permissions -->
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package diy.shakespeare.app;
|
||||||
|
|
||||||
|
import com.getcapacitor.BridgeActivity;
|
||||||
|
|
||||||
|
public class MainActivity extends BridgeActivity {}
|
||||||
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,53 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Shakespeare parrot logo from public/shakespeare.svg.
|
||||||
|
SVG viewBox is "0 0 128 128".
|
||||||
|
We scale to ~55% and center within the 108x108 viewport to fit
|
||||||
|
Android's adaptive icon safe zone (66% of 108dp).
|
||||||
|
Scale factor: 108 * 0.55 / 128 ≈ 0.464. Translate to center.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<group
|
||||||
|
android:translateX="24.3"
|
||||||
|
android:translateY="15.5"
|
||||||
|
android:scaleX="0.464"
|
||||||
|
android:scaleY="0.464">
|
||||||
|
|
||||||
|
<!-- Beak right -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M110.28,61.32l2.63,8.84c0,0,7.24,-1.6,7.62,3.2c0.38,4.8,-6.77,8,-6.77,8l2.26,10.63 c0,0,7.9,-6.4,8,-15.61c0,0,0.66,-11.29,-6.11,-13.92C113.67,60.85,110.28,61.32,110.28,61.32z"/>
|
||||||
|
|
||||||
|
<!-- Tail feathers -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M68.71,94.99c0,0,-11.1,-4.7,-16.46,1.98c-0.75,0.94,-1.41,1.88,-2.16,2.82 c-0.56,0.75,-1.13,1.5,-1.69,2.16c-0.47,0.56,-1.03,1.13,-1.69,1.5c-0.66,0.38,-1.32,0.66,-2.07,0.85c-0.94,0.19,-1.88,0.19,-2.82,0.09 c-1.32,-0.09,-2.63,-0.38,-3.95,-0.66c-0.47,-0.09,-0.85,-0.19,-1.22,-0.28c-0.09,0,-0.19,-0.09,-0.28,-0.09 s-0.19,-0.09,-0.28,-0.09c-0.38,0.09,0.19,0.75,0.38,0.94c0.28,0.28,0.56,0.66,0.85,0.94c0.85,0.75,1.69,1.5,2.73,1.98 c1.32,0.66,2.73,1.03,4.14,1.13c0.09,0,0.38,0,0.47,0.09c0.19,0.19,-0.28,0.47,-0.47,0.56c-0.28,0.19,-0.47,0.28,-0.75,0.38 c-0.85,0.38,-1.79,0.56,-2.63,0.75c-0.85,0.19,-1.69,0.28,-2.45,0.28c-0.47,0,-0.85,0.09,-1.22,0.09c-0.28,0,-0.56,-0.09,-0.85,0 s0.09,0.47,0.28,0.56c0.38,0.19,0.75,0.47,1.13,0.66c1.13,0.56,2.26,1.03,3.39,1.32c1.5,0.38,3.1,0.56,4.61,0.38 c1.32,-0.19,2.63,-0.56,3.86,-1.03c6.77,-3.1,6.21,-9.59,12.42,-10.16c4.61,-0.38,11.1,2.07,11.1,2.07L68.71,94.99z"/>
|
||||||
|
|
||||||
|
<!-- Beak left -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M19.79,38.28c0,0,-12.13,1.98,-15.24,12.79C0.61,64.9,20.26,69.5,20.26,69.5l1.22,-9.41 c0,0,-13.07,-1.32,-12.32,-6.3c0.94,-6.21,11.85,-5.64,11.85,-5.64L19.79,38.28z"/>
|
||||||
|
|
||||||
|
<!-- Wing detail -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M20.73,70.92c0,0,-1.88,0.56,-4.61,2.54c-1.88,1.32,-4.42,3.01,-6.87,5.93 c-1.22,1.41,-2.16,3.1,-2.82,4.89c-0.47,1.22,-0.66,2.45,-0.66,3.76c0,0.28,0,0.56,0,0.85c0,0.09,0,0.85,0.28,0.66 c0.09,-0.09,0.19,-0.38,0.28,-0.47c0.19,-0.47,0.47,-0.85,0.75,-1.22c0.85,-1.13,1.88,-2.16,3.01,-3.01c0.38,-0.28,0.75,-0.47,1.13,-0.66 c0.28,-0.28,0.75,-0.66,0.94,-0.28c0.09,0.19,-0.09,0.47,-0.19,0.66c-0.09,0.28,-0.19,0.66,-0.19,0.94c-0.38,1.5,-0.56,3.01,-0.75,4.51 c-0.09,0.85,-0.09,1.69,0,2.45c0,0.38,0.09,0.85,0.09,1.22c0,0.19,0.09,0.38,0.09,0.56c0,0.19,0.19,0.47,0.38,0.19 c0.09,-0.09,0.09,-0.19,0.19,-0.38c0.19,-0.28,0.28,-0.66,0.47,-0.94c0.47,-0.85,0.94,-1.69,1.5,-2.63c0.66,-1.13,1.41,-2.16,2.16,-3.1 c0.85,-1.13,1.88,-2.26,2.92,-3.2c1.13,-1.03,2.35,-2.07,3.67,-2.92c0.75,-0.47,1.6,-0.94,2.45,-1.32L20.73,70.92z"/>
|
||||||
|
|
||||||
|
<!-- Body -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M116.4,79.29c-1.13,-5.55,-2.73,-11.01,-4.51,-16.46c-1.5,-4.61,-3.1,-9.31,-5.83,-13.36 c-1.22,-1.79,-3.01,-3.01,-5.27,-3.86c-4.33,-1.69,-9.97,-1.98,-13.73,-1.98c-5.64,0,-11.48,1.22,-16.74,3.67 c-1.88,5.64,-7.05,19.94,-14.86,26.34c0.47,2.63,1.03,5.36,1.79,8c1.32,4.61,3.01,9.22,4.61,13.83c1.5,4.42,3.29,8.84,6.58,12.23 c0.85,0.94,1.88,1.69,2.82,2.45c2.26,1.88,4.99,3.01,7.71,3.95c2.54,0.85,5.17,1.5,7.81,2.07c4.7,1.03,11.48,2.82,16.08,0.66 c2.54,-1.13,4.61,-2.92,6.3,-5.08c1.79,-2.26,3.2,-4.8,4.42,-7.43c1.88,-3.95,3.86,-8.37,4.14,-12.89 C117.99,87.38,117.24,83.24,116.4,79.29z"/>
|
||||||
|
|
||||||
|
<!-- Head -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M77.64,33.57c-0.28,-1.03,-1.03,-2.07,-1.6,-3.01c-6.3,-11.01,-20.04,-16.27,-32.26,-15.52 c-3.76,0.28,-9.31,0.85,-13.54,2.73c-2.07,0.94,-3.86,2.35,-4.99,4.14c-2.54,4.23,-3.76,8.94,-5.08,13.64 C18.67,41,17.35,46.55,16.5,52.2c-0.75,4.89,-1.41,10.25,-0.09,15.14c1.03,3.86,3.29,9.22,5.74,12.32 c2.73,3.39,6.58,7.34,10.72,8.84c0.75,0.28,1.6,0.47,2.45,0.66c1.6,0.28,3.29,0.47,4.89,0.19c0.94,-0.19,1.98,-0.28,2.92,-0.56 c1.88,-0.47,3.67,-1.13,5.46,-1.79c7.52,-3.01,13.64,-7.43,17.68,-14.58c1.69,-3.1,3.1,-6.4,4.42,-9.69c0.09,-0.19,0.19,-0.38,0.19,-0.56 c1.98,-5.46,3.29,-11.19,4.61,-16.84c0.66,-2.73,1.41,-5.55,1.79,-8.37C77.55,35.92,77.92,34.7,77.64,33.57z"/>
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportHeight="108"
|
||||||
|
android:viewportWidth="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#2b0037"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
</vector>
|
||||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,53 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="240dp"
|
||||||
|
android:height="240dp"
|
||||||
|
android:viewportWidth="1200"
|
||||||
|
android:viewportHeight="1200">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Android 12 splash screen masks the icon to a circle at 2/3 of canvas (160dp of 240dp).
|
||||||
|
The Shakespeare logo SVG has viewBox="0 0 128 128".
|
||||||
|
We scale the 128x128 logo to fit ~800x800 in the center of 1200x1200,
|
||||||
|
leaving ~200px padding on each side for the circular safe zone.
|
||||||
|
Scale factor: 800/128 = 6.25. Translate: (200, 200) to shift origin.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<group
|
||||||
|
android:translateX="200"
|
||||||
|
android:translateY="200"
|
||||||
|
android:scaleX="6.25"
|
||||||
|
android:scaleY="6.25">
|
||||||
|
|
||||||
|
<!-- Red beak right -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M110.28,61.32l2.63,8.84c0,0,7.24,-1.6,7.62,3.2c0.38,4.8,-6.77,8,-6.77,8l2.26,10.63 c0,0,7.9,-6.4,8,-15.61c0,0,0.66,-11.29,-6.11,-13.92C113.67,60.85,110.28,61.32,110.28,61.32z"/>
|
||||||
|
|
||||||
|
<!-- Red tail feathers -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M68.71,94.99c0,0,-11.1,-4.7,-16.46,1.98c-0.75,0.94,-1.41,1.88,-2.16,2.82 c-0.56,0.75,-1.13,1.5,-1.69,2.16c-0.47,0.56,-1.03,1.13,-1.69,1.5c-0.66,0.38,-1.32,0.66,-2.07,0.85c-0.94,0.19,-1.88,0.19,-2.82,0.09 c-1.32,-0.09,-2.63,-0.38,-3.95,-0.66c-0.47,-0.09,-0.85,-0.19,-1.22,-0.28c-0.09,0,-0.19,-0.09,-0.28,-0.09 s-0.19,-0.09,-0.28,-0.09c-0.38,0.09,0.19,0.75,0.38,0.94c0.28,0.28,0.56,0.66,0.85,0.94c0.85,0.75,1.69,1.5,2.73,1.98 c1.32,0.66,2.73,1.03,4.14,1.13c0.09,0,0.38,0,0.47,0.09c0.19,0.19,-0.28,0.47,-0.47,0.56c-0.28,0.19,-0.47,0.28,-0.75,0.38 c-0.85,0.38,-1.79,0.56,-2.63,0.75c-0.85,0.19,-1.69,0.28,-2.45,0.28c-0.47,0,-0.85,0.09,-1.22,0.09c-0.28,0,-0.56,-0.09,-0.85,0 s0.09,0.47,0.28,0.56c0.38,0.19,0.75,0.47,1.13,0.66c1.13,0.56,2.26,1.03,3.39,1.32c1.5,0.38,3.1,0.56,4.61,0.38 c1.32,-0.19,2.63,-0.56,3.86,-1.03c6.77,-3.1,6.21,-9.59,12.42,-10.16c4.61,-0.38,11.1,2.07,11.1,2.07L68.71,94.99z"/>
|
||||||
|
|
||||||
|
<!-- Red beak left -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M19.79,38.28c0,0,-12.13,1.98,-15.24,12.79C0.61,64.9,20.26,69.5,20.26,69.5l1.22,-9.41 c0,0,-13.07,-1.32,-12.32,-6.3c0.94,-6.21,11.85,-5.64,11.85,-5.64L19.79,38.28z"/>
|
||||||
|
|
||||||
|
<!-- Red wing detail -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M20.73,70.92c0,0,-1.88,0.56,-4.61,2.54c-1.88,1.32,-4.42,3.01,-6.87,5.93 c-1.22,1.41,-2.16,3.1,-2.82,4.89c-0.47,1.22,-0.66,2.45,-0.66,3.76c0,0.28,0,0.56,0,0.85c0,0.09,0,0.85,0.28,0.66 c0.09,-0.09,0.19,-0.38,0.28,-0.47c0.19,-0.47,0.47,-0.85,0.75,-1.22c0.85,-1.13,1.88,-2.16,3.01,-3.01c0.38,-0.28,0.75,-0.47,1.13,-0.66 c0.28,-0.28,0.75,-0.66,0.94,-0.28c0.09,0.19,-0.09,0.47,-0.19,0.66c-0.09,0.28,-0.19,0.66,-0.19,0.94c-0.38,1.5,-0.56,3.01,-0.75,4.51 c-0.09,0.85,-0.09,1.69,0,2.45c0,0.38,0.09,0.85,0.09,1.22c0,0.19,0.09,0.38,0.09,0.56c0,0.19,0.19,0.47,0.38,0.19 c0.09,-0.09,0.09,-0.19,0.19,-0.38c0.19,-0.28,0.28,-0.66,0.47,-0.94c0.47,-0.85,0.94,-1.69,1.5,-2.63c0.66,-1.13,1.41,-2.16,2.16,-3.1 c0.85,-1.13,1.88,-2.26,2.92,-3.2c1.13,-1.03,2.35,-2.07,3.67,-2.92c0.75,-0.47,1.6,-0.94,2.45,-1.32L20.73,70.92z"/>
|
||||||
|
|
||||||
|
<!-- Yellow body -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M116.4,79.29c-1.13,-5.55,-2.73,-11.01,-4.51,-16.46c-1.5,-4.61,-3.1,-9.31,-5.83,-13.36 c-1.22,-1.79,-3.01,-3.01,-5.27,-3.86c-4.33,-1.69,-9.97,-1.98,-13.73,-1.98c-5.64,0,-11.48,1.22,-16.74,3.67 c-1.88,5.64,-7.05,19.94,-14.86,26.34c0.47,2.63,1.03,5.36,1.79,8c1.32,4.61,3.01,9.22,4.61,13.83c1.5,4.42,3.29,8.84,6.58,12.23 c0.85,0.94,1.88,1.69,2.82,2.45c2.26,1.88,4.99,3.01,7.71,3.95c2.54,0.85,5.17,1.5,7.81,2.07c4.7,1.03,11.48,2.82,16.08,0.66 c2.54,-1.13,4.61,-2.92,6.3,-5.08c1.79,-2.26,3.2,-4.8,4.42,-7.43c1.88,-3.95,3.86,-8.37,4.14,-12.89 C117.99,87.38,117.24,83.24,116.4,79.29z"/>
|
||||||
|
|
||||||
|
<!-- Blue head -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M77.64,33.57c-0.28,-1.03,-1.03,-2.07,-1.6,-3.01c-6.3,-11.01,-20.04,-16.27,-32.26,-15.52 c-3.76,0.28,-9.31,0.85,-13.54,2.73c-2.07,0.94,-3.86,2.35,-4.99,4.14c-2.54,4.23,-3.76,8.94,-5.08,13.64 C18.67,41,17.35,46.55,16.5,52.2c-0.75,4.89,-1.41,10.25,-0.09,15.14c1.03,3.86,3.29,9.22,5.74,12.32 c2.73,3.39,6.58,7.34,10.72,8.84c0.75,0.28,1.6,0.47,2.45,0.66c1.6,0.28,3.29,0.47,4.89,0.19c0.94,-0.19,1.98,-0.28,2.92,-0.56 c1.88,-0.47,3.67,-1.13,5.46,-1.79c7.52,-3.01,13.64,-7.43,17.68,-14.58c1.69,-3.1,3.1,-6.4,4.42,-9.69c0.09,-0.19,0.19,-0.38,0.19,-0.56 c1.98,-5.46,3.29,-11.19,4.61,-16.84c0.66,-2.73,1.41,-5.55,1.79,-8.37C77.55,35.92,77.92,34.7,77.64,33.57z"/>
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#2b0037</color>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Shakespeare</string>
|
||||||
|
<string name="title_activity_main">Shakespeare</string>
|
||||||
|
<string name="package_name">diy.shakespeare.app</string>
|
||||||
|
<string name="custom_url_scheme">diy.shakespeare.app</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
<item name="android:background">@null</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
|
||||||
|
<item name="windowSplashScreenBackground">#2b0037</item>
|
||||||
|
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon_vector</item>
|
||||||
|
<item name="postSplashScreenTheme">@style/AppTheme.NoActionBar</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<external-path name="my_images" path="." />
|
||||||
|
<cache-path name="my_cache_images" path="." />
|
||||||
|
</paths>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.getcapacitor.myapp;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() throws Exception {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:8.13.0'
|
||||||
|
classpath 'com.google.gms:google-services:4.4.4'
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "variables.gradle"
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||||
|
include ':capacitor-android'
|
||||||
|
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
|
||||||
|
|
||||||
|
include ':capacitor-app'
|
||||||
|
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
|
||||||
|
|
||||||
|
include ':capacitor-status-bar'
|
||||||
|
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
include ':app'
|
||||||
|
include ':capacitor-cordova-android-plugins'
|
||||||
|
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
|
||||||
|
|
||||||
|
apply from: 'capacitor.settings.gradle'
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
ext {
|
||||||
|
minSdkVersion = 24
|
||||||
|
compileSdkVersion = 36
|
||||||
|
targetSdkVersion = 36
|
||||||
|
androidxActivityVersion = '1.11.0'
|
||||||
|
androidxAppCompatVersion = '1.7.1'
|
||||||
|
androidxCoordinatorLayoutVersion = '1.3.0'
|
||||||
|
androidxCoreVersion = '1.17.0'
|
||||||
|
androidxFragmentVersion = '1.8.9'
|
||||||
|
coreSplashScreenVersion = '1.2.0'
|
||||||
|
androidxWebkitVersion = '1.14.0'
|
||||||
|
junitVersion = '4.13.2'
|
||||||
|
androidxJunitVersion = '1.3.0'
|
||||||
|
androidxEspressoCoreVersion = '3.7.0'
|
||||||
|
cordovaAndroidVersion = '14.0.1'
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import type { CapacitorConfig } from '@capacitor/cli';
|
||||||
|
|
||||||
|
const config: CapacitorConfig = {
|
||||||
|
appId: 'diy.shakespeare.app',
|
||||||
|
appName: 'Shakespeare',
|
||||||
|
webDir: 'dist',
|
||||||
|
server: {
|
||||||
|
// Handle deep links from your domain
|
||||||
|
hostname: 'shakespeare.diy',
|
||||||
|
androidScheme: 'https',
|
||||||
|
iosScheme: 'https'
|
||||||
|
},
|
||||||
|
android: {
|
||||||
|
// Enable safe area handling for notches and navigation bars
|
||||||
|
allowMixedContent: false,
|
||||||
|
backgroundColor: '#2b0037'
|
||||||
|
},
|
||||||
|
ios: {
|
||||||
|
backgroundColor: '#2b0037',
|
||||||
|
contentInset: 'automatic',
|
||||||
|
scheme: 'Shakespeare'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -284,7 +284,7 @@ export function useNewProviderOAuth() {
|
|||||||
redirectUri: window.location.origin + '/oauth/newprovider',
|
redirectUri: window.location.origin + '/oauth/newprovider',
|
||||||
usePKCE: false, // Set to true if provider supports PKCE
|
usePKCE: false, // Set to true if provider supports PKCE
|
||||||
getUserInfo: async (accessToken: string, corsProxy: string) => {
|
getUserInfo: async (accessToken: string, corsProxy: string) => {
|
||||||
const userUrl = proxyUrl(corsProxy, 'https://api.provider.com/user');
|
const userUrl = proxyUrl({ template: corsProxy, url: 'https://api.provider.com/user' });
|
||||||
const userResponse = await fetch(userUrl, {
|
const userResponse = await fetch(userUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${accessToken}`,
|
'Authorization': `Bearer ${accessToken}`,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import htmlParser from "@html-eslint/parser";
|
|||||||
import customRules from "./eslint-rules/index.js";
|
import customRules from "./eslint-rules/index.js";
|
||||||
|
|
||||||
export default tseslint.config(
|
export default tseslint.config(
|
||||||
{ ignores: ["dist", "electron/dist"] },
|
{ ignores: ["dist"] },
|
||||||
{
|
{
|
||||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||||
files: ["**/*.{ts,tsx}"],
|
files: ["**/*.{ts,tsx}"],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment",
|
"description": "Build custom apps with AI assistance using Shakespeare, an open-source development environment",
|
||||||
"homepage": "https://shakespeare.diy",
|
"homepage": "https://shakespeare.diy",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"version": "0.0.0",
|
"version": "9.10.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "shakespeare.diy",
|
"name": "shakespeare.diy",
|
||||||
@@ -17,20 +17,27 @@
|
|||||||
"dev": "npm i --silent && vite",
|
"dev": "npm i --silent && vite",
|
||||||
"build": "npm i --silent && vite build -l error && cp dist/index.html dist/404.html && echo 'Project built successfully!'",
|
"build": "npm i --silent && vite build -l error && cp dist/index.html dist/404.html && echo 'Project built successfully!'",
|
||||||
"typecheck": "npm i --silent && tsc --noEmit",
|
"typecheck": "npm i --silent && tsc --noEmit",
|
||||||
"test": "npm i --silent && eslint && vitest run --reporter=dot --silent && echo 'All tests passed!'"
|
"test": "npm i --silent && eslint && vitest run --reporter=dot --silent && echo 'All tests passed!'",
|
||||||
|
"keygen": "keytool -genkey -v -keystore android/app/my-upload-key.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias upload",
|
||||||
|
"icons": "bash scripts/generate-icons.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@capacitor/app": "^8.1.0",
|
||||||
|
"@capacitor/core": "^8.3.0",
|
||||||
|
"@capacitor/status-bar": "^8.0.2",
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@fontsource-variable/inter": "^5.2.6",
|
"@fontsource-variable/inter": "^5.2.6",
|
||||||
"@getalby/sdk": "^6.0.1",
|
"@getalby/sdk": "^6.0.1",
|
||||||
"@hookform/resolvers": "^3.9.0",
|
"@hookform/resolvers": "^5.2.2",
|
||||||
"@isomorphic-git/lightning-fs": "^4.6.2",
|
"@isomorphic-git/lightning-fs": "^4.6.2",
|
||||||
"@modelcontextprotocol/sdk": "^1.22.0",
|
"@modelcontextprotocol/sdk": "^1.22.0",
|
||||||
"@mozilla/readability": "^0.6.0",
|
"@mozilla/readability": "^0.6.0",
|
||||||
"@nostrify/nostrify": "^0.48.2",
|
"@nostrify/nostrify": "^0.49.2",
|
||||||
"@nostrify/react": "^0.2.20",
|
"@nostrify/react": "^0.2.24",
|
||||||
|
"@opensecret/react": "^1.5.4",
|
||||||
|
"@plausible-analytics/tracker": "^0.4.4",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||||
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
"@radix-ui/react-aspect-ratio": "^1.1.0",
|
||||||
@@ -81,7 +88,7 @@
|
|||||||
"mime": "^4.1.0",
|
"mime": "^4.1.0",
|
||||||
"nostr-tools": "^2.15.2",
|
"nostr-tools": "^2.15.2",
|
||||||
"nunjucks": "^3.2.4",
|
"nunjucks": "^3.2.4",
|
||||||
"openai": "^5.15.0",
|
"openai": "^6.16.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"prismjs": "^1.30.0",
|
"prismjs": "^1.30.0",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
@@ -89,7 +96,7 @@
|
|||||||
"react-day-picker": "^8.10.1",
|
"react-day-picker": "^8.10.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-error-boundary": "^6.0.0",
|
"react-error-boundary": "^6.0.0",
|
||||||
"react-hook-form": "^7.53.0",
|
"react-hook-form": "^7.71.1",
|
||||||
"react-i18next": "^15.7.3",
|
"react-i18next": "^15.7.3",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-resizable-panels": "^3.0.3",
|
"react-resizable-panels": "^3.0.3",
|
||||||
@@ -106,9 +113,11 @@
|
|||||||
"vaul": "^0.9.3",
|
"vaul": "^0.9.3",
|
||||||
"webln": "^0.3.2",
|
"webln": "^0.3.2",
|
||||||
"workbox-window": "^7.3.0",
|
"workbox-window": "^7.3.0",
|
||||||
"zod": "^3.25.76"
|
"zod": "^4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@capacitor/android": "^8.3.0",
|
||||||
|
"@capacitor/cli": "^8.3.0",
|
||||||
"@eslint/js": "^9.9.0",
|
"@eslint/js": "^9.9.0",
|
||||||
"@html-eslint/eslint-plugin": "^0.41.0",
|
"@html-eslint/eslint-plugin": "^0.41.0",
|
||||||
"@html-eslint/parser": "^0.41.0",
|
"@html-eslint/parser": "^0.41.0",
|
||||||
@@ -116,6 +125,7 @@
|
|||||||
"@testing-library/jest-dom": "^6.6.3",
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
"@testing-library/react": "^16.3.0",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@testing-library/user-event": "^14.6.1",
|
"@testing-library/user-event": "^14.6.1",
|
||||||
|
"@types/jsdom": "^27.0.0",
|
||||||
"@types/jszip": "^3.4.0",
|
"@types/jszip": "^3.4.0",
|
||||||
"@types/node": "^22.5.5",
|
"@types/node": "^22.5.5",
|
||||||
"@types/nunjucks": "^3.2.6",
|
"@types/nunjucks": "^3.2.6",
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [9.10.1] - 2026-04-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix Android app showing default Capacitor icon instead of Shakespeare logo in app drawer
|
||||||
|
|
||||||
|
## [9.10.0] - 2026-04-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Android app powered by Capacitor with deep links, splash screen, and signed release builds
|
||||||
|
- CI pipeline for building APKs, publishing to GitLab releases, and distributing via Zapstore
|
||||||
|
- Nsite deployment for decentralized hosting via Nostr
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Make version number on mobile settings a clickable link to the changelog with build date
|
||||||
|
|
||||||
|
## [9.9.2] - 2026-04-02
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Simplify nsite deployment to always use named sites, removing the root site option
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix crash in "What's new" toast when used outside the router context
|
||||||
|
- Truncate long changelog excerpts in update notifications so they fit neatly in the toast
|
||||||
|
- Left-align changelog page content for better readability
|
||||||
|
|
||||||
|
## [9.9.1] - 2026-04-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Changelog page and versioning system with "What's new" toast notifications on updates
|
||||||
|
- Release skill for managing versioned releases with changelog generation and git tagging
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Colors for output
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo -e "${GREEN}Generating app icons...${NC}\n"
|
||||||
|
|
||||||
|
# Check for inkscape (preferred) or rsvg-convert as fallback
|
||||||
|
if command -v inkscape &> /dev/null; then
|
||||||
|
SVG_RENDERER="inkscape"
|
||||||
|
elif command -v rsvg-convert &> /dev/null; then
|
||||||
|
SVG_RENDERER="rsvg"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Warning: neither inkscape nor rsvg-convert found. Install one to render SVG icons.${NC}"
|
||||||
|
echo "On Fedora/RHEL: sudo dnf install inkscape"
|
||||||
|
echo "On Ubuntu/Debian: sudo apt-get install inkscape"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if ImageMagick is installed (needed for compositing).
|
||||||
|
# ImageMagick 7+ uses `magick`; ImageMagick 6 (Ubuntu/Debian) uses `convert`.
|
||||||
|
if command -v magick &> /dev/null; then
|
||||||
|
MAGICK="magick"
|
||||||
|
elif command -v convert &> /dev/null; then
|
||||||
|
MAGICK="convert"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Warning: ImageMagick not found. Please install it to generate icons.${NC}"
|
||||||
|
echo "On Fedora/RHEL: sudo dnf install ImageMagick"
|
||||||
|
echo "On Ubuntu/Debian: sudo apt-get install imagemagick"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source SVG logo
|
||||||
|
SOURCE_SVG="public/shakespeare.svg"
|
||||||
|
|
||||||
|
if [ ! -f "$SOURCE_SVG" ]; then
|
||||||
|
echo -e "${YELLOW}Error: Source logo not found at $SOURCE_SVG${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Brand colors
|
||||||
|
BG_COLOR="#2b0037" # Shakespeare purple
|
||||||
|
|
||||||
|
TMPDIR=$(mktemp -d)
|
||||||
|
LOGO_WHITE_SVG="$TMPDIR/logo_white.svg"
|
||||||
|
LOGO_WHITE="$TMPDIR/logo_white.png"
|
||||||
|
|
||||||
|
# Recolor the SVG fills to white before rasterizing.
|
||||||
|
sed -E 's/fill:#[0-9A-Fa-f]{6}/fill:#ffffff/g' "$SOURCE_SVG" > "$LOGO_WHITE_SVG"
|
||||||
|
|
||||||
|
echo "Rendering white SVG at 512x512..."
|
||||||
|
|
||||||
|
if [ "$SVG_RENDERER" = "inkscape" ]; then
|
||||||
|
inkscape --export-type=png --export-filename="$LOGO_WHITE" -w 512 -h 512 "$LOGO_WHITE_SVG" 2>/dev/null
|
||||||
|
else
|
||||||
|
rsvg-convert -w 512 -h 512 "$LOGO_WHITE_SVG" -o "$LOGO_WHITE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Adaptive icon foreground PNGs (transparent bg, white logo, safe-zone padding) ──
|
||||||
|
# Content at 47% of canvas to fit within Android's adaptive icon safe zone.
|
||||||
|
|
||||||
|
echo "Generating adaptive foreground PNGs..."
|
||||||
|
|
||||||
|
make_foreground() {
|
||||||
|
local size=$1
|
||||||
|
local content_size=$(echo "$size * 47 / 100" | bc)
|
||||||
|
local dest=$2
|
||||||
|
$MAGICK -size "${size}x${size}" "xc:none" \
|
||||||
|
\( "$LOGO_WHITE" -resize "${content_size}x${content_size}" \) \
|
||||||
|
-gravity center -compose over -composite \
|
||||||
|
"$dest"
|
||||||
|
}
|
||||||
|
|
||||||
|
make_foreground 48 android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
|
||||||
|
make_foreground 72 android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
|
||||||
|
make_foreground 96 android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
|
||||||
|
make_foreground 144 android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
|
||||||
|
make_foreground 192 android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
|
||||||
|
|
||||||
|
# ── Legacy launcher icons (ic_launcher.png and ic_launcher_round.png) ──
|
||||||
|
# These are used on pre-API-26 devices and as fallback on some launchers.
|
||||||
|
# They must have the logo composited onto the purple background — NOT just
|
||||||
|
# a solid color fill.
|
||||||
|
|
||||||
|
echo "Generating legacy launcher icons (ic_launcher.png and ic_launcher_round.png)..."
|
||||||
|
|
||||||
|
# make_legacy_square: logo on flat purple square background
|
||||||
|
make_legacy_square() {
|
||||||
|
local size=$1
|
||||||
|
local content_size=$(echo "$size * 60 / 100" | bc)
|
||||||
|
local dest=$2
|
||||||
|
$MAGICK -size "${size}x${size}" "xc:${BG_COLOR}" \
|
||||||
|
\( "$LOGO_WHITE" -resize "${content_size}x${content_size}" \) \
|
||||||
|
-gravity center -compose over -composite \
|
||||||
|
"$dest"
|
||||||
|
}
|
||||||
|
|
||||||
|
# make_legacy_round: logo on circular purple background (alpha-masked circle)
|
||||||
|
make_legacy_round() {
|
||||||
|
local size=$1
|
||||||
|
local content_size=$(echo "$size * 60 / 100" | bc)
|
||||||
|
local dest=$2
|
||||||
|
local mask="$TMPDIR/circle_mask_${size}.png"
|
||||||
|
# Create a white circle mask
|
||||||
|
$MAGICK -size "${size}x${size}" "xc:none" \
|
||||||
|
-fill white -draw "circle $((size/2)),$((size/2)) $((size/2)),0" \
|
||||||
|
"$mask"
|
||||||
|
# Fill purple, apply circle mask, composite logo
|
||||||
|
$MAGICK -size "${size}x${size}" "xc:${BG_COLOR}" \
|
||||||
|
"$mask" -compose dst-in -composite \
|
||||||
|
\( "$LOGO_WHITE" -resize "${content_size}x${content_size}" \) \
|
||||||
|
-gravity center -compose over -composite \
|
||||||
|
"$dest"
|
||||||
|
}
|
||||||
|
|
||||||
|
make_legacy_square 48 android/app/src/main/res/mipmap-mdpi/ic_launcher.png
|
||||||
|
make_legacy_square 72 android/app/src/main/res/mipmap-hdpi/ic_launcher.png
|
||||||
|
make_legacy_square 96 android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
|
||||||
|
make_legacy_square 144 android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
|
||||||
|
make_legacy_square 192 android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
|
||||||
|
|
||||||
|
make_legacy_round 48 android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
|
||||||
|
make_legacy_round 72 android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
|
||||||
|
make_legacy_round 96 android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
|
||||||
|
make_legacy_round 144 android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
|
||||||
|
make_legacy_round 192 android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
|
||||||
|
|
||||||
|
# Update background color
|
||||||
|
BACKGROUND_COLOR_FILE="android/app/src/main/res/values/ic_launcher_background.xml"
|
||||||
|
mkdir -p android/app/src/main/res/values
|
||||||
|
cat > "$BACKGROUND_COLOR_FILE" << 'EOF'
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#2b0037</color>
|
||||||
|
</resources>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ── iOS App Icon (1024x1024, white logo on purple background) ──
|
||||||
|
|
||||||
|
echo "Generating iOS app icon..."
|
||||||
|
|
||||||
|
IOS_ICON_DIR="ios/App/App/Assets.xcassets/AppIcon.appiconset"
|
||||||
|
|
||||||
|
if [ -d "$IOS_ICON_DIR" ]; then
|
||||||
|
IOS_ICON="$IOS_ICON_DIR/[email protected]"
|
||||||
|
# Logo at ~60% of canvas, centered on purple background (matches legacy Android style)
|
||||||
|
$MAGICK -size "1024x1024" "xc:${BG_COLOR}" \
|
||||||
|
\( "$LOGO_WHITE" -resize "614x614" \) \
|
||||||
|
-gravity center -compose over -composite \
|
||||||
|
"$IOS_ICON"
|
||||||
|
echo -e " ${GREEN}✓${NC} $IOS_ICON"
|
||||||
|
else
|
||||||
|
echo -e " ${YELLOW}Skipped: $IOS_ICON_DIR not found${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cleanup temp files
|
||||||
|
rm -rf "$TMPDIR"
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}App icons generated successfully!${NC}"
|
||||||
|
echo -e "Icon: white Shakespeare logo on ${GREEN}${BG_COLOR}${NC} (Shakespeare purple)"
|
||||||
|
echo -e "Generated:"
|
||||||
|
echo -e " Android:"
|
||||||
|
echo -e " - ic_launcher_foreground.png (adaptive, all densities)"
|
||||||
|
echo -e " - ic_launcher.png (legacy square, all densities)"
|
||||||
|
echo -e " - ic_launcher_round.png (legacy round, all densities)"
|
||||||
|
echo -e " iOS:"
|
||||||
|
echo -e " - [email protected] (1024x1024)"
|
||||||
@@ -48,6 +48,11 @@ export default {
|
|||||||
hostname = 'docs.z.ai';
|
hostname = 'docs.z.ai';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deployment-provider-specific hacks
|
||||||
|
if (url.host === 'backboard.railway.com') {
|
||||||
|
hostname = 'railway.com';
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch the favicon from DuckDuckGo's service
|
// Fetch the favicon from DuckDuckGo's service
|
||||||
return fetch(`https://external-content.duckduckgo.com/ip3/${hostname}.ico`);
|
return fetch(`https://external-content.duckduckgo.com/ip3/${hostname}.ico`);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { render } from '@testing-library/react';
|
|
||||||
import { test, expect } from 'vitest';
|
|
||||||
|
|
||||||
import App from './App';
|
|
||||||
|
|
||||||
test('App', () => {
|
|
||||||
const { container } = render(<App />);
|
|
||||||
|
|
||||||
// Basic smoke test to ensure App renders without crashing
|
|
||||||
expect(container).toBeInTheDocument();
|
|
||||||
})
|
|
||||||
@@ -8,13 +8,13 @@ import { Suspense, useEffect } from 'react';
|
|||||||
import LightningFS from '@isomorphic-git/lightning-fs';
|
import LightningFS from '@isomorphic-git/lightning-fs';
|
||||||
import NostrProvider from '@/components/NostrProvider';
|
import NostrProvider from '@/components/NostrProvider';
|
||||||
import { NostrSync } from '@/components/NostrSync';
|
import { NostrSync } from '@/components/NostrSync';
|
||||||
import { Toaster } from "@/components/ui/toaster";
|
|
||||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||||
import { NostrLoginProvider } from '@nostrify/react/login';
|
import { NostrLoginProvider } from '@nostrify/react/login';
|
||||||
import { AppProvider } from '@/components/AppProvider';
|
import { AppProvider } from '@/components/AppProvider';
|
||||||
import { AppConfig } from '@/contexts/AppContext';
|
import { AppConfig } from '@/contexts/AppContext';
|
||||||
import { useAppContext } from '@/hooks/useAppContext';
|
import { useAppContext } from '@/hooks/useAppContext';
|
||||||
import { SentryProvider } from '@/components/SentryProvider';
|
import { SentryProvider } from '@/components/SentryProvider';
|
||||||
|
import { PlausibleProvider } from '@/components/PlausibleProvider';
|
||||||
import { AISettingsProvider } from '@/components/AISettingsProvider';
|
import { AISettingsProvider } from '@/components/AISettingsProvider';
|
||||||
import { GitSettingsProvider } from '@/components/GitSettingsProvider';
|
import { GitSettingsProvider } from '@/components/GitSettingsProvider';
|
||||||
import { DeploySettingsProvider } from '@/components/DeploySettingsProvider';
|
import { DeploySettingsProvider } from '@/components/DeploySettingsProvider';
|
||||||
@@ -28,6 +28,8 @@ import { DynamicFavicon } from '@/components/DynamicFavicon';
|
|||||||
import { OfflineIndicator } from '@/components/OfflineIndicator';
|
import { OfflineIndicator } from '@/components/OfflineIndicator';
|
||||||
import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt';
|
import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt';
|
||||||
import { ErrorBoundary } from '@/components/ErrorBoundary';
|
import { ErrorBoundary } from '@/components/ErrorBoundary';
|
||||||
|
import { LockdownModeDetector } from '@/components/LockdownModeDetector';
|
||||||
|
|
||||||
|
|
||||||
import AppRouter from './AppRouter';
|
import AppRouter from './AppRouter';
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ const defaultConfig: AppConfig = {
|
|||||||
relayMetadata: {
|
relayMetadata: {
|
||||||
relays: [
|
relays: [
|
||||||
{ url: 'wss://relay.ditto.pub', read: true, write: true },
|
{ url: 'wss://relay.ditto.pub', read: true, write: true },
|
||||||
{ url: 'wss://relay.nostr.band', read: true, write: true },
|
{ url: 'wss://relay.damus.io', read: true, write: true },
|
||||||
{ url: 'wss://relay.primal.net', read: true, write: true },
|
{ url: 'wss://relay.primal.net', read: true, write: true },
|
||||||
],
|
],
|
||||||
updatedAt: 0,
|
updatedAt: 0,
|
||||||
@@ -70,11 +72,6 @@ const defaultConfig: AppConfig = {
|
|||||||
description: "Build Nostr clients with React. This is the default template that you should choose in the majority of cases. It ships with complete Nostr integration out of the box, enabling a variety of use-cases from social media to blogging to AI-powered apps. If you're not sure which template to choose, choose this one.",
|
description: "Build Nostr clients with React. This is the default template that you should choose in the majority of cases. It ships with complete Nostr integration out of the box, enabling a variety of use-cases from social media to blogging to AI-powered apps. If you're not sure which template to choose, choose this one.",
|
||||||
url: "https://gitlab.com/soapbox-pub/mkstack.git",
|
url: "https://gitlab.com/soapbox-pub/mkstack.git",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Nutstack",
|
|
||||||
description: "This is a variant of MKStack extended to support Cashu integration. Choose this template only if the user has indicated they require Cashu integration.",
|
|
||||||
url: "https://gitlab.com/lemonknowsall/nutstack.git",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
esmUrl: "https://esm.sh",
|
esmUrl: "https://esm.sh",
|
||||||
corsProxy: "https://proxy.shakespeare.diy/?url={href}",
|
corsProxy: "https://proxy.shakespeare.diy/?url={href}",
|
||||||
@@ -91,6 +88,8 @@ const defaultConfig: AppConfig = {
|
|||||||
fsPathTemplates: "/templates",
|
fsPathTemplates: "/templates",
|
||||||
sentryDsn: import.meta.env.VITE_SENTRY_DSN || "",
|
sentryDsn: import.meta.env.VITE_SENTRY_DSN || "",
|
||||||
sentryEnabled: true,
|
sentryEnabled: true,
|
||||||
|
plausibleDomain: import.meta.env.VITE_PLAUSIBLE_DOMAIN || "",
|
||||||
|
plausibleEndpoint: import.meta.env.VITE_PLAUSIBLE_ENDPOINT || "",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize filesystem adapter
|
// Initialize filesystem adapter
|
||||||
@@ -135,6 +134,7 @@ export function App() {
|
|||||||
<UnheadProvider head={head}>
|
<UnheadProvider head={head}>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<AppProvider storageKey="nostr:app-config" defaultConfig={defaultConfig}>
|
<AppProvider storageKey="nostr:app-config" defaultConfig={defaultConfig}>
|
||||||
|
<PlausibleProvider>
|
||||||
<SentryProvider>
|
<SentryProvider>
|
||||||
<FSProvider fs={fs}>
|
<FSProvider fs={fs}>
|
||||||
<ConsoleErrorProvider>
|
<ConsoleErrorProvider>
|
||||||
@@ -148,10 +148,10 @@ export function App() {
|
|||||||
<GitSyncProvider>
|
<GitSyncProvider>
|
||||||
<SessionManagerProvider>
|
<SessionManagerProvider>
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<Toaster />
|
|
||||||
<DynamicFavicon />
|
<DynamicFavicon />
|
||||||
<OfflineIndicator />
|
<OfflineIndicator />
|
||||||
<PWAUpdatePrompt />
|
<PWAUpdatePrompt />
|
||||||
|
<LockdownModeDetector />
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<AppRouter />
|
<AppRouter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
@@ -166,6 +166,7 @@ export function App() {
|
|||||||
</ConsoleErrorProvider>
|
</ConsoleErrorProvider>
|
||||||
</FSProvider>
|
</FSProvider>
|
||||||
</SentryProvider>
|
</SentryProvider>
|
||||||
|
</PlausibleProvider>
|
||||||
</AppProvider>
|
</AppProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</UnheadProvider>
|
</UnheadProvider>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { BrowserRouter, HashRouter, Route, Routes } from "react-router-dom";
|
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
||||||
|
import { Toaster } from "./components/ui/toaster";
|
||||||
import { ScrollToTop } from "./components/ScrollToTop";
|
import { ScrollToTop } from "./components/ScrollToTop";
|
||||||
import { SessionMonitor } from "./components/SessionMonitor";
|
import { SessionMonitor } from "./components/SessionMonitor";
|
||||||
import { URLFragmentHandler } from "./components/URLFragmentHandler";
|
import { URLFragmentHandler } from "./components/URLFragmentHandler";
|
||||||
|
import { VersionCheck } from "./components/VersionCheck";
|
||||||
|
|
||||||
import Index from "./pages/Index";
|
import Index from "./pages/Index";
|
||||||
import Clone from "./pages/Clone";
|
import Clone from "./pages/Clone";
|
||||||
@@ -23,13 +25,13 @@ import { NIP19Page } from "./pages/NIP19Page";
|
|||||||
import NotFound from "./pages/NotFound";
|
import NotFound from "./pages/NotFound";
|
||||||
import { ProjectView } from "./pages/ProjectView";
|
import { ProjectView } from "./pages/ProjectView";
|
||||||
import { SettingsLayout } from "./components/SettingsLayout";
|
import { SettingsLayout } from "./components/SettingsLayout";
|
||||||
|
import { ChangelogPage } from "./pages/ChangelogPage";
|
||||||
|
|
||||||
export function AppRouter() {
|
export function AppRouter() {
|
||||||
// Use HashRouter in Electron, BrowserRouter in web
|
|
||||||
const Router = globalThis.electron ? HashRouter : BrowserRouter;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router>
|
<BrowserRouter>
|
||||||
|
<Toaster />
|
||||||
|
<VersionCheck />
|
||||||
<ScrollToTop />
|
<ScrollToTop />
|
||||||
<SessionMonitor />
|
<SessionMonitor />
|
||||||
<URLFragmentHandler />
|
<URLFragmentHandler />
|
||||||
@@ -52,13 +54,14 @@ export function AppRouter() {
|
|||||||
<Route path="storage" element={<StorageSettings />} />
|
<Route path="storage" element={<StorageSettings />} />
|
||||||
<Route path="about" element={<AboutSettings />} />
|
<Route path="about" element={<AboutSettings />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="/changelog" element={<ChangelogPage />} />
|
||||||
<Route path="/project/:projectId" element={<ProjectView />} />
|
<Route path="/project/:projectId" element={<ProjectView />} />
|
||||||
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
|
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
|
||||||
<Route path="/:nip19" element={<NIP19Page />} />
|
<Route path="/:nip19" element={<NIP19Page />} />
|
||||||
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Router>
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default AppRouter;
|
export default AppRouter;
|
||||||
@@ -19,12 +19,14 @@ interface AIMessageItemProps {
|
|||||||
message: AIMessage;
|
message: AIMessage;
|
||||||
isCurrentlyLoading?: boolean;
|
isCurrentlyLoading?: boolean;
|
||||||
toolCall?: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined; // Tool call data passed from the assistant message
|
toolCall?: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined; // Tool call data passed from the assistant message
|
||||||
|
projectId: string; // Current project ID for path display
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AIMessageItem = memo(({
|
export const AIMessageItem = memo(({
|
||||||
message,
|
message,
|
||||||
isCurrentlyLoading = false,
|
isCurrentlyLoading = false,
|
||||||
toolCall,
|
toolCall,
|
||||||
|
projectId,
|
||||||
}: AIMessageItemProps) => {
|
}: AIMessageItemProps) => {
|
||||||
const [isReasoningExpanded, setIsReasoningExpanded] = useState(false);
|
const [isReasoningExpanded, setIsReasoningExpanded] = useState(false);
|
||||||
const [expandedImageUrl, setExpandedImageUrl] = useState<string | null>(null);
|
const [expandedImageUrl, setExpandedImageUrl] = useState<string | null>(null);
|
||||||
@@ -71,6 +73,7 @@ export const AIMessageItem = memo(({
|
|||||||
toolArgs={toolArgs}
|
toolArgs={toolArgs}
|
||||||
state="completed"
|
state="completed"
|
||||||
result={content}
|
result={content}
|
||||||
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1041,12 +1041,31 @@ export function AIProviderConfigDialog({
|
|||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label htmlFor="provider-auth">{t('authentication')}</Label>
|
<Label htmlFor="provider-auth">{t('authentication')}</Label>
|
||||||
<Select
|
<Select
|
||||||
value={localProvider.nostr ? 'nostr' : 'api-key'}
|
value={localProvider.nostr ? 'nostr' : localProvider.openSecret ? 'opensecret' : 'api-key'}
|
||||||
onValueChange={(value: 'api-key' | 'nostr') => setLocalProvider({
|
onValueChange={(value: 'api-key' | 'nostr' | 'opensecret') => {
|
||||||
|
if (value === 'nostr') {
|
||||||
|
setLocalProvider({
|
||||||
...localProvider,
|
...localProvider,
|
||||||
nostr: value === 'nostr' || undefined,
|
nostr: true,
|
||||||
apiKey: value === 'nostr' ? undefined : localProvider.apiKey
|
openSecret: undefined,
|
||||||
})}
|
apiKey: undefined
|
||||||
|
});
|
||||||
|
} else if (value === 'opensecret') {
|
||||||
|
setLocalProvider({
|
||||||
|
...localProvider,
|
||||||
|
nostr: undefined,
|
||||||
|
openSecret: localProvider.openSecret,
|
||||||
|
apiKey: localProvider.apiKey
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setLocalProvider({
|
||||||
|
...localProvider,
|
||||||
|
nostr: undefined,
|
||||||
|
openSecret: undefined,
|
||||||
|
apiKey: localProvider.apiKey
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
@@ -1054,10 +1073,25 @@ export function AIProviderConfigDialog({
|
|||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="api-key">{t('apiKey')}</SelectItem>
|
<SelectItem value="api-key">{t('apiKey')}</SelectItem>
|
||||||
<SelectItem value="nostr">Nostr</SelectItem>
|
<SelectItem value="nostr">Nostr</SelectItem>
|
||||||
|
<SelectItem value="opensecret">OpenSecret</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{localProvider.openSecret && (
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label htmlFor="provider-opensecret-url">
|
||||||
|
OpenSecret API URL <span className="text-destructive">*</span>
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="provider-opensecret-url"
|
||||||
|
placeholder="https://enclave.trymaple.ai"
|
||||||
|
value={localProvider.openSecret || ''}
|
||||||
|
onChange={(e) => setLocalProvider({ ...localProvider, openSecret: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{!localProvider.nostr && (
|
{!localProvider.nostr && (
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label htmlFor="provider-apiKey">{t('apiKey')}</Label>
|
<Label htmlFor="provider-apiKey">{t('apiKey')}</Label>
|
||||||
@@ -1139,7 +1173,7 @@ export function AIProviderConfigDialog({
|
|||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<Label className="text-sm font-medium">{t('paymentMethod')}</Label>
|
<Label className="text-sm font-medium">{t('paymentMethod')}</Label>
|
||||||
<Tabs value={paymentMethod} onValueChange={(value: 'stripe' | 'lightning') => setPaymentMethod(value)} className="w-full">
|
<Tabs value={paymentMethod} onValueChange={(value) => setPaymentMethod(value as 'stripe' | 'lightning')} className="w-full">
|
||||||
<TabsList className="grid w-full grid-cols-2">
|
<TabsList className="grid w-full grid-cols-2">
|
||||||
<TabsTrigger value="stripe" className="flex items-center gap-2">
|
<TabsTrigger value="stripe" className="flex items-center gap-2">
|
||||||
<CreditCard className="h-4 w-4" />
|
<CreditCard className="h-4 w-4" />
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ export function AddCustomAIProviderDialog({
|
|||||||
const [customIdManuallyEdited, setCustomIdManuallyEdited] = useState(false);
|
const [customIdManuallyEdited, setCustomIdManuallyEdited] = useState(false);
|
||||||
const [customBaseURL, setCustomBaseURL] = useState('');
|
const [customBaseURL, setCustomBaseURL] = useState('');
|
||||||
const [customApiKey, setCustomApiKey] = useState('');
|
const [customApiKey, setCustomApiKey] = useState('');
|
||||||
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr'>('api-key');
|
const [customAuthMethod, setCustomAuthMethod] = useState<'api-key' | 'nostr' | 'opensecret'>('api-key');
|
||||||
|
const [customOpenSecretUrl, setCustomOpenSecretUrl] = useState('');
|
||||||
const [customProxy, setCustomProxy] = useState(false);
|
const [customProxy, setCustomProxy] = useState(false);
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
@@ -66,6 +67,11 @@ export function AddCustomAIProviderDialog({
|
|||||||
provider.apiKey = customApiKey.trim();
|
provider.apiKey = customApiKey.trim();
|
||||||
} else if (customAuthMethod === 'nostr') {
|
} else if (customAuthMethod === 'nostr') {
|
||||||
provider.nostr = true;
|
provider.nostr = true;
|
||||||
|
} else if (customAuthMethod === 'opensecret') {
|
||||||
|
provider.openSecret = customOpenSecretUrl.trim();
|
||||||
|
if (customApiKey.trim()) {
|
||||||
|
provider.apiKey = customApiKey.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customProxy) {
|
if (customProxy) {
|
||||||
@@ -81,6 +87,7 @@ export function AddCustomAIProviderDialog({
|
|||||||
setCustomBaseURL('');
|
setCustomBaseURL('');
|
||||||
setCustomApiKey('');
|
setCustomApiKey('');
|
||||||
setCustomAuthMethod('api-key');
|
setCustomAuthMethod('api-key');
|
||||||
|
setCustomOpenSecretUrl('');
|
||||||
setCustomProxy(false);
|
setCustomProxy(false);
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
@@ -89,6 +96,7 @@ export function AddCustomAIProviderDialog({
|
|||||||
const isValid = customProviderName.trim() &&
|
const isValid = customProviderName.trim() &&
|
||||||
customProviderId.trim() &&
|
customProviderId.trim() &&
|
||||||
customBaseURL.trim() &&
|
customBaseURL.trim() &&
|
||||||
|
(customAuthMethod !== 'opensecret' || customOpenSecretUrl.trim()) &&
|
||||||
!existingIds.includes(customProviderId.trim());
|
!existingIds.includes(customProviderId.trim());
|
||||||
|
|
||||||
const idExists = existingIds.includes(customProviderId.trim());
|
const idExists = existingIds.includes(customProviderId.trim());
|
||||||
@@ -156,7 +164,7 @@ export function AddCustomAIProviderDialog({
|
|||||||
<Label htmlFor="custom-auth">{t('authentication')}</Label>
|
<Label htmlFor="custom-auth">{t('authentication')}</Label>
|
||||||
<Select
|
<Select
|
||||||
value={customAuthMethod}
|
value={customAuthMethod}
|
||||||
onValueChange={(value: 'api-key' | 'nostr') => {
|
onValueChange={(value: 'api-key' | 'nostr' | 'opensecret') => {
|
||||||
setCustomAuthMethod(value);
|
setCustomAuthMethod(value);
|
||||||
if (value === 'nostr') {
|
if (value === 'nostr') {
|
||||||
setCustomApiKey(''); // Clear API key when switching to Nostr auth
|
setCustomApiKey(''); // Clear API key when switching to Nostr auth
|
||||||
@@ -169,11 +177,26 @@ export function AddCustomAIProviderDialog({
|
|||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="api-key">{t('apiKey')}</SelectItem>
|
<SelectItem value="api-key">{t('apiKey')}</SelectItem>
|
||||||
<SelectItem value="nostr">Nostr</SelectItem>
|
<SelectItem value="nostr">Nostr</SelectItem>
|
||||||
|
<SelectItem value="opensecret">OpenSecret</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{customAuthMethod === 'api-key' && (
|
{customAuthMethod === 'opensecret' && (
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label htmlFor="custom-opensecret-url">
|
||||||
|
OpenSecret API URL <span className="text-destructive">*</span>
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="custom-opensecret-url"
|
||||||
|
placeholder="https://enclave.trymaple.ai"
|
||||||
|
value={customOpenSecretUrl}
|
||||||
|
onChange={(e) => setCustomOpenSecretUrl(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(customAuthMethod === 'api-key' || customAuthMethod === 'opensecret') && (
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label htmlFor="custom-apikey">{t('apiKey')}</Label>
|
<Label htmlFor="custom-apikey">{t('apiKey')}</Label>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Check } from 'lucide-react';
|
import { Check } from 'lucide-react';
|
||||||
|
import { UrlListEditor } from '@/components/UrlListEditor';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { PasswordInput } from '@/components/ui/password-input';
|
import { PasswordInput } from '@/components/ui/password-input';
|
||||||
@@ -28,6 +29,7 @@ import type {
|
|||||||
NsiteProvider,
|
NsiteProvider,
|
||||||
CloudflareProvider,
|
CloudflareProvider,
|
||||||
DenoDeployProvider,
|
DenoDeployProvider,
|
||||||
|
RailwayProvider,
|
||||||
} from '@/contexts/DeploySettingsContext';
|
} from '@/contexts/DeploySettingsContext';
|
||||||
|
|
||||||
// Type for provider without the 'id' field (will be generated)
|
// Type for provider without the 'id' field (will be generated)
|
||||||
@@ -37,7 +39,8 @@ type DeployProviderInput =
|
|||||||
| Omit<VercelProvider, 'id'>
|
| Omit<VercelProvider, 'id'>
|
||||||
| Omit<NsiteProvider, 'id'>
|
| Omit<NsiteProvider, 'id'>
|
||||||
| Omit<CloudflareProvider, 'id'>
|
| Omit<CloudflareProvider, 'id'>
|
||||||
| Omit<DenoDeployProvider, 'id'>;
|
| Omit<DenoDeployProvider, 'id'>
|
||||||
|
| Omit<RailwayProvider, 'id'>;
|
||||||
|
|
||||||
interface AddCustomProviderDialogProps {
|
interface AddCustomProviderDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -51,7 +54,7 @@ export function AddCustomProviderDialog({
|
|||||||
onAdd,
|
onAdd,
|
||||||
}: AddCustomProviderDialogProps) {
|
}: AddCustomProviderDialogProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [customProviderType, setCustomProviderType] = useState<'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | ''>('');
|
const [customProviderType, setCustomProviderType] = useState<'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | 'railway' | ''>('');
|
||||||
const [customName, setCustomName] = useState('');
|
const [customName, setCustomName] = useState('');
|
||||||
const [customApiKey, setCustomApiKey] = useState('');
|
const [customApiKey, setCustomApiKey] = useState('');
|
||||||
const [customAccountId, setCustomAccountId] = useState('');
|
const [customAccountId, setCustomAccountId] = useState('');
|
||||||
@@ -61,8 +64,8 @@ export function AddCustomProviderDialog({
|
|||||||
const [customHost, setCustomHost] = useState('');
|
const [customHost, setCustomHost] = useState('');
|
||||||
const [customProxy, setCustomProxy] = useState(false);
|
const [customProxy, setCustomProxy] = useState(false);
|
||||||
const [customGateway, setCustomGateway] = useState('');
|
const [customGateway, setCustomGateway] = useState('');
|
||||||
const [customRelayUrls, setCustomRelayUrls] = useState('');
|
const [customRelayUrls, setCustomRelayUrls] = useState<string[]>([]);
|
||||||
const [customBlossomServers, setCustomBlossomServers] = useState('');
|
const [customBlossomServers, setCustomBlossomServers] = useState<string[]>([]);
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
if (!customProviderType || !customName.trim()) return;
|
if (!customProviderType || !customName.trim()) return;
|
||||||
@@ -82,12 +85,8 @@ export function AddCustomProviderDialog({
|
|||||||
type: 'nsite',
|
type: 'nsite',
|
||||||
name: customName.trim(),
|
name: customName.trim(),
|
||||||
gateway: customGateway.trim() || 'nsite.lol',
|
gateway: customGateway.trim() || 'nsite.lol',
|
||||||
relayUrls: customRelayUrls.trim()
|
relayUrls: customRelayUrls.length > 0 ? customRelayUrls : ['wss://relay.ditto.pub'],
|
||||||
? customRelayUrls.split(',').map(s => s.trim()).filter(Boolean)
|
blossomServers: customBlossomServers.length > 0 ? customBlossomServers : ['https://blossom.primal.net/'],
|
||||||
: ['wss://relay.nostr.band'],
|
|
||||||
blossomServers: customBlossomServers.trim()
|
|
||||||
? customBlossomServers.split(',').map(s => s.trim()).filter(Boolean)
|
|
||||||
: ['https://blossom.primal.net/'],
|
|
||||||
};
|
};
|
||||||
} else if (customProviderType === 'netlify') {
|
} else if (customProviderType === 'netlify') {
|
||||||
if (!customApiKey.trim()) return;
|
if (!customApiKey.trim()) return;
|
||||||
@@ -129,6 +128,15 @@ export function AddCustomProviderDialog({
|
|||||||
...(customBaseDomain?.trim() && { baseDomain: customBaseDomain.trim() }),
|
...(customBaseDomain?.trim() && { baseDomain: customBaseDomain.trim() }),
|
||||||
...(customProxy && { proxy: true }),
|
...(customProxy && { proxy: true }),
|
||||||
};
|
};
|
||||||
|
} else if (customProviderType === 'railway') {
|
||||||
|
if (!customApiKey.trim()) return;
|
||||||
|
provider = {
|
||||||
|
type: 'railway',
|
||||||
|
name: customName.trim(),
|
||||||
|
apiKey: customApiKey.trim(),
|
||||||
|
...(customBaseURL?.trim() && { baseURL: customBaseURL.trim() }),
|
||||||
|
...(customProxy && { proxy: true }),
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return; // Unknown type
|
return; // Unknown type
|
||||||
}
|
}
|
||||||
@@ -146,8 +154,8 @@ export function AddCustomProviderDialog({
|
|||||||
setCustomHost('');
|
setCustomHost('');
|
||||||
setCustomProxy(false);
|
setCustomProxy(false);
|
||||||
setCustomGateway('');
|
setCustomGateway('');
|
||||||
setCustomRelayUrls('');
|
setCustomRelayUrls([]);
|
||||||
setCustomBlossomServers('');
|
setCustomBlossomServers([]);
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
};
|
};
|
||||||
@@ -156,7 +164,8 @@ export function AddCustomProviderDialog({
|
|||||||
(customProviderType === 'shakespeare' || customProviderType === 'nsite' ||
|
(customProviderType === 'shakespeare' || customProviderType === 'nsite' ||
|
||||||
(customApiKey.trim() &&
|
(customApiKey.trim() &&
|
||||||
(customProviderType !== 'cloudflare' || customAccountId.trim()) &&
|
(customProviderType !== 'cloudflare' || customAccountId.trim()) &&
|
||||||
(customProviderType !== 'deno' || customOrganizationId.trim())));
|
(customProviderType !== 'deno' || customOrganizationId.trim()) &&
|
||||||
|
(customProviderType !== 'railway' || true)));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
@@ -175,7 +184,7 @@ export function AddCustomProviderDialog({
|
|||||||
</Label>
|
</Label>
|
||||||
<Select
|
<Select
|
||||||
value={customProviderType}
|
value={customProviderType}
|
||||||
onValueChange={(value: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno') => {
|
onValueChange={(value: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno' | 'railway') => {
|
||||||
setCustomProviderType(value);
|
setCustomProviderType(value);
|
||||||
// Reset form when provider type changes
|
// Reset form when provider type changes
|
||||||
setCustomApiKey('');
|
setCustomApiKey('');
|
||||||
@@ -186,8 +195,8 @@ export function AddCustomProviderDialog({
|
|||||||
setCustomHost('');
|
setCustomHost('');
|
||||||
setCustomProxy(false);
|
setCustomProxy(false);
|
||||||
setCustomGateway('');
|
setCustomGateway('');
|
||||||
setCustomRelayUrls('');
|
setCustomRelayUrls([]);
|
||||||
setCustomBlossomServers('');
|
setCustomBlossomServers([]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
@@ -200,6 +209,7 @@ export function AddCustomProviderDialog({
|
|||||||
<SelectItem value="vercel">Vercel</SelectItem>
|
<SelectItem value="vercel">Vercel</SelectItem>
|
||||||
<SelectItem value="cloudflare">Cloudflare</SelectItem>
|
<SelectItem value="cloudflare">Cloudflare</SelectItem>
|
||||||
<SelectItem value="deno">Deno Deploy</SelectItem>
|
<SelectItem value="deno">Deno Deploy</SelectItem>
|
||||||
|
<SelectItem value="railway">Railway</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
@@ -236,7 +246,7 @@ export function AddCustomProviderDialog({
|
|||||||
) : customProviderType === 'nsite' ? (
|
) : customProviderType === 'nsite' ? (
|
||||||
<>
|
<>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Deploy to Nostr as a static website. Uses kind 34128 events and Blossom file storage.
|
Deploy to Nostr as a static website. Uses a kind 15128 site manifest event and Blossom file storage.
|
||||||
</p>
|
</p>
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label htmlFor="custom-gateway">Gateway</Label>
|
<Label htmlFor="custom-gateway">Gateway</Label>
|
||||||
@@ -247,24 +257,20 @@ export function AddCustomProviderDialog({
|
|||||||
onChange={(e) => setCustomGateway(e.target.value)}
|
onChange={(e) => setCustomGateway(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-2">
|
<UrlListEditor
|
||||||
<Label htmlFor="custom-relays">Relay URLs (comma-separated)</Label>
|
label="Relay URLs"
|
||||||
<Input
|
items={customRelayUrls}
|
||||||
id="custom-relays"
|
onChange={setCustomRelayUrls}
|
||||||
placeholder="wss://relay.nostr.band, wss://relay.damus.io"
|
protocol="wss"
|
||||||
value={customRelayUrls}
|
placeholder="relay.ditto.pub"
|
||||||
onChange={(e) => setCustomRelayUrls(e.target.value)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
<UrlListEditor
|
||||||
<div className="grid gap-2">
|
label="Blossom Servers"
|
||||||
<Label htmlFor="custom-blossom">Blossom Servers (comma-separated)</Label>
|
items={customBlossomServers}
|
||||||
<Input
|
onChange={setCustomBlossomServers}
|
||||||
id="custom-blossom"
|
protocol="https"
|
||||||
placeholder="https://blossom.primal.net/"
|
placeholder="blossom.primal.net"
|
||||||
value={customBlossomServers}
|
|
||||||
onChange={(e) => setCustomBlossomServers(e.target.value)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -299,6 +305,7 @@ export function AddCustomProviderDialog({
|
|||||||
{customProviderType === 'netlify' ? 'Personal Access Token' :
|
{customProviderType === 'netlify' ? 'Personal Access Token' :
|
||||||
customProviderType === 'cloudflare' ? 'API Token' :
|
customProviderType === 'cloudflare' ? 'API Token' :
|
||||||
customProviderType === 'deno' ? 'Access Token' :
|
customProviderType === 'deno' ? 'Access Token' :
|
||||||
|
customProviderType === 'railway' ? 'API Token' :
|
||||||
'Access Token'} <span className="text-destructive">*</span>
|
'Access Token'} <span className="text-destructive">*</span>
|
||||||
</Label>
|
</Label>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
@@ -319,6 +326,8 @@ export function AddCustomProviderDialog({
|
|||||||
? 'https://api.vercel.com'
|
? 'https://api.vercel.com'
|
||||||
: customProviderType === 'deno'
|
: customProviderType === 'deno'
|
||||||
? 'https://api.deno.com/v1'
|
? 'https://api.deno.com/v1'
|
||||||
|
: customProviderType === 'railway'
|
||||||
|
? 'https://backboard.railway.com'
|
||||||
: 'https://api.cloudflare.com/client/v4'
|
: 'https://api.cloudflare.com/client/v4'
|
||||||
}
|
}
|
||||||
value={customBaseURL}
|
value={customBaseURL}
|
||||||
|
|||||||
@@ -0,0 +1,567 @@
|
|||||||
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar';
|
||||||
|
import { useToast } from '@/hooks/useToast';
|
||||||
|
import { useFS } from '@/hooks/useFS';
|
||||||
|
import { useFSPaths } from '@/hooks/useFSPaths';
|
||||||
|
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||||
|
import { useNostrPublish } from '@/hooks/useNostrPublish';
|
||||||
|
import { useUploadFile } from '@/hooks/useUploadFile';
|
||||||
|
import { useAppEvent } from '@/hooks/useAppEvent';
|
||||||
|
import { useProjectDeploySettings } from '@/hooks/useProjectDeploySettings';
|
||||||
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { DotAI } from '@/lib/DotAI';
|
||||||
|
import { buildAppEvent } from '@/lib/appEvent';
|
||||||
|
import {
|
||||||
|
Loader2,
|
||||||
|
Save,
|
||||||
|
Plus,
|
||||||
|
X,
|
||||||
|
ExternalLink,
|
||||||
|
Pencil,
|
||||||
|
Upload,
|
||||||
|
ChevronDown,
|
||||||
|
CircleHelp,
|
||||||
|
} from 'lucide-react';
|
||||||
|
import type { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
|
interface AppDialogProps {
|
||||||
|
projectId: string;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AppFormData {
|
||||||
|
name: string;
|
||||||
|
about: string;
|
||||||
|
picture: string;
|
||||||
|
website: string;
|
||||||
|
dTag: string;
|
||||||
|
supportedKinds: string[];
|
||||||
|
webHandlers: Array<{ url: string; type: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse a kind 31990 event into form data */
|
||||||
|
function eventToFormData(event: NostrEvent): AppFormData {
|
||||||
|
let metadata: Record<string, string> = {};
|
||||||
|
try {
|
||||||
|
if (event.content) {
|
||||||
|
metadata = JSON.parse(event.content);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Invalid JSON content, use empty metadata
|
||||||
|
}
|
||||||
|
|
||||||
|
const dTag = event.tags.find(([t]) => t === 'd')?.[1] ?? '';
|
||||||
|
const supportedKinds = event.tags
|
||||||
|
.filter(([t]) => t === 'k')
|
||||||
|
.map(([, v]) => v)
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
const webHandlers = event.tags
|
||||||
|
.filter(([t]) => t === 'web')
|
||||||
|
.map(([, url, type]) => ({ url: url ?? '', type: type ?? '' }));
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: metadata.name ?? '',
|
||||||
|
about: metadata.about ?? '',
|
||||||
|
picture: metadata.picture ?? '',
|
||||||
|
website: metadata.website ?? '',
|
||||||
|
dTag,
|
||||||
|
supportedKinds,
|
||||||
|
webHandlers,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convert a slug like "my-cool-app" to title case like "My Cool App" */
|
||||||
|
function toTitleCase(slug: string): string {
|
||||||
|
return slug
|
||||||
|
.replace(/[-_]+/g, ' ')
|
||||||
|
.replace(/\b\w/g, (c) => c.toUpperCase())
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create empty form data for a new app */
|
||||||
|
function emptyFormData(projectId: string): AppFormData {
|
||||||
|
return {
|
||||||
|
name: toTitleCase(projectId),
|
||||||
|
about: '',
|
||||||
|
picture: '',
|
||||||
|
website: '',
|
||||||
|
dTag: projectId,
|
||||||
|
supportedKinds: [],
|
||||||
|
webHandlers: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AppDialog({ projectId, open, onOpenChange }: AppDialogProps) {
|
||||||
|
const { fs } = useFS();
|
||||||
|
const { projectsPath } = useFSPaths();
|
||||||
|
const { user } = useCurrentUser();
|
||||||
|
const { toast } = useToast();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { mutateAsync: publishEvent } = useNostrPublish();
|
||||||
|
const { mutateAsync: uploadFile, isPending: isUploading } = useUploadFile();
|
||||||
|
const cwd = `${projectsPath}/${projectId}`;
|
||||||
|
|
||||||
|
const { event, isLoading, aTag, hasApp, refetch } = useAppEvent({ cwd });
|
||||||
|
const { settings: deploySettings, isLoading: isDeployLoading } = useProjectDeploySettings(projectId);
|
||||||
|
|
||||||
|
const [formData, setFormData] = useState<AppFormData>(emptyFormData(projectId));
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
const [newKind, setNewKind] = useState('');
|
||||||
|
const [newHandlerUrl, setNewHandlerUrl] = useState('');
|
||||||
|
const [newHandlerType, setNewHandlerType] = useState('');
|
||||||
|
const [advancedOpen, setAdvancedOpen] = useState(false);
|
||||||
|
|
||||||
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
// Get the deployed URL from project deploy settings
|
||||||
|
const deployedUrl = (() => {
|
||||||
|
if (!deploySettings?.currentProvider || !deploySettings?.providers) return null;
|
||||||
|
const config = deploySettings.providers[deploySettings.currentProvider];
|
||||||
|
return config?.url ?? null;
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Populate form when event loads
|
||||||
|
useEffect(() => {
|
||||||
|
if (event) {
|
||||||
|
setFormData(eventToFormData(event));
|
||||||
|
} else if (!isLoading && !hasApp) {
|
||||||
|
setFormData(emptyFormData(projectId));
|
||||||
|
}
|
||||||
|
}, [event, isLoading, hasApp, projectId]);
|
||||||
|
|
||||||
|
// Auto-fill website from deployment URL when creating a new app (not editing existing)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!hasApp && !isDeployLoading && deployedUrl && !formData.website) {
|
||||||
|
setFormData(prev => ({ ...prev, website: deployedUrl }));
|
||||||
|
}
|
||||||
|
}, [hasApp, isDeployLoading, deployedUrl, formData.website]);
|
||||||
|
|
||||||
|
const updateField = useCallback(<K extends keyof AppFormData>(key: K, value: AppFormData[K]) => {
|
||||||
|
setFormData(prev => ({ ...prev, [key]: value }));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const addKind = useCallback(() => {
|
||||||
|
const kind = newKind.trim();
|
||||||
|
if (kind && !formData.supportedKinds.includes(kind)) {
|
||||||
|
updateField('supportedKinds', [...formData.supportedKinds, kind]);
|
||||||
|
setNewKind('');
|
||||||
|
}
|
||||||
|
}, [newKind, formData.supportedKinds, updateField]);
|
||||||
|
|
||||||
|
const removeKind = useCallback((kind: string) => {
|
||||||
|
updateField('supportedKinds', formData.supportedKinds.filter(k => k !== kind));
|
||||||
|
}, [formData.supportedKinds, updateField]);
|
||||||
|
|
||||||
|
const addHandler = useCallback(() => {
|
||||||
|
const url = newHandlerUrl.trim();
|
||||||
|
if (url) {
|
||||||
|
updateField('webHandlers', [...formData.webHandlers, { url, type: newHandlerType.trim() }]);
|
||||||
|
setNewHandlerUrl('');
|
||||||
|
setNewHandlerType('');
|
||||||
|
}
|
||||||
|
}, [newHandlerUrl, newHandlerType, formData.webHandlers, updateField]);
|
||||||
|
|
||||||
|
const removeHandler = useCallback((index: number) => {
|
||||||
|
updateField('webHandlers', formData.webHandlers.filter((_, i) => i !== index));
|
||||||
|
}, [formData.webHandlers, updateField]);
|
||||||
|
|
||||||
|
const handleIconUpload = useCallback(async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const file = e.target.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const tags = await uploadFile(file);
|
||||||
|
const url = tags[0]?.[1];
|
||||||
|
if (url) {
|
||||||
|
updateField('picture', url);
|
||||||
|
toast({ title: 'Icon uploaded', description: 'Your app icon has been uploaded.' });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: 'Upload failed',
|
||||||
|
description: error instanceof Error ? error.message : 'Failed to upload icon.',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
// Reset input so re-selecting the same file triggers onChange
|
||||||
|
if (fileInputRef.current) {
|
||||||
|
fileInputRef.current.value = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [uploadFile, updateField, toast]);
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
if (!user) {
|
||||||
|
toast({
|
||||||
|
title: 'Not logged in',
|
||||||
|
description: 'You must be logged in with Nostr to publish an app.',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.name.trim()) {
|
||||||
|
toast({
|
||||||
|
title: 'Name required',
|
||||||
|
description: 'Please enter a name for your app.',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.dTag.trim()) {
|
||||||
|
toast({
|
||||||
|
title: 'Identifier required',
|
||||||
|
description: 'Please enter a unique identifier (d-tag) for your app.',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSaving(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Build event content and tags
|
||||||
|
const { content, tags } = await buildAppEvent(
|
||||||
|
{
|
||||||
|
name: formData.name,
|
||||||
|
about: formData.about,
|
||||||
|
picture: formData.picture,
|
||||||
|
website: formData.website,
|
||||||
|
dTag: formData.dTag,
|
||||||
|
supportedKinds: formData.supportedKinds,
|
||||||
|
webHandlers: formData.webHandlers,
|
||||||
|
},
|
||||||
|
{ fs, cwd, pubkey: user.pubkey },
|
||||||
|
);
|
||||||
|
|
||||||
|
// Publish the event
|
||||||
|
const published = await publishEvent({
|
||||||
|
kind: 31990,
|
||||||
|
content,
|
||||||
|
tags,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Store the "a" coordinate in .git/shakespeare/app.json
|
||||||
|
const aValue = `31990:${published.pubkey}:${formData.dTag.trim()}`;
|
||||||
|
const dotAI = new DotAI(fs, cwd);
|
||||||
|
await dotAI.writeAppConfig({ a: aValue });
|
||||||
|
|
||||||
|
// Invalidate queries
|
||||||
|
await queryClient.invalidateQueries({ queryKey: ['app-event'] });
|
||||||
|
await refetch();
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: hasApp ? 'App updated' : 'App published',
|
||||||
|
description: `"${formData.name}" has been ${hasApp ? 'updated' : 'published'} to Nostr.`,
|
||||||
|
});
|
||||||
|
|
||||||
|
onOpenChange(false);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to publish app:', error);
|
||||||
|
toast({
|
||||||
|
title: 'Failed to publish',
|
||||||
|
description: error instanceof Error ? error.message : 'An unexpected error occurred',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<DialogContent className="max-w-md">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>App</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
You must be logged in with Nostr to manage your app.
|
||||||
|
</p>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<DialogContent className="max-w-lg max-h-[85vh] overflow-y-auto">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{hasApp ? 'Edit App' : 'Publish App'}</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
{hasApp
|
||||||
|
? 'Update your app\'s listing on Nostr.'
|
||||||
|
: 'Publish your project as a Nostr app.'}
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
{isLoading ? (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-start gap-4">
|
||||||
|
<Skeleton className="h-20 w-20 rounded-2xl flex-shrink-0" />
|
||||||
|
<div className="flex-1 space-y-2 pt-1">
|
||||||
|
<Skeleton className="h-5 w-40" />
|
||||||
|
<Skeleton className="h-4 w-full" />
|
||||||
|
<Skeleton className="h-4 w-2/3" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-10 w-full" />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-5">
|
||||||
|
{/* App Preview Card */}
|
||||||
|
<div className="flex items-start gap-4">
|
||||||
|
{/* Icon with upload */}
|
||||||
|
<div className="relative flex-shrink-0 group">
|
||||||
|
<input
|
||||||
|
ref={fileInputRef}
|
||||||
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
onChange={handleIconUpload}
|
||||||
|
className="hidden"
|
||||||
|
disabled={isSaving || isUploading}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => fileInputRef.current?.click()}
|
||||||
|
disabled={isSaving || isUploading}
|
||||||
|
className="relative block rounded-2xl overflow-hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none"
|
||||||
|
>
|
||||||
|
{formData.picture ? (
|
||||||
|
<>
|
||||||
|
<Avatar className="h-20 w-20 rounded-2xl">
|
||||||
|
<AvatarImage src={formData.picture} alt={formData.name || 'App icon'} className="object-cover" />
|
||||||
|
<AvatarFallback className="rounded-2xl bg-muted" />
|
||||||
|
</Avatar>
|
||||||
|
<div className="absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-2xl">
|
||||||
|
{isUploading ? (
|
||||||
|
<Loader2 className="h-5 w-5 text-white animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Pencil className="h-4 w-4 text-white" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="h-20 w-20 rounded-2xl bg-muted flex items-center justify-center transition-colors group-hover:bg-muted-foreground">
|
||||||
|
{isUploading ? (
|
||||||
|
<Loader2 className="h-6 w-6 text-muted-foreground animate-spin group-hover:text-background" />
|
||||||
|
) : (
|
||||||
|
<Upload className="h-6 w-6 text-muted-foreground transition-colors group-hover:text-background" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Name & Description inline */}
|
||||||
|
<div className="flex-1 min-w-0 space-y-2">
|
||||||
|
<Input
|
||||||
|
value={formData.name}
|
||||||
|
onChange={e => updateField('name', e.target.value)}
|
||||||
|
placeholder="App Name"
|
||||||
|
disabled={isSaving}
|
||||||
|
/>
|
||||||
|
<Textarea
|
||||||
|
value={formData.about}
|
||||||
|
onChange={e => updateField('about', e.target.value)}
|
||||||
|
placeholder="A short description of your app..."
|
||||||
|
rows={2}
|
||||||
|
disabled={isSaving}
|
||||||
|
className="resize-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Website */}
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label htmlFor="app-website" className="text-xs text-muted-foreground">Website</Label>
|
||||||
|
<Input
|
||||||
|
id="app-website"
|
||||||
|
value={formData.website}
|
||||||
|
onChange={e => updateField('website', e.target.value)}
|
||||||
|
placeholder={deployedUrl || 'https://myapp.example.com'}
|
||||||
|
disabled={isSaving}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Existing app coordinate info */}
|
||||||
|
{aTag && (
|
||||||
|
<div className="text-xs text-muted-foreground space-y-1">
|
||||||
|
<p className="font-medium">Nostr Coordinate</p>
|
||||||
|
<code className="block p-2 bg-muted rounded text-xs break-all select-all">{aTag}</code>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Advanced Section */}
|
||||||
|
<Collapsible open={advancedOpen} onOpenChange={setAdvancedOpen}>
|
||||||
|
<CollapsibleTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex items-center gap-2 w-full text-sm text-muted-foreground hover:text-foreground transition-colors py-2 border-t"
|
||||||
|
>
|
||||||
|
<ChevronDown className={`h-4 w-4 transition-transform ${advancedOpen ? 'rotate-180' : ''}`} />
|
||||||
|
<span>Advanced</span>
|
||||||
|
</button>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
<CollapsibleContent>
|
||||||
|
<div className="space-y-4 pt-2">
|
||||||
|
{/* Hint to use AI */}
|
||||||
|
<div className="flex items-start gap-2 text-xs text-muted-foreground bg-muted/50 rounded-lg p-3">
|
||||||
|
<CircleHelp className="h-3.5 w-3.5 mt-0.5 flex-shrink-0" />
|
||||||
|
<span>Not sure? Ask Shakespeare to update your app.</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Identifier (d-tag) */}
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label htmlFor="app-dtag" className="text-xs">Identifier</Label>
|
||||||
|
<Input
|
||||||
|
id="app-dtag"
|
||||||
|
value={formData.dTag}
|
||||||
|
onChange={e => updateField('dTag', e.target.value)}
|
||||||
|
placeholder="my-app"
|
||||||
|
disabled={isSaving || hasApp}
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{hasApp ? 'Cannot be changed after publishing.' : 'Unique identifier for this app. Defaults to the project ID.'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Supported Kinds */}
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label className="text-xs">Supported Event Kinds</Label>
|
||||||
|
{formData.supportedKinds.length > 0 && (
|
||||||
|
<div className="flex flex-wrap gap-1">
|
||||||
|
{formData.supportedKinds.map(kind => (
|
||||||
|
<Badge key={kind} variant="secondary" className="gap-1">
|
||||||
|
{kind}
|
||||||
|
<button
|
||||||
|
onClick={() => removeKind(kind)}
|
||||||
|
disabled={isSaving}
|
||||||
|
className="hover:text-destructive"
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
value={newKind}
|
||||||
|
onChange={e => setNewKind(e.target.value)}
|
||||||
|
placeholder="Kind number (e.g. 1)"
|
||||||
|
disabled={isSaving}
|
||||||
|
onKeyDown={e => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
addKind();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex-1"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={addKind}
|
||||||
|
disabled={isSaving || !newKind.trim()}
|
||||||
|
className="h-9"
|
||||||
|
>
|
||||||
|
<Plus className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Web Handlers */}
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label className="text-xs">Web Handlers</Label>
|
||||||
|
{formData.webHandlers.length > 0 && (
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
{formData.webHandlers.map((handler, index) => (
|
||||||
|
<div key={index} className="flex items-center gap-2 text-sm bg-muted/50 p-2 rounded-md">
|
||||||
|
<ExternalLink className="h-3 w-3 text-muted-foreground flex-shrink-0" />
|
||||||
|
<span className="truncate flex-1">{handler.url}</span>
|
||||||
|
{handler.type && (
|
||||||
|
<Badge variant="outline" className="text-xs flex-shrink-0">{handler.type}</Badge>
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
onClick={() => removeHandler(index)}
|
||||||
|
disabled={isSaving}
|
||||||
|
className="hover:text-destructive flex-shrink-0"
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
value={newHandlerUrl}
|
||||||
|
onChange={e => setNewHandlerUrl(e.target.value)}
|
||||||
|
placeholder="https://app.example.com/e/<bech32>"
|
||||||
|
disabled={isSaving}
|
||||||
|
className="flex-1"
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
value={newHandlerType}
|
||||||
|
onChange={e => setNewHandlerType(e.target.value)}
|
||||||
|
placeholder="nevent"
|
||||||
|
disabled={isSaving}
|
||||||
|
className="w-24"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={addHandler}
|
||||||
|
disabled={isSaving || !newHandlerUrl.trim()}
|
||||||
|
className="h-9"
|
||||||
|
>
|
||||||
|
<Plus className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
URL patterns where <code className="text-xs">{'<bech32>'}</code> will be replaced with the NIP-19 entity.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CollapsibleContent>
|
||||||
|
</Collapsible>
|
||||||
|
|
||||||
|
{/* Save Button */}
|
||||||
|
<Button
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={isSaving || !formData.name.trim()}
|
||||||
|
className="w-full gap-2"
|
||||||
|
>
|
||||||
|
{isSaving ? (
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Save className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
{isSaving
|
||||||
|
? (hasApp ? 'Updating...' : 'Publishing...')
|
||||||
|
: (hasApp ? 'Update App' : 'Publish App')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -60,6 +60,8 @@ const AppConfigSchema = z.object({
|
|||||||
sentryDsn: z.string(),
|
sentryDsn: z.string(),
|
||||||
sentryEnabled: z.boolean(),
|
sentryEnabled: z.boolean(),
|
||||||
systemPrompt: z.string(),
|
systemPrompt: z.string(),
|
||||||
|
plausibleDomain: z.string(),
|
||||||
|
plausibleEndpoint: z.string(),
|
||||||
}) satisfies z.ZodType<AppConfig>;
|
}) satisfies z.ZodType<AppConfig>;
|
||||||
|
|
||||||
export function AppProvider(props: AppProviderProps) {
|
export function AppProvider(props: AppProviderProps) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { getSentryInstance } from '@/lib/sentry';
|
|||||||
interface ErrorBoundaryProps {
|
interface ErrorBoundaryProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
fallback?: ReactNode | ((props: FallbackProps) => ReactNode);
|
fallback?: ReactNode | ((props: FallbackProps) => ReactNode);
|
||||||
onError?: (error: Error, info: { componentStack: string | null }) => void;
|
onError?: (error: Error, info: { componentStack?: string | null }) => void;
|
||||||
/** Whether to report errors to Sentry (default: true) */
|
/** Whether to report errors to Sentry (default: true) */
|
||||||
reportToSentry?: boolean;
|
reportToSentry?: boolean;
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ export function ErrorBoundary({
|
|||||||
onError,
|
onError,
|
||||||
reportToSentry = true,
|
reportToSentry = true,
|
||||||
}: ErrorBoundaryProps) {
|
}: ErrorBoundaryProps) {
|
||||||
const handleError = (error: Error, info: { componentStack: string | null }) => {
|
const handleError = (error: Error, info: { componentStack?: string | null }) => {
|
||||||
// Log error details for debugging
|
// Log error details for debugging
|
||||||
console.error('ErrorBoundary caught an error:', error, info);
|
console.error('ErrorBoundary caught an error:', error, info);
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ export function ExternalFavicon({
|
|||||||
const parsedUrl = new URL(url);
|
const parsedUrl = new URL(url);
|
||||||
|
|
||||||
// Strip `ai.` and `api.` subdomains for a better chance at finding a favicon
|
// Strip `ai.` and `api.` subdomains for a better chance at finding a favicon
|
||||||
parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.)/, '');
|
parsedUrl.hostname = parsedUrl.hostname.replace(/^(ai\.|api\.|enclave\.)/, '');
|
||||||
|
|
||||||
// Normalize the URL to ensure it has a protocol
|
// Normalize the URL to ensure it has a protocol
|
||||||
return faviconUrl(config.faviconUrl, parsedUrl);
|
return faviconUrl({ template: config.faviconUrl, url: parsedUrl });
|
||||||
} catch {
|
} catch {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
} from '@/components/ui/alert-dialog';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detects if IndexedDB is unavailable (which happens in iOS lockdown mode)
|
||||||
|
* and displays a blocking alert dialog informing the user.
|
||||||
|
*/
|
||||||
|
export function LockdownModeDetector() {
|
||||||
|
const [isLockdownMode, setIsLockdownMode] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Check if IndexedDB is available
|
||||||
|
const checkIndexedDB = async () => {
|
||||||
|
try {
|
||||||
|
// Check if IndexedDB exists
|
||||||
|
if (!window.indexedDB) {
|
||||||
|
setIsLockdownMode(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to open a test database to verify IndexedDB actually works
|
||||||
|
// In iOS lockdown mode, indexedDB exists but throws errors when used
|
||||||
|
const testDBName = '_shakespeare_lockdown_test';
|
||||||
|
const request = window.indexedDB.open(testDBName, 1);
|
||||||
|
|
||||||
|
request.onerror = () => {
|
||||||
|
setIsLockdownMode(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
request.onsuccess = () => {
|
||||||
|
// IndexedDB is working, clean up test database
|
||||||
|
request.result.close();
|
||||||
|
window.indexedDB.deleteDatabase(testDBName);
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
// Any error means IndexedDB is not available
|
||||||
|
setIsLockdownMode(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
checkIndexedDB();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AlertDialog open={isLockdownMode}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle className="text-left">🔒 Lockdown Mode Detected</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription className="space-y-3 text-left">
|
||||||
|
<p>
|
||||||
|
Shakespeare requires IndexedDB to function, which is unavailable in iOS Lockdown Mode.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To use Shakespeare, please disable Lockdown Mode in your device settings:
|
||||||
|
</p>
|
||||||
|
<ol className="list-decimal list-inside space-y-1 text-left ml-4">
|
||||||
|
<li>Open Settings</li>
|
||||||
|
<li>Go to Privacy & Security</li>
|
||||||
|
<li>Tap Lockdown Mode</li>
|
||||||
|
<li>Turn off Lockdown Mode</li>
|
||||||
|
</ol>
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { ReactNode, useEffect, useRef } from 'react';
|
||||||
|
import { useAppContext } from '@/hooks/useAppContext';
|
||||||
|
|
||||||
|
interface PlausibleProviderProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reactively initializes Plausible Analytics from AppConfig.
|
||||||
|
* Plausible's `init()` can only be called once, so we guard with a ref.
|
||||||
|
*/
|
||||||
|
export function PlausibleProvider({ children }: PlausibleProviderProps) {
|
||||||
|
const { config } = useAppContext();
|
||||||
|
const initializedRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initializedRef.current || !config.plausibleDomain) return;
|
||||||
|
initializedRef.current = true;
|
||||||
|
|
||||||
|
import('@plausible-analytics/tracker').then(({ init }) => {
|
||||||
|
init({
|
||||||
|
domain: config.plausibleDomain,
|
||||||
|
...(config.plausibleEndpoint && { endpoint: config.plausibleEndpoint }),
|
||||||
|
});
|
||||||
|
}).catch(console.error);
|
||||||
|
}, [config.plausibleDomain, config.plausibleEndpoint]);
|
||||||
|
|
||||||
|
return <>{children}</>;
|
||||||
|
}
|
||||||
@@ -327,6 +327,7 @@ export function ProjectSidebar({
|
|||||||
className="h-8 w-8 p-0 hover:bg-primary/10 -mr-2"
|
className="h-8 w-8 p-0 hover:bg-primary/10 -mr-2"
|
||||||
onClick={handleToggleSidebar}
|
onClick={handleToggleSidebar}
|
||||||
aria-label={(onClose && isMobile) ? t('closeSidebar') : t('collapseSidebar')}
|
aria-label={(onClose && isMobile) ? t('closeSidebar') : t('collapseSidebar')}
|
||||||
|
title={(onClose && isMobile) ? t('closeSidebar') : t('hidePaneButtonTooltip')}
|
||||||
>
|
>
|
||||||
{(onClose && isMobile) ? (
|
{(onClose && isMobile) ? (
|
||||||
<X className="h-4 w-4 text-primary/60 hover:text-primary" />
|
<X className="h-4 w-4 text-primary/60 hover:text-primary" />
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
ChevronDown,
|
ChevronDown,
|
||||||
Trash2,
|
Trash2,
|
||||||
Star,
|
Star,
|
||||||
|
AppWindow,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||||
@@ -27,7 +28,7 @@ interface ProjectTitleMenuProps {
|
|||||||
onDuplicate: () => void;
|
onDuplicate: () => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
onProjectDetails: () => void;
|
onProjectDetails: () => void;
|
||||||
isAILoading: boolean;
|
onApp: () => void;
|
||||||
isAnyLoading: boolean;
|
isAnyLoading: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
@@ -40,7 +41,7 @@ export function ProjectTitleMenu({
|
|||||||
onDuplicate,
|
onDuplicate,
|
||||||
onDelete,
|
onDelete,
|
||||||
onProjectDetails,
|
onProjectDetails,
|
||||||
isAILoading,
|
onApp,
|
||||||
isAnyLoading,
|
isAnyLoading,
|
||||||
className = '',
|
className = '',
|
||||||
}: ProjectTitleMenuProps) {
|
}: ProjectTitleMenuProps) {
|
||||||
@@ -100,6 +101,15 @@ export function ProjectTitleMenu({
|
|||||||
Project Details
|
Project Details
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={onApp}
|
||||||
|
disabled={isAnyLoading}
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<AppWindow className="h-4 w-4" />
|
||||||
|
App
|
||||||
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={onGitHistory}
|
onClick={onGitHistory}
|
||||||
disabled={isAnyLoading}
|
disabled={isAnyLoading}
|
||||||
@@ -111,7 +121,7 @@ export function ProjectTitleMenu({
|
|||||||
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={onNewChat}
|
onClick={onNewChat}
|
||||||
disabled={isAILoading}
|
disabled={isAnyLoading}
|
||||||
className="gap-2"
|
className="gap-2"
|
||||||
>
|
>
|
||||||
<MessageSquarePlus className="h-4 w-4" />
|
<MessageSquarePlus className="h-4 w-4" />
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
|
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
|
||||||
import type { PresetDeployProvider } from '@/lib/deploy/types';
|
import type { PresetDeployProvider } from '@/lib/deploy/types';
|
||||||
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||||
|
import { UrlListEditor } from '@/components/UrlListEditor';
|
||||||
|
|
||||||
interface ProviderConfigDialogProps {
|
interface ProviderConfigDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -138,34 +139,22 @@ export function ProviderConfigDialog({
|
|||||||
onChange={(e) => setLocalProvider({ ...localProvider, gateway: e.target.value })}
|
onChange={(e) => setLocalProvider({ ...localProvider, gateway: e.target.value })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-2">
|
<UrlListEditor
|
||||||
<Label htmlFor="provider-relays">
|
label="Relay URLs"
|
||||||
Relay URLs (comma-separated) <span className="text-destructive">*</span>
|
items={localProvider.relayUrls ?? []}
|
||||||
</Label>
|
onChange={(urls) => setLocalProvider({ ...localProvider, relayUrls: urls })}
|
||||||
<Input
|
protocol="wss"
|
||||||
id="provider-relays"
|
placeholder="relay.ditto.pub"
|
||||||
placeholder="wss://relay.nostr.band, wss://relay.damus.io"
|
required
|
||||||
value={localProvider.relayUrls?.join(', ') || ''}
|
|
||||||
onChange={(e) => setLocalProvider({
|
|
||||||
...localProvider,
|
|
||||||
relayUrls: e.target.value.split(',').map(s => s.trim()).filter(Boolean)
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
<UrlListEditor
|
||||||
<div className="grid gap-2">
|
label="Blossom Servers"
|
||||||
<Label htmlFor="provider-blossom">
|
items={localProvider.blossomServers ?? []}
|
||||||
Blossom Servers (comma-separated) <span className="text-destructive">*</span>
|
onChange={(servers) => setLocalProvider({ ...localProvider, blossomServers: servers })}
|
||||||
</Label>
|
protocol="https"
|
||||||
<Input
|
placeholder="blossom.primal.net"
|
||||||
id="provider-blossom"
|
required
|
||||||
placeholder="https://blossom.primal.net/"
|
|
||||||
value={localProvider.blossomServers?.join(', ') || ''}
|
|
||||||
onChange={(e) => setLocalProvider({
|
|
||||||
...localProvider,
|
|
||||||
blossomServers: e.target.value.split(',').map(s => s.trim()).filter(Boolean)
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -212,6 +201,8 @@ export function ProviderConfigDialog({
|
|||||||
setLocalProvider({ ...localProvider, apiKey: e.target.value });
|
setLocalProvider({ ...localProvider, apiKey: e.target.value });
|
||||||
} else if (localProvider.type === 'deno') {
|
} else if (localProvider.type === 'deno') {
|
||||||
setLocalProvider({ ...localProvider, apiKey: e.target.value });
|
setLocalProvider({ ...localProvider, apiKey: e.target.value });
|
||||||
|
} else if (localProvider.type === 'railway') {
|
||||||
|
setLocalProvider({ ...localProvider, apiKey: e.target.value });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -227,6 +218,7 @@ export function ProviderConfigDialog({
|
|||||||
localProvider.type === 'vercel' ? 'https://api.vercel.com' :
|
localProvider.type === 'vercel' ? 'https://api.vercel.com' :
|
||||||
localProvider.type === 'cloudflare' ? 'https://api.cloudflare.com/client/v4' :
|
localProvider.type === 'cloudflare' ? 'https://api.cloudflare.com/client/v4' :
|
||||||
localProvider.type === 'deno' ? 'https://api.deno.com/v1' :
|
localProvider.type === 'deno' ? 'https://api.deno.com/v1' :
|
||||||
|
localProvider.type === 'railway' ? 'https://backboard.railway.app/graphql/v2' :
|
||||||
'Base URL'
|
'Base URL'
|
||||||
}
|
}
|
||||||
value={localProvider.baseURL || ''}
|
value={localProvider.baseURL || ''}
|
||||||
@@ -239,6 +231,8 @@ export function ProviderConfigDialog({
|
|||||||
setLocalProvider({ ...localProvider, baseURL: e.target.value });
|
setLocalProvider({ ...localProvider, baseURL: e.target.value });
|
||||||
} else if (localProvider.type === 'deno') {
|
} else if (localProvider.type === 'deno') {
|
||||||
setLocalProvider({ ...localProvider, baseURL: e.target.value });
|
setLocalProvider({ ...localProvider, baseURL: e.target.value });
|
||||||
|
} else if (localProvider.type === 'railway') {
|
||||||
|
setLocalProvider({ ...localProvider, baseURL: e.target.value });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ describe('SentryProvider', () => {
|
|||||||
fsPathTmp: '/tmp',
|
fsPathTmp: '/tmp',
|
||||||
fsPathPlugins: '/plugins',
|
fsPathPlugins: '/plugins',
|
||||||
fsPathTemplates: '/templates',
|
fsPathTemplates: '/templates',
|
||||||
|
plausibleDomain: '',
|
||||||
|
plausibleEndpoint: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
render(
|
render(
|
||||||
@@ -87,6 +89,8 @@ describe('SentryProvider', () => {
|
|||||||
fsPathTmp: '/tmp',
|
fsPathTmp: '/tmp',
|
||||||
fsPathPlugins: '/plugins',
|
fsPathPlugins: '/plugins',
|
||||||
fsPathTemplates: '/templates',
|
fsPathTemplates: '/templates',
|
||||||
|
plausibleDomain: '',
|
||||||
|
plausibleEndpoint: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
render(
|
render(
|
||||||
@@ -130,6 +134,8 @@ describe('SentryProvider', () => {
|
|||||||
fsPathTmp: '/tmp',
|
fsPathTmp: '/tmp',
|
||||||
fsPathPlugins: '/plugins',
|
fsPathPlugins: '/plugins',
|
||||||
fsPathTemplates: '/templates',
|
fsPathTemplates: '/templates',
|
||||||
|
plausibleDomain: '',
|
||||||
|
plausibleEndpoint: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
render(
|
render(
|
||||||
@@ -176,6 +182,8 @@ describe('SentryProvider', () => {
|
|||||||
fsPathTmp: '/tmp',
|
fsPathTmp: '/tmp',
|
||||||
fsPathPlugins: '/plugins',
|
fsPathPlugins: '/plugins',
|
||||||
fsPathTemplates: '/templates',
|
fsPathTemplates: '/templates',
|
||||||
|
plausibleDomain: '',
|
||||||
|
plausibleEndpoint: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
import { useState, useCallback, memo } from 'react';
|
import { useState, useCallback, memo, useRef, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||||
import { CircularProgress } from '@/components/ui/circular-progress';
|
import { CircularProgress } from '@/components/ui/circular-progress';
|
||||||
import { FileAttachment } from '@/components/ui/file-attachment';
|
import { FileAttachment } from '@/components/ui/file-attachment';
|
||||||
|
import { Command, CommandGroup, CommandItem, CommandList } from '@/components/ui/command';
|
||||||
import { Square, ArrowUp } from 'lucide-react';
|
import { Square, ArrowUp } from 'lucide-react';
|
||||||
import { ModelSelector } from '@/components/ModelSelector';
|
import { ModelSelector } from '@/components/ModelSelector';
|
||||||
|
|
||||||
|
export interface SlashCommand {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
action: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
interface ChatInputProps {
|
interface ChatInputProps {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
isConfigured: boolean;
|
isConfigured: boolean;
|
||||||
@@ -29,6 +36,7 @@ interface ChatInputProps {
|
|||||||
onDragOver: (e: React.DragEvent) => void;
|
onDragOver: (e: React.DragEvent) => void;
|
||||||
onDragLeave: (e: React.DragEvent) => void;
|
onDragLeave: (e: React.DragEvent) => void;
|
||||||
onDrop: (e: React.DragEvent) => void;
|
onDrop: (e: React.DragEvent) => void;
|
||||||
|
slashCommands?: SlashCommand[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChatInput = memo(function ChatInput({
|
export const ChatInput = memo(function ChatInput({
|
||||||
@@ -52,10 +60,15 @@ export const ChatInput = memo(function ChatInput({
|
|||||||
onDragOver,
|
onDragOver,
|
||||||
onDragLeave,
|
onDragLeave,
|
||||||
onDrop,
|
onDrop,
|
||||||
|
slashCommands = [],
|
||||||
}: ChatInputProps) {
|
}: ChatInputProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [input, setInput] = useState('');
|
const [input, setInput] = useState('');
|
||||||
const [attachedFiles, setAttachedFiles] = useState<File[]>([]);
|
const [attachedFiles, setAttachedFiles] = useState<File[]>([]);
|
||||||
|
const [showSlashCommands, setShowSlashCommands] = useState(false);
|
||||||
|
const [filteredCommands, setFilteredCommands] = useState<SlashCommand[]>([]);
|
||||||
|
const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);
|
||||||
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
const handleFileSelect = useCallback((file: File) => {
|
const handleFileSelect = useCallback((file: File) => {
|
||||||
setAttachedFiles(prev => [...prev, file]);
|
setAttachedFiles(prev => [...prev, file]);
|
||||||
@@ -78,16 +91,110 @@ export const ChatInput = memo(function ChatInput({
|
|||||||
onSend(currentInput, currentFiles);
|
onSend(currentInput, currentFiles);
|
||||||
}, [input, attachedFiles, isLoading, isConfigured, providerModel, onSend]);
|
}, [input, attachedFiles, isLoading, isConfigured, providerModel, onSend]);
|
||||||
|
|
||||||
|
const executeSlashCommand = useCallback((command: SlashCommand) => {
|
||||||
|
setInput('');
|
||||||
|
setShowSlashCommands(false);
|
||||||
|
setSelectedCommandIndex(0);
|
||||||
|
command.action();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
||||||
|
// Handle arrow key navigation when slash commands are showing
|
||||||
|
if (showSlashCommands && filteredCommands.length > 0) {
|
||||||
|
if (e.key === 'ArrowDown') {
|
||||||
|
e.preventDefault();
|
||||||
|
setSelectedCommandIndex(prev =>
|
||||||
|
prev < filteredCommands.length - 1 ? prev + 1 : 0
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.key === 'ArrowUp') {
|
||||||
|
e.preventDefault();
|
||||||
|
setSelectedCommandIndex(prev =>
|
||||||
|
prev > 0 ? prev - 1 : filteredCommands.length - 1
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If slash commands are showing and user presses Enter or Tab, select the highlighted command
|
||||||
|
if ((e.key === 'Enter' && !e.shiftKey) || e.key === 'Tab') {
|
||||||
|
e.preventDefault();
|
||||||
|
executeSlashCommand(filteredCommands[selectedCommandIndex]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If slash commands are showing and user presses Escape, close the popover
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
e.preventDefault();
|
||||||
|
setShowSlashCommands(false);
|
||||||
|
setSelectedCommandIndex(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (e.key === 'Enter' && !e.shiftKey) {
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleSend();
|
handleSend();
|
||||||
}
|
}
|
||||||
}, [handleSend]);
|
}, [handleSend, showSlashCommands, filteredCommands, selectedCommandIndex, executeSlashCommand]);
|
||||||
|
|
||||||
const handleInputChange = useCallback((e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
const handleInputChange = useCallback((e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
setInput(e.target.value);
|
const value = e.target.value;
|
||||||
}, []);
|
setInput(value);
|
||||||
|
|
||||||
|
// Check if slash command autocomplete should be shown
|
||||||
|
if (value.startsWith('/') && !value.includes(' ') && slashCommands.length > 0) {
|
||||||
|
const query = value.slice(1).toLowerCase();
|
||||||
|
const filtered = slashCommands.filter(cmd =>
|
||||||
|
cmd.name.toLowerCase().includes(query)
|
||||||
|
);
|
||||||
|
setFilteredCommands(filtered);
|
||||||
|
setShowSlashCommands(filtered.length > 0);
|
||||||
|
setSelectedCommandIndex(0); // Reset selection when filtering
|
||||||
|
} else {
|
||||||
|
setShowSlashCommands(false);
|
||||||
|
setSelectedCommandIndex(0);
|
||||||
|
}
|
||||||
|
}, [slashCommands]);
|
||||||
|
|
||||||
|
const handleDrop = useCallback((e: React.DragEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// Call parent's drop handler for visual state management
|
||||||
|
onDrop(e);
|
||||||
|
|
||||||
|
// Extract files from the drop event
|
||||||
|
const files = Array.from(e.dataTransfer.files);
|
||||||
|
if (files.length === 0) return;
|
||||||
|
|
||||||
|
// Add all files without validation
|
||||||
|
setAttachedFiles(prev => [...prev, ...files]);
|
||||||
|
}, [onDrop]);
|
||||||
|
|
||||||
|
// Close popover when clicking outside
|
||||||
|
useEffect(() => {
|
||||||
|
if (!showSlashCommands) return;
|
||||||
|
|
||||||
|
const handleClickOutside = (e: MouseEvent) => {
|
||||||
|
// Check if click is outside the popover and textarea
|
||||||
|
const target = e.target as Node;
|
||||||
|
if (textareaRef.current && !textareaRef.current.contains(target)) {
|
||||||
|
setShowSlashCommands(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Use a slight delay to avoid closing immediately on focus
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
document.addEventListener('click', handleClickOutside);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
document.removeEventListener('click', handleClickOutside);
|
||||||
|
};
|
||||||
|
}, [showSlashCommands]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="border-t p-4">
|
<div className="border-t p-4">
|
||||||
@@ -99,9 +206,11 @@ export const ChatInput = memo(function ChatInput({
|
|||||||
onDragEnter={onDragEnter}
|
onDragEnter={onDragEnter}
|
||||||
onDragOver={onDragOver}
|
onDragOver={onDragOver}
|
||||||
onDragLeave={onDragLeave}
|
onDragLeave={onDragLeave}
|
||||||
onDrop={onDrop}
|
onDrop={handleDrop}
|
||||||
>
|
>
|
||||||
|
<div className="relative">
|
||||||
<Textarea
|
<Textarea
|
||||||
|
ref={textareaRef}
|
||||||
value={input}
|
value={input}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
@@ -128,6 +237,30 @@ export const ChatInput = memo(function ChatInput({
|
|||||||
target.style.height = Math.min(target.scrollHeight, 128) + 'px';
|
target.style.height = Math.min(target.scrollHeight, 128) + 'px';
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{showSlashCommands && filteredCommands.length > 0 && (
|
||||||
|
<div className="absolute bottom-full left-0 mb-2 w-80 rounded-lg border bg-popover p-0 text-popover-foreground shadow-md z-50">
|
||||||
|
<Command value={filteredCommands[selectedCommandIndex]?.name}>
|
||||||
|
<CommandList>
|
||||||
|
<CommandGroup>
|
||||||
|
{filteredCommands.map((command) => (
|
||||||
|
<CommandItem
|
||||||
|
key={command.name}
|
||||||
|
value={command.name}
|
||||||
|
onSelect={() => executeSlashCommand(command)}
|
||||||
|
className="cursor-pointer"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<div className="font-medium">/{command.name}</div>
|
||||||
|
<div className="text-xs text-muted-foreground">{command.description}</div>
|
||||||
|
</div>
|
||||||
|
</CommandItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Bottom Controls Row */}
|
{/* Bottom Controls Row */}
|
||||||
<div className="flex items-center gap-4 px-2 py-2">
|
<div className="flex items-center gap-4 px-2 py-2">
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ import { useMCPTools } from '@/hooks/useMCPTools';
|
|||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { AIMessageItem } from '@/components/AIMessageItem';
|
import { AIMessageItem } from '@/components/AIMessageItem';
|
||||||
import { ToolCallDisplay } from '@/components/ToolCallDisplay';
|
import { ToolCallDisplay } from '@/components/ToolCallDisplay';
|
||||||
import { TextEditorViewTool } from '@/lib/tools/TextEditorViewTool';
|
import { ReadTool } from '@/lib/tools/ReadTool';
|
||||||
import { TextEditorWriteTool } from '@/lib/tools/TextEditorWriteTool';
|
import { WriteTool } from '@/lib/tools/WriteTool';
|
||||||
import { TextEditorStrReplaceTool } from '@/lib/tools/TextEditorStrReplaceTool';
|
import { EditTool } from '@/lib/tools/EditTool';
|
||||||
|
import { GlobTool } from '@/lib/tools/GlobTool';
|
||||||
|
import { GrepTool } from '@/lib/tools/GrepTool';
|
||||||
import { NpmAddPackageTool } from '@/lib/tools/NpmAddPackageTool';
|
import { NpmAddPackageTool } from '@/lib/tools/NpmAddPackageTool';
|
||||||
import { NpmRemovePackageTool } from '@/lib/tools/NpmRemovePackageTool';
|
import { NpmRemovePackageTool } from '@/lib/tools/NpmRemovePackageTool';
|
||||||
import { GitCommitTool } from '@/lib/tools/GitCommitTool';
|
import { GitCommitTool } from '@/lib/tools/GitCommitTool';
|
||||||
@@ -33,13 +35,21 @@ import { NostrReadProtocolTool } from '@/lib/tools/NostrReadProtocolTool';
|
|||||||
import { NostrReadNipsIndexTool } from '@/lib/tools/NostrReadNipsIndexTool';
|
import { NostrReadNipsIndexTool } from '@/lib/tools/NostrReadNipsIndexTool';
|
||||||
import { NostrGenerateKindTool } from '@/lib/tools/NostrGenerateKindTool';
|
import { NostrGenerateKindTool } from '@/lib/tools/NostrGenerateKindTool';
|
||||||
import { NostrPublishEventsTool } from '@/lib/tools/NostrPublishEventsTool';
|
import { NostrPublishEventsTool } from '@/lib/tools/NostrPublishEventsTool';
|
||||||
|
import { NostrEncodeTool } from '@/lib/tools/NostrEncodeTool';
|
||||||
|
import { NostrDecodeTool } from '@/lib/tools/NostrDecodeTool';
|
||||||
|
import { BlossomUploadTool } from '@/lib/tools/BlossomUploadTool';
|
||||||
import { ShellTool } from '@/lib/tools/ShellTool';
|
import { ShellTool } from '@/lib/tools/ShellTool';
|
||||||
import { ReadConsoleMessagesTool } from '@/lib/tools/ReadConsoleMessagesTool';
|
import { ReadConsoleMessagesTool } from '@/lib/tools/ReadConsoleMessagesTool';
|
||||||
import { SkillTool } from '@/lib/tools/SkillTool';
|
import { SkillTool } from '@/lib/tools/SkillTool';
|
||||||
import { GenerateImageTool } from '@/lib/tools/GenerateImageTool';
|
import { GenerateImageTool } from '@/lib/tools/GenerateImageTool';
|
||||||
import { ViewAvailableModelsTool } from '@/lib/tools/ViewAvailableModelsTool';
|
import { ViewAvailableModelsTool } from '@/lib/tools/ViewAvailableModelsTool';
|
||||||
import { ConfigureImageGenerationTool } from '@/lib/tools/ConfigureImageGenerationTool';
|
import { ConfigureImageGenerationTool } from '@/lib/tools/ConfigureImageGenerationTool';
|
||||||
|
import { WebFetchTool } from '@/lib/tools/WebFetchTool';
|
||||||
|
import { WebSearchTool } from '@/lib/tools/WebSearchTool';
|
||||||
import { createMCPTools } from '@/lib/tools/MCPTool';
|
import { createMCPTools } from '@/lib/tools/MCPTool';
|
||||||
|
import { TodoWriteTool } from '@/lib/tools/TodoWriteTool';
|
||||||
|
import { TodoReadTool } from '@/lib/tools/TodoReadTool';
|
||||||
|
import { AppTool } from '@/lib/tools/AppTool';
|
||||||
import { ProjectPreviewConsoleError } from '@/lib/consoleMessages';
|
import { ProjectPreviewConsoleError } from '@/lib/consoleMessages';
|
||||||
import { toolToOpenAI } from '@/lib/tools/openai-adapter';
|
import { toolToOpenAI } from '@/lib/tools/openai-adapter';
|
||||||
import { Tool } from '@/lib/tools/Tool';
|
import { Tool } from '@/lib/tools/Tool';
|
||||||
@@ -47,11 +57,13 @@ import OpenAI from 'openai';
|
|||||||
import { useGit } from '@/hooks/useGit';
|
import { useGit } from '@/hooks/useGit';
|
||||||
import { Quilly } from '@/components/Quilly';
|
import { Quilly } from '@/components/Quilly';
|
||||||
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||||
import { ChatInput } from '@/components/Shakespeare/ChatInput';
|
import { ChatInput, SlashCommand } from '@/components/Shakespeare/ChatInput';
|
||||||
|
import { ToolsDialog } from '@/components/Shakespeare/ToolsDialog';
|
||||||
import { buildMessageContent } from '@/lib/buildMessageContent';
|
import { buildMessageContent } from '@/lib/buildMessageContent';
|
||||||
import { DotAI } from '@/lib/DotAI';
|
import { DotAI } from '@/lib/DotAI';
|
||||||
import { parseProviderModel } from '@/lib/parseProviderModel';
|
import { parseProviderModel } from '@/lib/parseProviderModel';
|
||||||
import { AIMessage } from '@/lib/SessionManager';
|
import { AIMessage } from '@/lib/SessionManager';
|
||||||
|
import { getAllSkills } from '@/lib/skills';
|
||||||
|
|
||||||
// Clean interfaces now handled by proper hooks
|
// Clean interfaces now handled by proper hooks
|
||||||
|
|
||||||
@@ -91,12 +103,15 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
|
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
|
||||||
const [isDragOver, setIsDragOver] = useState(false);
|
const [isDragOver, setIsDragOver] = useState(false);
|
||||||
const [scrolledProjects] = useState(() => new Set<string>());
|
const scrolledProjectsRef = useRef(new Set<string>());
|
||||||
|
const shouldScrollToBottomRef = useRef(false);
|
||||||
const [showOnboarding, setShowOnboarding] = useState(false);
|
const [showOnboarding, setShowOnboarding] = useState(false);
|
||||||
const [isStuck, setIsStuck] = useState(false);
|
const [isStuck, setIsStuck] = useState(false);
|
||||||
const [aiError, setAIError] = useState<Error | null>(null);
|
const [aiError, setAIError] = useState<Error | null>(null);
|
||||||
const [templateInfo, setTemplateInfo] = useState<{ name: string; description: string; url: string } | null>(null);
|
const [templateInfo, setTemplateInfo] = useState<{ name: string; description: string; url: string } | null>(null);
|
||||||
const [showTemplateInfo, setShowTemplateInfo] = useState(false);
|
const [showTemplateInfo, setShowTemplateInfo] = useState(false);
|
||||||
|
const [showToolsDialog, setShowToolsDialog] = useState(false);
|
||||||
|
const [availableSkills, setAvailableSkills] = useState<Array<{ name: string; description: string; path: string; plugin: string }>>([]);
|
||||||
|
|
||||||
// Determine which error to show - AI errors take priority over console errors
|
// Determine which error to show - AI errors take priority over console errors
|
||||||
// since they are more immediately relevant to the user's current action
|
// since they are more immediately relevant to the user's current action
|
||||||
@@ -167,16 +182,34 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
queryClient.invalidateQueries({ queryKey: ['git-sync', cwd] });
|
queryClient.invalidateQueries({ queryKey: ['git-sync', cwd] });
|
||||||
}, [queryClient, cwd]);
|
}, [queryClient, cwd]);
|
||||||
|
|
||||||
|
// Load available skills
|
||||||
|
useEffect(() => {
|
||||||
|
const loadSkills = async () => {
|
||||||
|
const skills = await getAllSkills(fs, pluginsPath, cwd);
|
||||||
|
setAvailableSkills(skills);
|
||||||
|
};
|
||||||
|
|
||||||
|
loadSkills().catch(err => {
|
||||||
|
console.error('Failed to load skills:', err);
|
||||||
|
setAvailableSkills([]);
|
||||||
|
});
|
||||||
|
}, [fs, pluginsPath, cwd]);
|
||||||
|
|
||||||
// Fetch MCP tools
|
// Fetch MCP tools
|
||||||
const { tools: mcpOpenAITools, clients: mcpClients } = useMCPTools();
|
const { tools: mcpOpenAITools, clients: mcpClients } = useMCPTools();
|
||||||
|
|
||||||
// Separate built-in tools from MCP tools for clarity
|
// Separate built-in tools from MCP tools for clarity
|
||||||
const builtInTools = useMemo(() => {
|
const builtInTools = useMemo(() => {
|
||||||
const tools: Record<string, Tool<unknown>> = {
|
const tools: Record<string, Tool<unknown>> = {
|
||||||
|
// File operation tools (OpenCode-compatible API)
|
||||||
|
read: new ReadTool(fs, cwd, { projectsPath }),
|
||||||
|
write: new WriteTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }),
|
||||||
|
edit: new EditTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }),
|
||||||
|
glob: new GlobTool(fs, cwd),
|
||||||
|
grep: new GrepTool(fs, cwd),
|
||||||
|
|
||||||
|
// Other tools
|
||||||
git_commit: new GitCommitTool(fs, cwd, git, { onCommit: handleCommit }),
|
git_commit: new GitCommitTool(fs, cwd, git, { onCommit: handleCommit }),
|
||||||
text_editor_view: new TextEditorViewTool(fs, cwd, { projectsPath }),
|
|
||||||
text_editor_write: new TextEditorWriteTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }),
|
|
||||||
text_editor_str_replace: new TextEditorStrReplaceTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }),
|
|
||||||
npm_add_package: new NpmAddPackageTool(fs, cwd),
|
npm_add_package: new NpmAddPackageTool(fs, cwd),
|
||||||
npm_remove_package: new NpmRemovePackageTool(fs, cwd),
|
npm_remove_package: new NpmRemovePackageTool(fs, cwd),
|
||||||
build_project: new BuildProjectTool(fs, cwd, esmUrlRef.current),
|
build_project: new BuildProjectTool(fs, cwd, esmUrlRef.current),
|
||||||
@@ -188,9 +221,23 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
nostr_read_nips_index: new NostrReadNipsIndexTool(),
|
nostr_read_nips_index: new NostrReadNipsIndexTool(),
|
||||||
nostr_generate_kind: new NostrGenerateKindTool(),
|
nostr_generate_kind: new NostrGenerateKindTool(),
|
||||||
nostr_publish_events: new NostrPublishEventsTool(),
|
nostr_publish_events: new NostrPublishEventsTool(),
|
||||||
|
nostr_encode: new NostrEncodeTool(),
|
||||||
|
nostr_decode: new NostrDecodeTool(),
|
||||||
|
blossom_upload: new BlossomUploadTool(fs, cwd, user?.signer),
|
||||||
shell: new ShellTool(fs, cwd, git, config.corsProxy, user?.signer),
|
shell: new ShellTool(fs, cwd, git, config.corsProxy, user?.signer),
|
||||||
read_console_messages: new ReadConsoleMessagesTool(),
|
read_console_messages: new ReadConsoleMessagesTool(),
|
||||||
skill: new SkillTool(fs, pluginsPath, cwd),
|
skill: new SkillTool(fs, availableSkills),
|
||||||
|
webfetch: new WebFetchTool({ corsProxy: config.corsProxy }),
|
||||||
|
websearch: new WebSearchTool(),
|
||||||
|
todowrite: new TodoWriteTool(fs, projectId, { projectsPath }),
|
||||||
|
todoread: new TodoReadTool(fs, projectId, { projectsPath }),
|
||||||
|
app: new AppTool(
|
||||||
|
fs,
|
||||||
|
cwd,
|
||||||
|
user?.signer,
|
||||||
|
user?.pubkey,
|
||||||
|
config.relayMetadata.relays.filter(r => r.write).map(r => r.url),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add generate_image tool if imageModel is configured
|
// Add generate_image tool if imageModel is configured
|
||||||
@@ -242,7 +289,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return tools;
|
return tools;
|
||||||
}, [fs, git, cwd, user, projectsPath, tmpPath, pluginsPath, config.corsProxy, settings, aiSettings, models, handleFileChanged, handleCommit]);
|
}, [fs, git, cwd, user, projectsPath, tmpPath, config.corsProxy, config.relayMetadata, settings, aiSettings, models, handleFileChanged, handleCommit, projectId, availableSkills]);
|
||||||
|
|
||||||
// MCP tools wrapped for execution
|
// MCP tools wrapped for execution
|
||||||
const mcpToolWrappers = useMemo(() => createMCPTools(mcpClients), [mcpClients]);
|
const mcpToolWrappers = useMemo(() => createMCPTools(mcpClients), [mcpClients]);
|
||||||
@@ -489,30 +536,46 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (scrollAreaRef.current && (messages || streamingMessage)) {
|
if (scrollAreaRef.current && (messages || streamingMessage)) {
|
||||||
// Check if user was already at or near the bottom (within 100px threshold)
|
|
||||||
const threshold = 100;
|
const threshold = 100;
|
||||||
const container = scrollAreaRef.current;
|
const container = scrollAreaRef.current;
|
||||||
const isNearBottom = container.scrollTop + container.clientHeight >= container.scrollHeight - threshold;
|
const isNearBottom = container.scrollTop + container.clientHeight >= container.scrollHeight - threshold;
|
||||||
|
|
||||||
// Only auto-scroll if user was already near the bottom
|
// Auto-scroll if:
|
||||||
if (isNearBottom) {
|
// 1. User just sent a message (shouldScrollToBottomRef is true), OR
|
||||||
container.scrollTop = container.scrollHeight;
|
// 2. User was already near the bottom
|
||||||
|
if (shouldScrollToBottomRef.current || isNearBottom) {
|
||||||
|
// Double requestAnimationFrame ensures scroll happens after layout and paint
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (scrollAreaRef.current) {
|
||||||
|
scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
shouldScrollToBottomRef.current = false; // Reset the flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [messages, streamingMessage, isLoading]);
|
}, [messages, streamingMessage, isLoading]);
|
||||||
|
|
||||||
|
// Remove project from scrolled set when loading starts (so it can scroll again after loading)
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoadingHistory) {
|
||||||
|
scrolledProjectsRef.current.delete(projectId);
|
||||||
|
}
|
||||||
|
}, [projectId, isLoadingHistory]);
|
||||||
|
|
||||||
// Scroll to bottom when first visiting a project (including page refresh)
|
// Scroll to bottom when first visiting a project (including page refresh)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (projectId && !scrolledProjects.has(projectId)) {
|
if (projectId && !scrolledProjectsRef.current.has(projectId) && !isLoadingHistory && messages.length > 0) {
|
||||||
// Small delay to ensure messages have loaded
|
// Use double RAF to ensure DOM is fully rendered after isLoadingHistory becomes false
|
||||||
const timer = setTimeout(() => {
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
scrolledProjects.add(projectId);
|
scrolledProjectsRef.current.add(projectId);
|
||||||
}, 100);
|
});
|
||||||
|
});
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}
|
}
|
||||||
}, [projectId, scrolledProjects, scrollToBottom]);
|
}, [projectId, isLoadingHistory, messages.length, scrollToBottom]);
|
||||||
|
|
||||||
// Drag and drop handlers
|
// Drag and drop handlers
|
||||||
const handleDragEnter = useCallback((e: React.DragEvent) => {
|
const handleDragEnter = useCallback((e: React.DragEvent) => {
|
||||||
@@ -577,6 +640,9 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
// Add model to recently used when sending a message
|
// Add model to recently used when sending a message
|
||||||
addRecentlyUsedModel(modelToUse);
|
addRecentlyUsedModel(modelToUse);
|
||||||
|
|
||||||
|
// Mark that we should scroll to bottom when the message is added
|
||||||
|
shouldScrollToBottomRef.current = true;
|
||||||
|
|
||||||
await sendMessage(messageContent, modelToUse);
|
await sendMessage(messageContent, modelToUse);
|
||||||
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath]);
|
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath]);
|
||||||
|
|
||||||
@@ -599,6 +665,23 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
}
|
}
|
||||||
}, [onFirstInteraction]);
|
}, [onFirstInteraction]);
|
||||||
|
|
||||||
|
// Slash commands
|
||||||
|
const slashCommands: SlashCommand[] = [
|
||||||
|
{
|
||||||
|
name: 'new',
|
||||||
|
description: 'Start a new chat session',
|
||||||
|
action: () => {
|
||||||
|
internalStartNewSession();
|
||||||
|
onNewChat();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'tools',
|
||||||
|
description: "View the current session's available tools",
|
||||||
|
action: () => setShowToolsDialog(true),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// Expose startNewSession function via ref
|
// Expose startNewSession function via ref
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
startNewSession: () => {
|
startNewSession: () => {
|
||||||
@@ -618,6 +701,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
key="streaming-message"
|
key="streaming-message"
|
||||||
message={streamingMessage}
|
message={streamingMessage}
|
||||||
isCurrentlyLoading={isLoading}
|
isCurrentlyLoading={isLoading}
|
||||||
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* Show tool call in "calling" state if streaming tool call is in progress */}
|
{/* Show tool call in "calling" state if streaming tool call is in progress */}
|
||||||
@@ -633,6 +717,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
state="calling"
|
state="calling"
|
||||||
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -669,6 +754,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
state="waiting"
|
state="waiting"
|
||||||
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -800,6 +886,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
key={`${index}-${message.role}-${typeof message.content === 'string' ? message.content.slice(0, 50) : 'content'}`}
|
key={`${index}-${message.role}-${typeof message.content === 'string' ? message.content.slice(0, 50) : 'content'}`}
|
||||||
message={message}
|
message={message}
|
||||||
toolCall={toolCall}
|
toolCall={toolCall}
|
||||||
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -872,6 +959,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
onDragOver={handleDragOver}
|
onDragOver={handleDragOver}
|
||||||
onDragLeave={handleDragLeave}
|
onDragLeave={handleDragLeave}
|
||||||
onDrop={handleDrop}
|
onDrop={handleDrop}
|
||||||
|
slashCommands={slashCommands}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Onboarding Dialog */}
|
{/* Onboarding Dialog */}
|
||||||
@@ -879,6 +967,13 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
open={showOnboarding}
|
open={showOnboarding}
|
||||||
onOpenChange={setShowOnboarding}
|
onOpenChange={setShowOnboarding}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Tools Dialog */}
|
||||||
|
<ToolsDialog
|
||||||
|
open={showToolsDialog}
|
||||||
|
onOpenChange={setShowToolsDialog}
|
||||||
|
tools={tools}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -10,17 +10,14 @@ import { useBuildProject } from '@/hooks/useBuildProject';
|
|||||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
||||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { FolderOpen, ArrowLeft, Bug, Copy, Check, Loader2, Code, X, Terminal, Expand, Shrink, Hammer } from 'lucide-react';
|
import { FolderOpen, ArrowLeft, Bug, Copy, Check, Loader2, Code, X, Terminal, Expand, Shrink, Hammer, RefreshCw } from 'lucide-react';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
||||||
import { BranchSwitcher } from '@/components/BranchSwitcher';
|
import { BranchSwitcher } from '@/components/BranchSwitcher';
|
||||||
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
||||||
import { type DeviceMode } from '@/components/ui/device-toggle';
|
import { type DeviceMode } from '@/components/ui/device-toggle';
|
||||||
import {
|
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable';
|
||||||
Popover,
|
import type { ImperativePanelHandle } from 'react-resizable-panels';
|
||||||
PopoverContent,
|
|
||||||
PopoverTrigger,
|
|
||||||
} from '@/components/ui/popover';
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { FileTree } from './FileTree';
|
import { FileTree } from './FileTree';
|
||||||
import { FileEditor } from './FileEditor';
|
import { FileEditor } from './FileEditor';
|
||||||
@@ -77,14 +74,18 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
const [desktopCodeView, setDesktopCodeView] = useState<'files' | 'terminal'>('files');
|
const [desktopCodeView, setDesktopCodeView] = useState<'files' | 'terminal'>('files');
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
||||||
|
const [buildError, setBuildError] = useState<string | null>(null);
|
||||||
const [currentPath, setCurrentPath] = useState('/');
|
const [currentPath, setCurrentPath] = useState('/');
|
||||||
const [navigationHistory, setNavigationHistory] = useState<string[]>(['/']);
|
const [navigationHistory, setNavigationHistory] = useState<string[]>(['/']);
|
||||||
const [historyIndex, setHistoryIndex] = useState(0);
|
const [historyIndex, setHistoryIndex] = useState(0);
|
||||||
|
|
||||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||||
const [deviceMode, setDeviceMode] = useState<DeviceMode>('laptop');
|
const [deviceMode, setDeviceMode] = useState<DeviceMode>('laptop');
|
||||||
|
const [isLogsOpen, setIsLogsOpen] = useState(false);
|
||||||
const previewContainerRef = useRef<HTMLDivElement>(null);
|
const previewContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||||
|
const iframePanelRef = useRef<ImperativePanelHandle>(null);
|
||||||
|
const logsPanelRef = useRef<ImperativePanelHandle>(null);
|
||||||
const { fs } = useFS();
|
const { fs } = useFS();
|
||||||
const { projectsPath } = useFSPaths();
|
const { projectsPath } = useFSPaths();
|
||||||
const projectsManager = useProjectsManager();
|
const projectsManager = useProjectsManager();
|
||||||
@@ -177,19 +178,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
}
|
}
|
||||||
}, [projectId, projectsManager]);
|
}, [projectId, projectsManager]);
|
||||||
|
|
||||||
// Legacy refresh function for build completion events
|
|
||||||
const refreshIframeLegacy = useCallback(() => {
|
|
||||||
if (iframeRef.current) {
|
|
||||||
// Force reload the iframe by updating its src
|
|
||||||
iframeRef.current.src = '/';
|
|
||||||
// Use a small timeout to ensure the src is cleared before setting it back
|
|
||||||
setTimeout(() => {
|
|
||||||
if (iframeRef.current) {
|
|
||||||
iframeRef.current.src = `https://${projectId}.${previewDomain}/`;
|
|
||||||
}
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
}, [projectId, previewDomain]);
|
|
||||||
|
|
||||||
const sendResponse = useCallback((message: JSONRPCResponse) => {
|
const sendResponse = useCallback((message: JSONRPCResponse) => {
|
||||||
if (iframeRef.current?.contentWindow) {
|
if (iframeRef.current?.contentWindow) {
|
||||||
@@ -440,6 +429,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
setFileContent('');
|
setFileContent('');
|
||||||
setMobileCodeView('explorer');
|
setMobileCodeView('explorer');
|
||||||
setDesktopCodeView('files');
|
setDesktopCodeView('files');
|
||||||
|
setBuildError(null);
|
||||||
|
|
||||||
// Reset navigation history and state
|
// Reset navigation history and state
|
||||||
setCurrentPath('/');
|
setCurrentPath('/');
|
||||||
@@ -464,13 +454,13 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
console.log('Build completed for project, refreshing preview');
|
console.log('Build completed for project, refreshing preview');
|
||||||
// Check for built project and refresh iframe
|
// Check for built project and refresh iframe
|
||||||
checkForBuiltProject();
|
checkForBuiltProject();
|
||||||
refreshIframeLegacy();
|
refreshIframe();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('buildComplete', handleBuildComplete as EventListener);
|
window.addEventListener('buildComplete', handleBuildComplete as EventListener);
|
||||||
return () => window.removeEventListener('buildComplete', handleBuildComplete as EventListener);
|
return () => window.removeEventListener('buildComplete', handleBuildComplete as EventListener);
|
||||||
}, [projectId, checkForBuiltProject, refreshIframeLegacy]);
|
}, [projectId, checkForBuiltProject, refreshIframe]);
|
||||||
|
|
||||||
const handleFileSelect = (filePath: string) => {
|
const handleFileSelect = (filePath: string) => {
|
||||||
setSelectedFile(filePath);
|
setSelectedFile(filePath);
|
||||||
@@ -500,11 +490,11 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ConsoleDropdown = () => {
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
const [copiedMessageIndex, setCopiedMessageIndex] = useState<number | null>(null);
|
const [copiedMessageIndex, setCopiedMessageIndex] = useState<number | null>(null);
|
||||||
|
const [copiedAll, setCopiedAll] = useState(false);
|
||||||
|
const [copiedBuildError, setCopiedBuildError] = useState(false);
|
||||||
|
|
||||||
const messages = isOpen ? getConsoleMessages() : [];
|
const messages = isLogsOpen ? getConsoleMessages() : [];
|
||||||
|
|
||||||
const copyMessageToClipboard = async (msg: ConsoleMessage, index: number) => {
|
const copyMessageToClipboard = async (msg: ConsoleMessage, index: number) => {
|
||||||
try {
|
try {
|
||||||
@@ -516,89 +506,31 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const copyAllMessagesToClipboard = async () => {
|
||||||
|
try {
|
||||||
|
const allMessages = messages.map(msg => msg.message).join('\n');
|
||||||
|
await navigator.clipboard.writeText(allMessages);
|
||||||
|
setCopiedAll(true);
|
||||||
|
setTimeout(() => setCopiedAll(false), 2000);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to copy all messages to clipboard:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const messageCount = messages.length;
|
const messageCount = messages.length;
|
||||||
|
|
||||||
return (
|
// Programmatically resize panels when isLogsOpen changes
|
||||||
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
useEffect(() => {
|
||||||
<PopoverTrigger asChild>
|
if (isLogsOpen) {
|
||||||
<Button
|
// Open logs panel to 40% and resize iframe to 60%
|
||||||
variant="ghost"
|
logsPanelRef.current?.resize(40);
|
||||||
size="sm"
|
iframePanelRef.current?.resize(60);
|
||||||
className="h-8 gap-2 relative"
|
} else {
|
||||||
>
|
// Close logs panel and expand iframe to 100%
|
||||||
<Bug className="h-4 w-4" />
|
logsPanelRef.current?.resize(0);
|
||||||
<span className="hidden lg:inline">Logs</span>
|
iframePanelRef.current?.resize(100);
|
||||||
{hasConsoleErrors && (
|
}
|
||||||
<span className="absolute -top-1 -right-1 h-3 w-3 rounded-full border-2 border-background bg-red-500" />
|
}, [isLogsOpen]);
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent
|
|
||||||
align="end"
|
|
||||||
className="w-[calc(100vw-1rem)] max-w-[480px] max-h-[512px] overflow-hidden shadow-lg border rounded-lg bg-background p-0 z-[9999]"
|
|
||||||
sideOffset={4}
|
|
||||||
>
|
|
||||||
|
|
||||||
{/* Messages */}
|
|
||||||
<div className="h-[60vh] max-h-[512px] w-full bg-background text-foreground font-mono text-xs relative overflow-y-auto overflow-x-hidden [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]">
|
|
||||||
<div className="py-2 px-1 space-y-0">
|
|
||||||
{messageCount === 0 ? (
|
|
||||||
<div className="flex flex-col items-center justify-center py-12 text-center">
|
|
||||||
<p className="text-sm text-muted-foreground font-medium">No console messages</p>
|
|
||||||
<p className="text-xs text-muted-foreground mt-1">Messages from your project will appear here</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
messages.map((msg, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="group relative py-0.5 px-1 hover:bg-muted/50 transition-colors duration-150 rounded cursor-pointer"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
copyMessageToClipboard(msg, index);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className={cn(
|
|
||||||
"text-xs font-mono leading-tight whitespace-pre-wrap break-words",
|
|
||||||
msg.level === 'error' ? "text-destructive" :
|
|
||||||
msg.level === 'warn' ? "text-warning" :
|
|
||||||
msg.level === 'info' ? "text-primary" :
|
|
||||||
"text-muted-foreground"
|
|
||||||
)}>
|
|
||||||
{msg.message}
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
copyMessageToClipboard(msg, index);
|
|
||||||
}}
|
|
||||||
className="h-3 w-3 p-0 opacity-0 group-hover:opacity-100 transition-all duration-200 absolute right-1 top-1 hover:bg-muted/70 text-muted-foreground hover:text-foreground bg-background/80 rounded border"
|
|
||||||
>
|
|
||||||
{copiedMessageIndex === index ? (
|
|
||||||
<Check className="h-2 w-2 text-success" />
|
|
||||||
) : (
|
|
||||||
<Copy className="h-2 w-2" />
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Close button */}
|
|
||||||
<button
|
|
||||||
onClick={() => setIsOpen(false)}
|
|
||||||
className="absolute top-2 right-2 h-8 w-8 p-0 bg-muted/50 hover:bg-muted/70 rounded-md z-10 flex items-center justify-center border"
|
|
||||||
>
|
|
||||||
<X className="h-5 w-5 text-muted-foreground" />
|
|
||||||
</button>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full">
|
<div className="h-full">
|
||||||
@@ -656,7 +588,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
})}
|
})}
|
||||||
disabled={isBuildLoading}
|
disabled={isBuildLoading}
|
||||||
className="h-8 gap-2"
|
className="h-8 gap-2"
|
||||||
title="Build project"
|
title={t('buildButtonTooltip')}
|
||||||
>
|
>
|
||||||
{isBuildLoading ? (
|
{isBuildLoading ? (
|
||||||
<Loader2 className="h-4 w-4 animate-spin" />
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
@@ -671,17 +603,38 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={onToggleView}
|
onClick={onToggleView}
|
||||||
className="h-8 gap-2"
|
className="h-8 gap-2"
|
||||||
|
title={t('codeButtonTooltip')}
|
||||||
>
|
>
|
||||||
<Code className="h-4 w-4" />
|
<Code className="h-4 w-4" />
|
||||||
<span className="hidden lg:inline">Code</span>
|
<span className="hidden lg:inline">Code</span>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<ConsoleDropdown />
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setIsLogsOpen(!isLogsOpen)}
|
||||||
|
className={cn("h-8 gap-2 relative", isLogsOpen && "bg-muted")}
|
||||||
|
title={t('logsButtonTooltip')}
|
||||||
|
>
|
||||||
|
<Bug className="h-4 w-4" />
|
||||||
|
<span className="hidden lg:inline">Logs</span>
|
||||||
|
{hasConsoleErrors && (
|
||||||
|
<span className="absolute -top-1 -right-1 h-3 w-3 rounded-full border-2 border-background bg-red-500" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Content area */}
|
{/* Content area */}
|
||||||
<div className="flex-1 flex items-center justify-center bg-muted/30">
|
<div className="flex-1 bg-muted/30 min-h-0 overflow-hidden">
|
||||||
|
<ResizablePanelGroup direction="vertical" className="h-full">
|
||||||
|
<ResizablePanel
|
||||||
|
ref={iframePanelRef}
|
||||||
|
defaultSize={isLogsOpen ? 60 : 100}
|
||||||
|
minSize={30}
|
||||||
|
className="min-h-0"
|
||||||
|
>
|
||||||
|
<div className="h-full flex items-center justify-center min-h-0">
|
||||||
{hasBuiltProject ? (
|
{hasBuiltProject ? (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -701,15 +654,198 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="h-full w-full flex items-center justify-center bg-muted">
|
<div className="h-full w-full flex items-center justify-center bg-muted p-4">
|
||||||
<div className="text-center">
|
<div className="text-center space-y-4 max-w-2xl w-full">
|
||||||
|
<div>
|
||||||
<h3 className="text-lg font-semibold mb-2">{t('projectPreview')}</h3>
|
<h3 className="text-lg font-semibold mb-2">{t('projectPreview')}</h3>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
{t('buildProjectToSeePreview')}
|
{t('buildProjectToSeePreview')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
{buildError && (
|
||||||
|
<div className="bg-destructive/10 border border-destructive/20 rounded-lg overflow-hidden text-left">
|
||||||
|
<div className="px-4 py-2 bg-destructive/20 border-b border-destructive/20 flex items-center justify-between">
|
||||||
|
<p className="font-semibold text-destructive text-sm">Build Failed</p>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={async () => {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(buildError);
|
||||||
|
setCopiedBuildError(true);
|
||||||
|
setTimeout(() => setCopiedBuildError(false), 2000);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to copy error to clipboard:', error);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="h-7 px-2 text-xs hover:bg-destructive/10"
|
||||||
|
>
|
||||||
|
{copiedBuildError ? (
|
||||||
|
<>
|
||||||
|
<Check className="h-3 w-3 mr-1.5" />
|
||||||
|
Copied
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Copy className="h-3 w-3 mr-1.5" />
|
||||||
|
Copy
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<ScrollArea className="max-h-48">
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<pre className="p-4 text-xs font-mono text-destructive whitespace-pre leading-relaxed">{buildError}</pre>
|
||||||
|
</div>
|
||||||
|
<ScrollBar orientation="horizontal" />
|
||||||
|
</ScrollArea>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => {
|
||||||
|
setBuildError(null);
|
||||||
|
buildProject(undefined, {
|
||||||
|
onSuccess: () => {
|
||||||
|
setBuildError(null);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('Build failed:', error);
|
||||||
|
setBuildError(error instanceof Error ? error.message : String(error));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
disabled={isBuildLoading}
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
{isBuildLoading ? (
|
||||||
|
<>
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
|
Building...
|
||||||
|
</>
|
||||||
|
) : buildError ? (
|
||||||
|
<>
|
||||||
|
<RefreshCw className="h-4 w-4" />
|
||||||
|
Retry
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Hammer className="h-4 w-4" />
|
||||||
|
Build
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ResizablePanel>
|
||||||
|
<ResizableHandle withHandle className={cn(!isLogsOpen && "hidden")} />
|
||||||
|
<ResizablePanel
|
||||||
|
ref={logsPanelRef}
|
||||||
|
defaultSize={isLogsOpen ? 40 : 0}
|
||||||
|
minSize={0}
|
||||||
|
maxSize={isLogsOpen ? undefined : 0}
|
||||||
|
className="min-h-0 min-w-0"
|
||||||
|
collapsible
|
||||||
|
collapsedSize={0}
|
||||||
|
>
|
||||||
|
{/* Logs Panel */}
|
||||||
|
<div className="h-full flex flex-col bg-background border-t overflow-hidden min-h-0 w-full min-w-0">
|
||||||
|
{/* Logs Header */}
|
||||||
|
<div className="h-12 px-4 border-b flex items-center justify-between flex-shrink-0">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{hasConsoleErrors && (
|
||||||
|
<span className="h-2 w-2 rounded-full bg-red-500" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
{messageCount > 0 && (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={copyAllMessagesToClipboard}
|
||||||
|
className="h-7 px-2 text-xs"
|
||||||
|
>
|
||||||
|
{copiedAll ? (
|
||||||
|
<>
|
||||||
|
<Check className="h-3 w-3 mr-1.5 text-success" />
|
||||||
|
{t('copied')}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Copy className="h-3 w-3 mr-1.5" />
|
||||||
|
{t('copyAll')}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setIsLogsOpen(false)}
|
||||||
|
className="h-7 w-7 p-0"
|
||||||
|
>
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Logs Content */}
|
||||||
|
<div className="flex-1 min-h-0 overflow-hidden w-full">
|
||||||
|
<ScrollArea className="h-full w-full">
|
||||||
|
<div className="p-2 space-y-0 w-full min-w-0 max-w-full">
|
||||||
|
{messageCount === 0 ? (
|
||||||
|
<div className="flex flex-col items-center justify-center py-12 text-center">
|
||||||
|
<p className="text-sm text-muted-foreground font-medium">No console messages</p>
|
||||||
|
<p className="text-xs text-muted-foreground mt-1">Messages from your project will appear here</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
messages.map((msg, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="group relative py-0.5 px-1 hover:bg-muted/50 transition-colors duration-150 rounded cursor-pointer w-full max-w-full"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
copyMessageToClipboard(msg, index);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"text-xs font-mono leading-tight whitespace-pre-wrap break-words w-full min-w-0 max-w-full",
|
||||||
|
msg.level === 'error' ? "text-destructive" :
|
||||||
|
msg.level === 'warn' ? "text-warning" :
|
||||||
|
msg.level === 'info' ? "text-primary" :
|
||||||
|
"text-muted-foreground"
|
||||||
|
)}
|
||||||
|
style={{ wordBreak: 'break-word', overflowWrap: 'break-word' }}
|
||||||
|
>
|
||||||
|
{msg.message}
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
copyMessageToClipboard(msg, index);
|
||||||
|
}}
|
||||||
|
className="h-3 w-3 p-0 opacity-0 group-hover:opacity-100 transition-all duration-200 absolute right-1 top-1 hover:bg-muted/70 text-muted-foreground hover:text-foreground bg-background/80 rounded border"
|
||||||
|
>
|
||||||
|
{copiedMessageIndex === index ? (
|
||||||
|
<Check className="h-2 w-2 text-success" />
|
||||||
|
) : (
|
||||||
|
<Copy className="h-2 w-2" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ResizablePanel>
|
||||||
|
</ResizablePanelGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Build loading overlay */}
|
{/* Build loading overlay */}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog';
|
||||||
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||||
|
import OpenAI from 'openai';
|
||||||
|
|
||||||
|
interface ToolsDialogProps {
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
tools: Record<string, OpenAI.Chat.Completions.ChatCompletionTool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ToolsDialog({ open, onOpenChange, tools }: ToolsDialogProps) {
|
||||||
|
const toolEntries = Object.entries(tools);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<DialogContent className="max-w-4xl max-h-[80vh]">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Available Tools</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
The current session's full list of available tools ({toolEntries.length} tools)
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<ScrollArea className="h-[60vh] w-full pr-4">
|
||||||
|
<Accordion type="single" collapsible className="w-full space-y-2">
|
||||||
|
{toolEntries.map(([name, tool]) => {
|
||||||
|
const func = 'function' in tool ? tool.function : undefined;
|
||||||
|
return (
|
||||||
|
<AccordionItem key={name} value={name} className="border rounded-lg px-4">
|
||||||
|
<AccordionTrigger className="text-sm font-mono hover:no-underline py-3 outline-none focus:outline-none focus-visible:outline-none">
|
||||||
|
{name}
|
||||||
|
</AccordionTrigger>
|
||||||
|
<AccordionContent className="pt-2 pb-4">
|
||||||
|
<div className="space-y-3 text-sm">
|
||||||
|
<div>
|
||||||
|
<div className="font-semibold mb-1">Description:</div>
|
||||||
|
<div className="text-muted-foreground whitespace-pre-wrap">
|
||||||
|
{func?.description || 'No description available'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{func?.parameters && (
|
||||||
|
<div>
|
||||||
|
<div className="font-semibold mb-1">Parameters:</div>
|
||||||
|
<pre className="text-xs bg-muted p-3 rounded-md overflow-x-auto">
|
||||||
|
{JSON.stringify(func.parameters, null, 2)}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</AccordionContent>
|
||||||
|
</AccordionItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Accordion>
|
||||||
|
</ScrollArea>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { TestApp } from '@/test/TestApp';
|
||||||
|
import { ToolCallDisplay } from './ToolCallDisplay';
|
||||||
|
|
||||||
|
describe('ToolCallDisplay', () => {
|
||||||
|
describe('path stripping', () => {
|
||||||
|
it('should strip project prefix from absolute paths for read tool', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="read"
|
||||||
|
toolArgs={{ filePath: '/projects/mysite/src/index.ts' }}
|
||||||
|
state="completed"
|
||||||
|
result="File content"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Viewed src/index.ts')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should strip project prefix from absolute paths for write tool', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="write"
|
||||||
|
toolArgs={{ filePath: '/projects/mysite/src/App.tsx', content: 'code' }}
|
||||||
|
state="completed"
|
||||||
|
result="File written"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Wrote src/App.tsx')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should strip project prefix from absolute paths for edit tool', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="edit"
|
||||||
|
toolArgs={{
|
||||||
|
filePath: '/projects/mysite/src/components/Header.tsx',
|
||||||
|
oldString: 'old',
|
||||||
|
newString: 'new'
|
||||||
|
}}
|
||||||
|
state="completed"
|
||||||
|
result="File edited"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Edited src/components/Header.tsx')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle paths without project prefix', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="read"
|
||||||
|
toolArgs={{ filePath: 'src/index.ts' }}
|
||||||
|
state="completed"
|
||||||
|
result="File content"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Viewed src/index.ts')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle legacy text_editor_view tool', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="text_editor_view"
|
||||||
|
toolArgs={{ path: '/projects/mysite/README.md' }}
|
||||||
|
state="completed"
|
||||||
|
result="File content"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Viewed README.md')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle legacy text_editor_write tool', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="text_editor_write"
|
||||||
|
toolArgs={{ path: '/projects/mysite/package.json', file_text: '{}' }}
|
||||||
|
state="completed"
|
||||||
|
result="File written"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Wrote package.json')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle legacy text_editor_str_replace tool', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="text_editor_str_replace"
|
||||||
|
toolArgs={{
|
||||||
|
path: '/projects/mysite/src/utils.ts',
|
||||||
|
old_str: 'old',
|
||||||
|
new_str: 'new'
|
||||||
|
}}
|
||||||
|
state="completed"
|
||||||
|
result="File edited"
|
||||||
|
projectId="mysite"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Edited src/utils.ts')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle different projects with same relative path', () => {
|
||||||
|
render(
|
||||||
|
<TestApp>
|
||||||
|
<ToolCallDisplay
|
||||||
|
toolName="read"
|
||||||
|
toolArgs={{ filePath: '/projects/another-project/src/index.ts' }}
|
||||||
|
state="completed"
|
||||||
|
result="File content"
|
||||||
|
projectId="another-project"
|
||||||
|
/>
|
||||||
|
</TestApp>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText('Viewed src/index.ts')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -26,12 +26,16 @@ import {
|
|||||||
Settings,
|
Settings,
|
||||||
TriangleAlert,
|
TriangleAlert,
|
||||||
X,
|
X,
|
||||||
|
Search,
|
||||||
|
Clipboard,
|
||||||
|
AppWindow,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { VFSImage } from '@/components/VFSImage';
|
import { VFSImage } from '@/components/VFSImage';
|
||||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||||
import { ImageModelDialog } from '@/components/ImageModelDialog';
|
import { ImageModelDialog } from '@/components/ImageModelDialog';
|
||||||
import { ImageLightbox } from '@/components/ImageLightbox';
|
import { ImageLightbox } from '@/components/ImageLightbox';
|
||||||
|
import { useFSPaths } from '@/hooks/useFSPaths';
|
||||||
|
|
||||||
interface ToolInfo {
|
interface ToolInfo {
|
||||||
icon: LucideIcon;
|
icon: LucideIcon;
|
||||||
@@ -45,6 +49,7 @@ interface ToolCallDisplayProps {
|
|||||||
toolArgs: Record<string, unknown>;
|
toolArgs: Record<string, unknown>;
|
||||||
state: 'calling' | 'waiting' | 'completed';
|
state: 'calling' | 'waiting' | 'completed';
|
||||||
result?: string; // The tool result content (only for completed state)
|
result?: string; // The tool result content (only for completed state)
|
||||||
|
projectId: string; // Current project ID for path display
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component to show image generation errors inline
|
// Component to show image generation errors inline
|
||||||
@@ -77,21 +82,95 @@ function ImageGenerationError() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip project path prefix from absolute paths
|
||||||
|
* e.g., /projects/mysite/src/index.ts -> src/index.ts
|
||||||
|
*/
|
||||||
|
function stripProjectPrefix(path: string, projectId?: string, projectsPath = '/projects'): string {
|
||||||
|
if (!projectId) return path;
|
||||||
|
|
||||||
|
const projectPrefix = `${projectsPath}/${projectId}/`;
|
||||||
|
if (path === `${projectsPath}/${projectId}`) {
|
||||||
|
return '.';
|
||||||
|
} else if (path.startsWith(projectPrefix)) {
|
||||||
|
return path.slice(projectPrefix.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tool information including icon, title, and calling title
|
* Get tool information including icon, title, and calling title
|
||||||
*/
|
*/
|
||||||
function getToolInfo(toolName: string, args: Record<string, unknown>): ToolInfo {
|
function getToolInfo(toolName: string, args: Record<string, unknown>, projectId?: string, projectsPath?: string, result?: string): ToolInfo {
|
||||||
switch (toolName) {
|
switch (toolName) {
|
||||||
case 'shell':
|
case 'shell':
|
||||||
return {
|
return {
|
||||||
icon: Terminal,
|
icon: Terminal,
|
||||||
title: args.command ? String(args.command) : 'Shell Command',
|
title: args.command ? String(args.command) : 'Shell command',
|
||||||
callingTitle: args.command ? String(args.command) : 'Running Shell Command',
|
callingTitle: args.command ? String(args.command) : 'Running shell command',
|
||||||
errorTitle: args.command ? `Failed: ${String(args.command)}` : 'Shell Command Failed',
|
errorTitle: args.command ? `Failed: ${String(args.command)}` : 'Shell command failed',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// New tools (OpenCode-compatible names)
|
||||||
|
case 'read': {
|
||||||
|
const rawPath = args.filePath ? String(args.filePath) : 'File';
|
||||||
|
const path = stripProjectPrefix(rawPath, projectId, projectsPath);
|
||||||
|
const offset = typeof args.offset === 'number' ? args.offset : 0;
|
||||||
|
const limit = typeof args.limit === 'number' ? args.limit : undefined;
|
||||||
|
const lineInfo = (typeof offset === 'number' && typeof limit === 'number')
|
||||||
|
? ` (lines ${(offset || 0) + 1}-${limit ? offset + limit : ''})`
|
||||||
|
: '';
|
||||||
|
return {
|
||||||
|
icon: Eye,
|
||||||
|
title: `Viewed ${path}${lineInfo}`,
|
||||||
|
callingTitle: `Viewing ${path}${lineInfo}`,
|
||||||
|
errorTitle: `Failed to view ${path}${lineInfo}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'write': {
|
||||||
|
const rawPath = args.filePath ? String(args.filePath) : '';
|
||||||
|
const path = rawPath ? stripProjectPrefix(rawPath, projectId, projectsPath) : '';
|
||||||
|
return {
|
||||||
|
icon: FileText,
|
||||||
|
title: path ? `Wrote ${path}` : 'Wrote file',
|
||||||
|
callingTitle: path ? `Writing ${path}` : 'Writing file',
|
||||||
|
errorTitle: path ? `Failed to write ${path}` : 'Failed to write file',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'edit': {
|
||||||
|
const rawPath = args.filePath ? String(args.filePath) : '';
|
||||||
|
const path = rawPath ? stripProjectPrefix(rawPath, projectId, projectsPath) : '';
|
||||||
|
return {
|
||||||
|
icon: Edit,
|
||||||
|
title: path ? `Edited ${path}` : 'Edited file',
|
||||||
|
callingTitle: path ? `Editing ${path}` : 'Editing file',
|
||||||
|
errorTitle: path ? `Failed to edit ${path}` : 'Failed to edit file',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'glob':
|
||||||
|
return {
|
||||||
|
icon: Search,
|
||||||
|
title: args.pattern ? `Searched "${args.pattern}"` : 'File pattern search',
|
||||||
|
callingTitle: args.pattern ? `Searching "${args.pattern}"` : 'Searching files',
|
||||||
|
errorTitle: args.pattern ? `Failed to search ${args.pattern}` : 'Search failed',
|
||||||
|
};
|
||||||
|
|
||||||
|
case 'grep':
|
||||||
|
return {
|
||||||
|
icon: Search,
|
||||||
|
title: args.pattern ? `Searched "${args.pattern}"` : 'Content search',
|
||||||
|
callingTitle: args.pattern ? `Searching "${args.pattern}"` : 'Searching content',
|
||||||
|
errorTitle: args.pattern ? `Failed to search ${args.pattern}` : 'Search failed',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Legacy tools (kept for old chat history)
|
||||||
case 'text_editor_view': {
|
case 'text_editor_view': {
|
||||||
const path = args.path ? String(args.path) : 'File';
|
const rawPath = args.path ? String(args.path) : 'File';
|
||||||
|
const path = stripProjectPrefix(rawPath, projectId, projectsPath);
|
||||||
const hasLineRange = args.start_line || args.end_line;
|
const hasLineRange = args.start_line || args.end_line;
|
||||||
const lineInfo = hasLineRange
|
const lineInfo = hasLineRange
|
||||||
? ` (lines ${args.start_line || 1}-${args.end_line || 'end'})`
|
? ` (lines ${args.start_line || 1}-${args.end_line || 'end'})`
|
||||||
@@ -104,21 +183,27 @@ function getToolInfo(toolName: string, args: Record<string, unknown>): ToolInfo
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'text_editor_write':
|
case 'text_editor_write': {
|
||||||
|
const rawPath = args.path ? String(args.path) : '';
|
||||||
|
const path = rawPath ? stripProjectPrefix(rawPath, projectId, projectsPath) : '';
|
||||||
return {
|
return {
|
||||||
icon: FileText,
|
icon: FileText,
|
||||||
title: args.path ? `Wrote ${args.path}` : 'Wrote File',
|
title: path ? `Wrote ${path}` : 'Wrote file',
|
||||||
callingTitle: args.path ? `Writing ${args.path}` : 'Writing File',
|
callingTitle: path ? `Writing ${path}` : 'Writing file',
|
||||||
errorTitle: args.path ? `Failed to write ${args.path}` : 'Failed to Write File',
|
errorTitle: path ? `Failed to write ${path}` : 'Failed to write file',
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
case 'text_editor_str_replace':
|
case 'text_editor_str_replace': {
|
||||||
|
const rawPath = args.path ? String(args.path) : '';
|
||||||
|
const path = rawPath ? stripProjectPrefix(rawPath, projectId, projectsPath) : '';
|
||||||
return {
|
return {
|
||||||
icon: Edit,
|
icon: Edit,
|
||||||
title: args.path ? `Edited ${args.path}` : 'Edited File',
|
title: path ? `Edited ${path}` : 'Edited file',
|
||||||
callingTitle: args.path ? `Editing ${args.path}` : 'Editing File',
|
callingTitle: path ? `Editing ${path}` : 'Editing file',
|
||||||
errorTitle: args.path ? `Failed to edit ${args.path}` : 'Failed to Edit File',
|
errorTitle: path ? `Failed to edit ${path}` : 'Failed to edit file',
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
case 'npm_add_package': {
|
case 'npm_add_package': {
|
||||||
const name = args.name ? String(args.name) : 'Package';
|
const name = args.name ? String(args.name) : 'Package';
|
||||||
@@ -134,25 +219,25 @@ function getToolInfo(toolName: string, args: Record<string, unknown>): ToolInfo
|
|||||||
case 'npm_remove_package':
|
case 'npm_remove_package':
|
||||||
return {
|
return {
|
||||||
icon: PackageMinus,
|
icon: PackageMinus,
|
||||||
title: args.name ? `Removed ${args.name}` : 'Removed Package',
|
title: args.name ? `Removed ${args.name}` : 'Removed package',
|
||||||
callingTitle: args.name ? `Removing ${args.name}` : 'Removing Package',
|
callingTitle: args.name ? `Removing ${args.name}` : 'Removing package',
|
||||||
errorTitle: args.name ? `Failed to remove ${args.name}` : 'Failed to Remove Package',
|
errorTitle: args.name ? `Failed to remove ${args.name}` : 'Failed to remove package',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'git_commit':
|
case 'git_commit':
|
||||||
return {
|
return {
|
||||||
icon: GitCommit,
|
icon: GitCommit,
|
||||||
title: args.message ? `Committed: ${args.message}` : 'Committed Changes',
|
title: args.message ? `Committed: ${args.message}` : 'Committed changes',
|
||||||
callingTitle: args.message ? `Committing: ${args.message}` : 'Committing Changes',
|
callingTitle: args.message ? `Committing: ${args.message}` : 'Committing changes',
|
||||||
errorTitle: 'Failed to Commit Changes',
|
errorTitle: 'Failed to commit changes',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'build_project':
|
case 'build_project':
|
||||||
return {
|
return {
|
||||||
icon: Package,
|
icon: Package,
|
||||||
title: 'Built Project',
|
title: 'Built project',
|
||||||
callingTitle: 'Building Project',
|
callingTitle: 'Building project',
|
||||||
errorTitle: 'Failed to Build Project',
|
errorTitle: 'Failed to build project',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_read_nip':
|
case 'nostr_read_nip':
|
||||||
@@ -160,55 +245,55 @@ function getToolInfo(toolName: string, args: Record<string, unknown>): ToolInfo
|
|||||||
icon: BookOpen,
|
icon: BookOpen,
|
||||||
title: args.nip ? `Read NIP-${args.nip}` : 'Read NIP',
|
title: args.nip ? `Read NIP-${args.nip}` : 'Read NIP',
|
||||||
callingTitle: args.nip ? `Reading NIP-${args.nip}` : 'Reading NIP',
|
callingTitle: args.nip ? `Reading NIP-${args.nip}` : 'Reading NIP',
|
||||||
errorTitle: args.nip ? `Failed to read NIP-${args.nip}` : 'Failed to Read NIP',
|
errorTitle: args.nip ? `Failed to read NIP-${args.nip}` : 'Failed to read NIP',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_fetch_event':
|
case 'nostr_fetch_event':
|
||||||
return {
|
return {
|
||||||
icon: Download,
|
icon: Download,
|
||||||
title: args.identifier ? `Fetched ${String(args.identifier).slice(0, 16)}...` : 'Fetched Event',
|
title: args.identifier ? `Viewed ${String(args.identifier).slice(0, 16)}...` : 'Viewed event',
|
||||||
callingTitle: args.identifier ? `Fetching ${String(args.identifier).slice(0, 16)}...` : 'Fetching Event',
|
callingTitle: args.identifier ? `Viewing ${String(args.identifier).slice(0, 16)}...` : 'Viewing event',
|
||||||
errorTitle: args.identifier ? `Failed to fetch ${String(args.identifier).slice(0, 16)}...` : 'Failed to Fetch Event',
|
errorTitle: args.identifier ? `Failed to view ${String(args.identifier).slice(0, 16)}...` : 'Failed to view event',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_read_kind':
|
case 'nostr_read_kind':
|
||||||
return {
|
return {
|
||||||
icon: Hash,
|
icon: Hash,
|
||||||
title: args.kind !== undefined ? `Read Kind ${args.kind}` : 'Read Kind',
|
title: args.kind !== undefined ? `Viewed kind ${args.kind}` : 'Viewed kind',
|
||||||
callingTitle: args.kind !== undefined ? `Reading Kind ${args.kind}` : 'Reading Kind',
|
callingTitle: args.kind !== undefined ? `Viewing kind ${args.kind}` : 'Viewing kind',
|
||||||
errorTitle: args.kind !== undefined ? `Failed to read Kind ${args.kind}` : 'Failed to Read Kind',
|
errorTitle: args.kind !== undefined ? `Failed to view kind ${args.kind}` : 'Failed to view kind',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_read_tag':
|
case 'nostr_read_tag':
|
||||||
return {
|
return {
|
||||||
icon: Tag,
|
icon: Tag,
|
||||||
title: args.tag ? `Read Tag "${args.tag}"` : 'Read Tag',
|
title: args.tag ? `Viewed tag "${args.tag}"` : 'Viewed tag',
|
||||||
callingTitle: args.tag ? `Reading Tag "${args.tag}"` : 'Reading Tag',
|
callingTitle: args.tag ? `Viewing tag "${args.tag}"` : 'Viewing tag',
|
||||||
errorTitle: args.tag ? `Failed to read Tag "${args.tag}"` : 'Failed to Read Tag',
|
errorTitle: args.tag ? `Failed to view tag "${args.tag}"` : 'Failed to view tag',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_read_protocol':
|
case 'nostr_read_protocol':
|
||||||
return {
|
return {
|
||||||
icon: Network,
|
icon: Network,
|
||||||
title: args.doc ? `Read Protocol: ${args.doc}` : 'Read Protocol',
|
title: args.doc ? `Viewed protocol ${args.doc}` : 'Viewed protocol',
|
||||||
callingTitle: args.doc ? `Reading Protocol: ${args.doc}` : 'Reading Protocol',
|
callingTitle: args.doc ? `Viewing protocol ${args.doc}` : 'Viewing protocol',
|
||||||
errorTitle: args.doc ? `Failed to read Protocol: ${args.doc}` : 'Failed to Read Protocol',
|
errorTitle: args.doc ? `Failed to view protocol ${args.doc}` : 'Failed to view protocol',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_read_nips_index':
|
case 'nostr_read_nips_index':
|
||||||
return {
|
return {
|
||||||
icon: List,
|
icon: List,
|
||||||
title: 'Read NIPs Index',
|
title: 'Viewed NIPs index',
|
||||||
callingTitle: 'Reading NIPs Index',
|
callingTitle: 'Viewing NIPs index',
|
||||||
errorTitle: 'Failed to Read NIPs Index',
|
errorTitle: 'Failed to view NIPs index',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_generate_kind':
|
case 'nostr_generate_kind':
|
||||||
return {
|
return {
|
||||||
icon: Plus,
|
icon: Plus,
|
||||||
title: args.range ? `Generated ${args.range} kind` : 'Generated Kind',
|
title: args.range ? `Generated ${args.range} kind` : 'Generated kind',
|
||||||
callingTitle: args.range ? `Generating ${args.range} kind` : 'Generating Kind',
|
callingTitle: args.range ? `Generating ${args.range} kind` : 'Generating kind',
|
||||||
errorTitle: args.range ? `Failed to generate ${args.range} kind` : 'Failed to Generate Kind',
|
errorTitle: args.range ? `Failed to generate ${args.range} kind` : 'Failed to generate kind',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'nostr_publish_events': {
|
case 'nostr_publish_events': {
|
||||||
@@ -217,58 +302,136 @@ function getToolInfo(toolName: string, args: Record<string, unknown>): ToolInfo
|
|||||||
icon: Send,
|
icon: Send,
|
||||||
title: eventCount > 1 ? `Published ${eventCount} Nostr events` : 'Published Nostr event',
|
title: eventCount > 1 ? `Published ${eventCount} Nostr events` : 'Published Nostr event',
|
||||||
callingTitle: eventCount > 1 ? `Publishing ${eventCount} Nostr events` : 'Publishing Nostr event',
|
callingTitle: eventCount > 1 ? `Publishing ${eventCount} Nostr events` : 'Publishing Nostr event',
|
||||||
errorTitle: eventCount > 1 ? `Failed to publish ${eventCount} Nostr events` : 'Failed to Publish Nostr Event',
|
errorTitle: eventCount > 1 ? `Failed to publish ${eventCount} Nostr events` : 'Failed to publish Nostr event',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'deploy_project':
|
case 'deploy_project':
|
||||||
return {
|
return {
|
||||||
icon: Globe,
|
icon: Globe,
|
||||||
title: args.deployServer ? `Deployed to ${args.deployServer}` : 'Deployed Project',
|
title: args.deployServer ? `Deployed to ${args.deployServer}` : 'Deployed project',
|
||||||
callingTitle: args.deployServer ? `Deploying to ${args.deployServer}` : 'Deploying Project',
|
callingTitle: args.deployServer ? `Deploying to ${args.deployServer}` : 'Deploying project',
|
||||||
errorTitle: args.deployServer ? `Failed to deploy to ${args.deployServer}` : 'Failed to Deploy Project',
|
errorTitle: args.deployServer ? `Failed to deploy to ${args.deployServer}` : 'Failed to deploy project',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'read_console_messages':
|
case 'read_console_messages':
|
||||||
return {
|
return {
|
||||||
icon: Logs,
|
icon: Logs,
|
||||||
title: 'Read Console',
|
title: 'Viewed console',
|
||||||
callingTitle: 'Reading Console',
|
callingTitle: 'Viewing console',
|
||||||
errorTitle: 'Failed to Read Console',
|
errorTitle: 'Failed to view console',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case 'webfetch': {
|
||||||
|
const url = args.url ? String(args.url) : '';
|
||||||
|
return {
|
||||||
|
icon: Globe,
|
||||||
|
title: url ? `Viewed ${url}` : 'Viewed webpage',
|
||||||
|
callingTitle: url ? `Viewing ${url}` : 'Viewing webpage',
|
||||||
|
errorTitle: url ? `Failed to view ${url}` : 'Failed to view webpage',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'websearch': {
|
||||||
|
const query = args.query ? String(args.query) : '';
|
||||||
|
return {
|
||||||
|
icon: Search,
|
||||||
|
title: query ? `Searched "${query}"` : 'Web search',
|
||||||
|
callingTitle: query ? `Searching "${query}"` : 'Searching web',
|
||||||
|
errorTitle: query ? `Failed to search "${query}"` : 'Search failed',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
case 'skill':
|
case 'skill':
|
||||||
return {
|
return {
|
||||||
icon: Puzzle,
|
icon: Puzzle,
|
||||||
title: args.name ? `Skill: ${args.name}` : 'Skill',
|
title: args.name ? `Skill: ${args.name}` : 'Skill',
|
||||||
callingTitle: args.name ? `Running Skill: ${args.name}` : 'Running Skill',
|
callingTitle: args.name ? `Running skill: ${args.name}` : 'Running skill',
|
||||||
errorTitle: args.name ? `Skill Failed: ${args.name}` : 'Skill Failed',
|
errorTitle: args.name ? `Skill failed: ${args.name}` : 'Skill failed',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'generate_image':
|
case 'generate_image':
|
||||||
return {
|
return {
|
||||||
icon: Image,
|
icon: Image,
|
||||||
title: args.prompt ? String(args.prompt) : 'Generated Image',
|
title: args.prompt ? String(args.prompt) : 'Generated image',
|
||||||
callingTitle: args.prompt ? String(args.prompt) : 'Generating Image',
|
callingTitle: args.prompt ? String(args.prompt) : 'Generating image',
|
||||||
errorTitle: 'Failed to Generate Image',
|
errorTitle: 'Failed to generate image',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'view_available_models':
|
case 'view_available_models':
|
||||||
return {
|
return {
|
||||||
icon: Eye,
|
icon: Eye,
|
||||||
title: 'Viewed Available Models',
|
title: 'Viewed available models',
|
||||||
callingTitle: 'Viewing Available Models',
|
callingTitle: 'Viewing available models',
|
||||||
errorTitle: 'Failed to View Available Models',
|
errorTitle: 'Failed to view available models',
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'configure_image_generation':
|
case 'configure_image_generation':
|
||||||
return {
|
return {
|
||||||
icon: Settings,
|
icon: Settings,
|
||||||
title: args.model ? `Configured image model: ${args.model}` : 'Configured Image Generation',
|
title: args.model ? `Configured image model: ${args.model}` : 'Configured image generation',
|
||||||
callingTitle: args.model ? `Configuring image model: ${args.model}` : 'Configuring Image Generation',
|
callingTitle: args.model ? `Configuring image model: ${args.model}` : 'Configuring image generation',
|
||||||
errorTitle: args.model ? `Failed to configure image model: ${args.model}` : 'Failed to Configure Image Generation',
|
errorTitle: args.model ? `Failed to configure image model: ${args.model}` : 'Failed to configure image generation',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case 'todowrite':
|
||||||
|
case 'todoread': {
|
||||||
|
// Try to parse the result to get task counts for the title
|
||||||
|
let title = toolName === 'todowrite' ? 'Updated todo list' : 'Viewed todo list';
|
||||||
|
if (result) {
|
||||||
|
try {
|
||||||
|
const todos = JSON.parse(result);
|
||||||
|
if (Array.isArray(todos)) {
|
||||||
|
const activeTodos = todos.filter((x: { status: string }) => x.status !== 'completed' && x.status !== 'cancelled');
|
||||||
|
const completedTodos = todos.filter((x: { status: string }) => x.status === 'completed');
|
||||||
|
const inProgressTask = todos.find((x: { status: string }) => x.status === 'in_progress');
|
||||||
|
|
||||||
|
// Format: "[<completed>/<total>] <active-task>" if in_progress task exists
|
||||||
|
if (inProgressTask) {
|
||||||
|
const taskName = inProgressTask.content || 'Task';
|
||||||
|
const totalTasks = todos.length;
|
||||||
|
title = `[${completedTodos.length + 1}/${totalTasks}] ${taskName}`;
|
||||||
|
} else if (activeTodos.length === 0 && completedTodos.length > 0) {
|
||||||
|
// All tasks completed
|
||||||
|
title = `${completedTodos.length + 1} task${completedTodos.length !== 0 ? 's' : ''} completed`;
|
||||||
|
} else if (completedTodos.length === 0) {
|
||||||
|
// No completed tasks yet
|
||||||
|
title = `${activeTodos.length} active task${activeTodos.length !== 1 ? 's' : ''}`;
|
||||||
|
} else {
|
||||||
|
title = `${activeTodos.length} active task${activeTodos.length !== 1 ? 's' : ''}, ${completedTodos.length} completed`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// If parsing fails, use default title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
icon: Clipboard,
|
||||||
|
title,
|
||||||
|
callingTitle: toolName === 'todowrite' ? 'Updating todo list' : 'Viewing todo list',
|
||||||
|
errorTitle: toolName === 'todowrite' ? 'Failed to update todo list' : 'Failed to view todo list',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'app': {
|
||||||
|
const action = args.action as string | undefined;
|
||||||
|
if (action === 'view_app') {
|
||||||
|
return {
|
||||||
|
icon: AppWindow,
|
||||||
|
title: 'Viewed app',
|
||||||
|
callingTitle: 'Viewing app',
|
||||||
|
errorTitle: 'Failed to view app',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const name = args.name ? String(args.name) : 'app';
|
||||||
|
return {
|
||||||
|
icon: AppWindow,
|
||||||
|
title: `Updated ${name}`,
|
||||||
|
callingTitle: `Updating ${name}`,
|
||||||
|
errorTitle: `Failed to update ${name}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
const formattedName = toolName.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
const formattedName = toolName.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
||||||
return {
|
return {
|
||||||
@@ -299,12 +462,13 @@ function parseToolError(result: string | undefined, expectedToolName: string): s
|
|||||||
/**
|
/**
|
||||||
* Unified component for displaying tool calls in all states
|
* Unified component for displaying tool calls in all states
|
||||||
*/
|
*/
|
||||||
export function ToolCallDisplay({ toolName, toolArgs, state, result }: ToolCallDisplayProps) {
|
export function ToolCallDisplay({ toolName, toolArgs, state, result, projectId }: ToolCallDisplayProps) {
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
const [expandedImageUrl, setExpandedImageUrl] = useState<string | null>(null);
|
const [expandedImageUrl, setExpandedImageUrl] = useState<string | null>(null);
|
||||||
const [imageLoadError, setImageLoadError] = useState(false);
|
const [imageLoadError, setImageLoadError] = useState(false);
|
||||||
|
const { projectsPath } = useFSPaths();
|
||||||
|
|
||||||
const toolInfo = getToolInfo(toolName, toolArgs);
|
const toolInfo = getToolInfo(toolName, toolArgs, projectId, projectsPath, result);
|
||||||
const IconComponent = toolInfo.icon;
|
const IconComponent = toolInfo.icon;
|
||||||
|
|
||||||
// Check if this is an error result
|
// Check if this is an error result
|
||||||
@@ -342,19 +506,26 @@ export function ToolCallDisplay({ toolName, toolArgs, state, result }: ToolCallD
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolName === 'text_editor_write' && typeof toolArgs.file_text === 'string') {
|
// Write tool expanded content (new and legacy)
|
||||||
|
if ((toolName === 'write' && typeof toolArgs.content === 'string') ||
|
||||||
|
(toolName === 'text_editor_write' && typeof toolArgs.file_text === 'string')) {
|
||||||
|
const content = toolName === 'write' ? String(toolArgs.content) : String(toolArgs.file_text);
|
||||||
return (
|
return (
|
||||||
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs">
|
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs">
|
||||||
<div className="whitespace-pre-wrap break-words font-mono">
|
<div className="whitespace-pre-wrap break-words font-mono">
|
||||||
{toolArgs.file_text}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolName === 'text_editor_str_replace' && typeof toolArgs.old_str === 'string' && typeof toolArgs.new_str === 'string') {
|
// Edit tool expanded content (new and legacy)
|
||||||
const oldLines = String(toolArgs.old_str).split('\n');
|
if ((toolName === 'edit' && typeof toolArgs.oldString === 'string' && typeof toolArgs.newString === 'string') ||
|
||||||
const newLines = String(toolArgs.new_str).split('\n');
|
(toolName === 'text_editor_str_replace' && typeof toolArgs.old_str === 'string' && typeof toolArgs.new_str === 'string')) {
|
||||||
|
const oldStr = toolName === 'edit' ? String(toolArgs.oldString) : String(toolArgs.old_str);
|
||||||
|
const newStr = toolName === 'edit' ? String(toolArgs.newString) : String(toolArgs.new_str);
|
||||||
|
const oldLines = oldStr.split('\n');
|
||||||
|
const newLines = newStr.split('\n');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs font-mono">
|
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs font-mono">
|
||||||
@@ -387,6 +558,56 @@ export function ToolCallDisplay({ toolName, toolArgs, state, result }: ToolCallD
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read tool expanded content - parse and display file content nicely
|
||||||
|
if (toolName === 'read' || toolName === 'text_editor_view') {
|
||||||
|
// Parse the result to extract file content from <file> tags
|
||||||
|
const fileMatch = result.match(/<file>\n([\s\S]*?)\n\n\((.*?)\)\n<\/file>/);
|
||||||
|
if (fileMatch) {
|
||||||
|
const fileContent = fileMatch[1];
|
||||||
|
const footerMessage = fileMatch[2];
|
||||||
|
|
||||||
|
// Split content into lines and parse line numbers
|
||||||
|
const lines = fileContent.split('\n');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mt-1 rounded border bg-background text-xs font-mono overflow-hidden">
|
||||||
|
<div className="max-h-96 overflow-y-auto">
|
||||||
|
<div>
|
||||||
|
{lines.map((line, idx) => {
|
||||||
|
// Parse line number and content (format: " 1| content")
|
||||||
|
const match = line.match(/^(\s*\d+)\|(.*)$/);
|
||||||
|
if (match) {
|
||||||
|
return (
|
||||||
|
<div key={idx} className="flex hover:bg-muted/30 transition-colors">
|
||||||
|
<div className="text-muted-foreground/60 select-none px-3 py-0.5 text-right min-w-[3rem] bg-muted/20">
|
||||||
|
{match[1].trim()}
|
||||||
|
</div>
|
||||||
|
<div className="flex-1 px-3 py-0.5 whitespace-pre-wrap break-words">
|
||||||
|
{match[2]}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Fallback for lines that don't match expected format
|
||||||
|
return (
|
||||||
|
<div key={idx} className="px-3 py-0.5 whitespace-pre-wrap break-words">
|
||||||
|
{line}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{footerMessage && (
|
||||||
|
<div className="px-3 py-1.5 bg-muted/30 border-t text-muted-foreground text-[10px]">
|
||||||
|
{footerMessage}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Fallback to default rendering if no <file> tags found
|
||||||
|
}
|
||||||
|
|
||||||
if (toolName === 'generate_image') {
|
if (toolName === 'generate_image') {
|
||||||
// For generate_image, when expanded show the full prompt
|
// For generate_image, when expanded show the full prompt
|
||||||
return (
|
return (
|
||||||
@@ -396,6 +617,58 @@ export function ToolCallDisplay({ toolName, toolArgs, state, result }: ToolCallD
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo tools expanded content
|
||||||
|
if (toolName === 'todowrite' || toolName === 'todoread') {
|
||||||
|
try {
|
||||||
|
const todos = JSON.parse(result);
|
||||||
|
if (!Array.isArray(todos)) {
|
||||||
|
throw new Error('Invalid todo format');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (todos.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs">
|
||||||
|
<div className="text-muted-foreground italic">No todos found</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first in_progress task for bold styling
|
||||||
|
const firstInProgressIndex = todos.findIndex((x: { status: string }) => x.status === 'in_progress');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mt-1 rounded border bg-muted/30 text-xs overflow-hidden">
|
||||||
|
<div className="px-3 py-2 space-y-1">
|
||||||
|
{todos.map((todo: { id: string; content: string; status: string; priority: string }, index: number) => {
|
||||||
|
const isChecked = todo.status === 'completed' || todo.status === 'cancelled';
|
||||||
|
const isFirstInProgress = index === firstInProgressIndex;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={todo.id} className="flex items-start gap-2 py-1">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={isChecked}
|
||||||
|
readOnly
|
||||||
|
className="mt-0.5 h-4 w-4 rounded border-gray-300 cursor-default"
|
||||||
|
/>
|
||||||
|
<span className={cn(
|
||||||
|
"flex-1 text-foreground",
|
||||||
|
isChecked && "line-through text-muted-foreground",
|
||||||
|
isFirstInProgress && "font-bold"
|
||||||
|
)}>
|
||||||
|
{todo.content}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
// If parsing fails, fall through to default rendering
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Default rendering for other tools
|
// Default rendering for other tools
|
||||||
return (
|
return (
|
||||||
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs">
|
<div className="mt-1 p-3 bg-muted/30 rounded border text-xs">
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import { useState, useRef, KeyboardEvent } from 'react';
|
||||||
|
import { X, Plus } from 'lucide-react';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
|
interface UrlListEditorProps {
|
||||||
|
/** Label shown above the list */
|
||||||
|
label: string;
|
||||||
|
/** Current array of full URLs */
|
||||||
|
items: string[];
|
||||||
|
/** Called when the list changes */
|
||||||
|
onChange: (items: string[]) => void;
|
||||||
|
/** Controls auto-prefix on bare domain entry */
|
||||||
|
protocol: 'wss' | 'https';
|
||||||
|
/** Placeholder shown in the add input */
|
||||||
|
placeholder?: string;
|
||||||
|
/** Whether to show the required asterisk */
|
||||||
|
required?: boolean;
|
||||||
|
/** Additional CSS classes for the root element */
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a bare domain or partial URL to a fully-qualified URL.
|
||||||
|
* If the value already has any protocol it is returned as-is.
|
||||||
|
*/
|
||||||
|
function normalizeEntry(value: string, protocol: 'wss' | 'https'): string {
|
||||||
|
const trimmed = value.trim();
|
||||||
|
if (!trimmed) return '';
|
||||||
|
if (/^wss?:\/\//i.test(trimmed) || /^https?:\/\//i.test(trimmed)) return trimmed;
|
||||||
|
return `${protocol}://${trimmed}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a URL to an https:// form suitable for favicon lookup.
|
||||||
|
* wss:// → https://, ws:// → http://
|
||||||
|
*/
|
||||||
|
function toHttpsUrl(url: string): string {
|
||||||
|
return url.replace(/^wss:\/\//i, 'https://').replace(/^ws:\/\//i, 'http://');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Strip the protocol prefix for compact display */
|
||||||
|
function displayLabel(url: string): string {
|
||||||
|
return url.replace(/^wss?:\/\//i, '').replace(/^https?:\/\//i, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UrlListEditor({
|
||||||
|
label,
|
||||||
|
items,
|
||||||
|
onChange,
|
||||||
|
protocol,
|
||||||
|
placeholder,
|
||||||
|
required,
|
||||||
|
className,
|
||||||
|
}: UrlListEditorProps) {
|
||||||
|
const [inputValue, setInputValue] = useState('');
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
const handleAdd = () => {
|
||||||
|
const normalized = normalizeEntry(inputValue, protocol);
|
||||||
|
if (!normalized) return;
|
||||||
|
// Silently ignore duplicates
|
||||||
|
if (items.includes(normalized)) {
|
||||||
|
setInputValue('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onChange([...items, normalized]);
|
||||||
|
setInputValue('');
|
||||||
|
inputRef.current?.focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRemove = (index: number) => {
|
||||||
|
onChange(items.filter((_, i) => i !== index));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
handleAdd();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn('grid gap-2', className)}>
|
||||||
|
<Label>
|
||||||
|
{label}
|
||||||
|
{required && <span className="text-destructive ml-1">*</span>}
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
{/* Scrollable list of existing items */}
|
||||||
|
{items.length > 0 && (
|
||||||
|
<div className="rounded-md border overflow-y-auto max-h-48">
|
||||||
|
{items.map((item, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="flex items-center gap-2 px-3 py-2 hover:bg-muted border-b last:border-b-0"
|
||||||
|
>
|
||||||
|
<ExternalFavicon
|
||||||
|
url={toHttpsUrl(item)}
|
||||||
|
size={14}
|
||||||
|
className="shrink-0 opacity-70"
|
||||||
|
/>
|
||||||
|
<span className="flex-1 text-sm font-mono truncate">
|
||||||
|
{displayLabel(item)}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-6 w-6 shrink-0 text-muted-foreground hover:text-destructive"
|
||||||
|
onClick={() => handleRemove(index)}
|
||||||
|
aria-label={`Remove ${item}`}
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Add input */}
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
|
value={inputValue}
|
||||||
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
placeholder={placeholder ?? (protocol === 'wss' ? 'relay.example.com' : 'server.example.com')}
|
||||||
|
className="font-mono text-sm"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
onClick={handleAdd}
|
||||||
|
disabled={!inputValue.trim()}
|
||||||
|
aria-label={`Add ${label}`}
|
||||||
|
>
|
||||||
|
<Plus className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { toast } from '@/hooks/useToast';
|
||||||
|
import { ToastAction } from '@/components/ui/toast';
|
||||||
|
import { parseChangelog } from '@/lib/changelog';
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'shakespeare:app-version';
|
||||||
|
|
||||||
|
/** Fetch the first changelog item for the given version (or the latest entry). */
|
||||||
|
async function fetchChangelogExcerpt(version: string): Promise<string | undefined> {
|
||||||
|
try {
|
||||||
|
const res = await fetch('/CHANGELOG.md');
|
||||||
|
if (!res.ok) return undefined;
|
||||||
|
const markdown = await res.text();
|
||||||
|
const entries = parseChangelog(markdown);
|
||||||
|
|
||||||
|
// Try to find the entry matching the current version, otherwise use the first entry.
|
||||||
|
const entry = entries.find((e) => e.version === version) ?? entries[0];
|
||||||
|
if (!entry) return undefined;
|
||||||
|
|
||||||
|
// Return a truncated first item from the first section.
|
||||||
|
const item = entry.sections[0]?.items[0];
|
||||||
|
if (!item) return undefined;
|
||||||
|
if (item.length <= 60) return item;
|
||||||
|
return item.slice(0, 60).trimEnd() + '…';
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compares the running app version against localStorage and shows a toast when the version changes. */
|
||||||
|
export function VersionCheck() {
|
||||||
|
useEffect(() => {
|
||||||
|
const currentVersion = import.meta.env.VERSION;
|
||||||
|
if (!currentVersion) return;
|
||||||
|
|
||||||
|
const storedVersion = localStorage.getItem(STORAGE_KEY);
|
||||||
|
localStorage.setItem(STORAGE_KEY, currentVersion);
|
||||||
|
|
||||||
|
if (storedVersion && storedVersion !== currentVersion) {
|
||||||
|
// Show the toast immediately, then enrich it with a changelog excerpt.
|
||||||
|
const { update, id } = toast({
|
||||||
|
title: `What's new in v${currentVersion}`,
|
||||||
|
action: (
|
||||||
|
<ToastAction altText="View changelog" asChild>
|
||||||
|
<Link to="/changelog">See all</Link>
|
||||||
|
</ToastAction>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
fetchChangelogExcerpt(currentVersion).then((excerpt) => {
|
||||||
|
if (excerpt) {
|
||||||
|
update({
|
||||||
|
id,
|
||||||
|
title: `What's new in v${currentVersion}`,
|
||||||
|
description: excerpt,
|
||||||
|
action: (
|
||||||
|
<ToastAction altText="View changelog" asChild>
|
||||||
|
<Link to="/changelog">See all</Link>
|
||||||
|
</ToastAction>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -63,10 +63,10 @@ export function CloudflareDeployForm({
|
|||||||
const workersUrl = `${baseURL}/accounts/${accountId}/workers/scripts`;
|
const workersUrl = `${baseURL}/accounts/${accountId}/workers/scripts`;
|
||||||
|
|
||||||
const [subdomainResponse, workersResponse] = await Promise.all([
|
const [subdomainResponse, workersResponse] = await Promise.all([
|
||||||
fetch(corsProxy ? proxyUrl(corsProxy, subdomainUrl) : subdomainUrl, {
|
fetch(corsProxy ? proxyUrl({ template: corsProxy, url: subdomainUrl }) : subdomainUrl, {
|
||||||
headers: { 'Authorization': `Bearer ${apiKey}` },
|
headers: { 'Authorization': `Bearer ${apiKey}` },
|
||||||
}),
|
}),
|
||||||
fetch(corsProxy ? proxyUrl(corsProxy, workersUrl) : workersUrl, {
|
fetch(corsProxy ? proxyUrl({ template: corsProxy, url: workersUrl }) : workersUrl, {
|
||||||
headers: { 'Authorization': `Bearer ${apiKey}` },
|
headers: { 'Authorization': `Bearer ${apiKey}` },
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export function DenoDeployForm({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const url = `${baseURL}/organizations/${organizationId}/projects?limit=100`;
|
const url = `${baseURL}/organizations/${organizationId}/projects?limit=100`;
|
||||||
const targetUrl = corsProxy ? proxyUrl(corsProxy, url) : url;
|
const targetUrl = corsProxy ? proxyUrl({ template: corsProxy, url }) : url;
|
||||||
|
|
||||||
const response = await fetch(targetUrl, {
|
const response = await fetch(targetUrl, {
|
||||||
headers: { 'Authorization': `Bearer ${apiKey}` },
|
headers: { 'Authorization': `Bearer ${apiKey}` },
|
||||||
|
|||||||