Compare commits

..
3 Commits
Author SHA1 Message Date
Alex Gleason a94f3fbde6 Enable text chats 2025-10-04 19:44:54 -05:00
Alex Gleason 0f0f9e6945 Hide recentlyUsed models in the total list 2025-10-04 17:12:19 -05:00
Alex Gleason 07048d2b5f gitignore Android files 2025-10-04 17:01:41 -05:00
62 changed files with 705 additions and 2318 deletions

No files matched your search

-1
View File
@@ -12,7 +12,6 @@ dist
dist-ssr
*.local
.ai-history/
.tmp.webmanifest
*.apk
*.aab
+1 -4
View File
@@ -1,7 +1,4 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
"editor.insertSpaces": true
}
-104
View File
@@ -1,104 +0,0 @@
# 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
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# 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
# Generated assets
app/src/main/res/*/*.png
-2
View File
@@ -1,2 +0,0 @@
/build/*
!/build/.npmkeep
-80
View File
@@ -1,80 +0,0 @@
apply plugin: 'com.android.application'
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 "1.0"
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 {
def keystorePath = rootProject.file("../shakespeare.keystore")
// Only require keystore for release builds
def taskNames = gradle.startParameter.taskNames.toString()
def isReleaseBuild = taskNames.contains("Release") || taskNames.contains("release") || taskNames.contains("bundle")
if (!isReleaseBuild) {
// Skip signing config for debug builds
return
}
if (!keystorePath.exists()) {
throw new GradleException("shakespeare.keystore not found! Expected at: " + keystorePath.absolutePath)
}
storeFile keystorePath
keyAlias "mykey"
storePassword "shakespeare"
keyPassword "shakespeare"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
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')
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")
}
-23
View File
@@ -1,23 +0,0 @@
// 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-filesystem')
implementation project(':capacitor-keyboard')
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
}
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}
-21
View File
@@ -1,21 +0,0 @@
# 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
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# 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
-35
View File
@@ -1,35 +0,0 @@
<?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"
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>
</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" />
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
@@ -1,5 +0,0 @@
package diy.shakespeare.app;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {}
@@ -1,34 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
@@ -1,170 +0,0 @@
<?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="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
@@ -1,12 +0,0 @@
<?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>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background>
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
</background>
<foreground>
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
</foreground>
</adaptive-icon>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background>
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
</background>
<foreground>
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
</foreground>
</adaptive-icon>
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
@@ -1,7 +0,0 @@
<?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>
@@ -1,20 +0,0 @@
<?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="android:background">@drawable/splash</item>
</style>
</resources>
@@ -1,5 +0,0 @@
<?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>
@@ -1,18 +0,0 @@
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);
}
}
-29
View File
@@ -1,29 +0,0 @@
// 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.7.2'
classpath 'com.google.gms:google-services:4.4.2'
// 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
}
-18
View File
@@ -1,18 +0,0 @@
// 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-filesystem'
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')
include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android')
include ':capacitor-splash-screen'
project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android')
include ':capacitor-status-bar'
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
-22
View File
@@ -1,22 +0,0 @@
# 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
Binary file not shown.
-7
View File
@@ -1,7 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-252
View File
@@ -1,252 +0,0 @@
#!/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
' "$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=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# 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, 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" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# 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" "$@"
-94
View File
@@ -1,94 +0,0 @@
@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=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
: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
-5
View File
@@ -1,5 +0,0 @@
include ':app'
include ':capacitor-cordova-android-plugins'
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
apply from: 'capacitor.settings.gradle'
-16
View File
@@ -1,16 +0,0 @@
ext {
minSdkVersion = 23
compileSdkVersion = 35
targetSdkVersion = 35
androidxActivityVersion = '1.9.2'
androidxAppCompatVersion = '1.7.0'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxCoreVersion = '1.15.0'
androidxFragmentVersion = '1.8.4'
coreSplashScreenVersion = '1.0.1'
androidxWebkitVersion = '1.12.1'
junitVersion = '4.13.2'
androidxJunitVersion = '1.2.1'
androidxEspressoCoreVersion = '3.6.1'
cordovaAndroidVersion = '10.1.1'
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 KiB

-29
View File
@@ -1,29 +0,0 @@
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'diy.shakespeare.app',
appName: 'Shakespeare',
webDir: 'dist',
server: {
androidScheme: 'https'
},
plugins: {
SplashScreen: {
launchShowDuration: 2000,
launchAutoHide: true,
backgroundColor: "#ffffff",
androidSplashResourceName: "splash",
androidScaleType: "CENTER_CROP",
showSpinner: false
},
StatusBar: {
style: 'default'
},
Filesystem: {
// Use app data directory for all file operations
// This directory is included in Android backups
}
}
};
export default config;
-72
View File
@@ -1,72 +0,0 @@
## Mobile Development
Shakespeare supports building native Android apps using Capacitor.js. The mobile app provides the full Shakespeare experience with native mobile optimizations.
### Native Filesystem
Shakespeare automatically uses **native filesystem storage** on Android for better performance and reliability:
- **2-3x faster** file operations compared to web version
- **No storage quotas** - uses device storage directly
- **Automatic backups** - data included in Android backups
- **Better battery life** - 10-15% improvement during file operations
- **Automatic migration** - seamlessly migrates existing projects from web to native storage on first run
### Android Development
#### Prerequisites
- [Android Studio](https://developer.android.com/studio) installed
- Android SDK and build tools
- Java Development Kit (JDK) 17 or higher
#### Building for Android
1. **Build the web app:**
```bash
npm run build
```
2. **Sync web assets to Android:**
```bash
npm run android:sync
```
3. **Open in Android Studio:**
```bash
npm run android:open
```
4. **Build APK directly (optional):**
```bash
npm run android:build
```
5. **Run on device/emulator:**
```bash
npm run android:run
```
#### Available Scripts
- `android:build` - Build web app and create Android APK
- `android:open` - Open the Android project in Android Studio
- `android:sync` - Sync web assets to Android project
- `android:run` - Build, sync, and run on connected device/emulator
#### Mobile Features
- **Native status bar integration** with theme-aware styling
- **Splash screen** with Shakespeare branding
- **Keyboard handling** for better mobile UX
- **Hardware back button** support on Android
- **Safe area support** for modern devices with notches
- **Touch-optimized** UI elements (44px minimum touch targets)
- **Responsive design** that adapts to mobile screens
#### Customization
The mobile app can be customized by editing:
- `capacitor.config.ts` - Capacitor configuration
- `android/app/src/main/res/` - Android resources (icons, splash screens)
- `src/capacitor.ts` - Mobile-specific initialization code
-1009
View File
File diff suppressed because it is too large. Load diff
+1 -15
View File
@@ -8,22 +8,9 @@
"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",
"test": "npm i --silent && eslint && vitest run --reporter=dot --silent && echo 'All tests passed!'",
"deploy": "npm run build && npx -y nostr-deploy-cli deploy --skip-setup",
"android:aab": "npm run android:sync && cd android && ./gradlew bundleRelease && cd .. && cp android/app/build/outputs/bundle/release/app-release.aab shakespeare.aab",
"android:apk": "npm run android:sync && cd android && ./gradlew assembleRelease && cd .. && cp android/app/build/outputs/apk/release/app-release.apk shakespeare.apk",
"android:open": "npx cap open android",
"android:sync": "npm run build && npx cap sync android && npm run android:assets",
"android:run": "npm run android:sync && npx cap run android",
"android:assets": "npx -y @capacitor/assets generate --pwaManifestPath=.tmp.webmanifest && rm .tmp.webmanifest && rm -rf icons"
"deploy": "npm run build && npx -y nostr-deploy-cli deploy --skip-setup"
},
"dependencies": {
"@capacitor/android": "^7.4.3",
"@capacitor/app": "^7.1.0",
"@capacitor/core": "^7.4.3",
"@capacitor/filesystem": "^7.1.4",
"@capacitor/keyboard": "^7.0.3",
"@capacitor/splash-screen": "^7.0.3",
"@capacitor/status-bar": "^7.0.3",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
@@ -104,7 +91,6 @@
"zod": "^3.25.76"
},
"devDependencies": {
"@capacitor/cli": "^7.4.3",
"@eslint/js": "^9.9.0",
"@html-eslint/eslint-plugin": "^0.41.0",
"@html-eslint/parser": "^0.41.0",
+2 -9
View File
@@ -5,14 +5,7 @@
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#8b5cf6",
"orientation": "portrait-primary",
"categories": [
"productivity",
"developer",
"utilities"
],
"lang": "en",
"theme_color": "#000000",
"icons": [
{
"src": "/shakespeare.png",
@@ -25,4 +18,4 @@
"type": "image/png"
}
]
}
}
+1 -1
View File
@@ -52,7 +52,7 @@ const presetRelays = [
{ url: 'wss://relay.primal.net', name: 'Primal' },
];
// Initialize the filesystem
// Initialize LightningFS
const lightningFS = new LightningFS('shakespeare-fs');
const fs = new LightningFSAdapter(lightningFS.promises);
+2
View File
@@ -16,6 +16,7 @@ import GitHubOAuth from "./pages/GitHubOAuth";
import { NIP19Page } from "./pages/NIP19Page";
import NotFound from "./pages/NotFound";
import { ProjectView } from "./pages/ProjectView";
import { TextChatView } from "./pages/TextChatView";
import { SettingsLayout } from "./components/SettingsLayout";
export function AppRouter() {
@@ -37,6 +38,7 @@ export function AppRouter() {
<Route path="about" element={<AboutSettings />} />
</Route>
<Route path="/project/:projectId" element={<ProjectView />} />
<Route path="/chat/:chatId" element={<TextChatView />} />
{/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */}
<Route path="/:nip19" element={<NIP19Page />} />
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
-41
View File
@@ -1,41 +0,0 @@
import { Capacitor } from '@capacitor/core';
import { StatusBar, Style } from '@capacitor/status-bar';
import { SplashScreen } from '@capacitor/splash-screen';
import { Keyboard } from '@capacitor/keyboard';
import { App } from '@capacitor/app';
export const initializeCapacitor = async () => {
if (Capacitor.isNativePlatform()) {
// Hide splash screen
await SplashScreen.hide();
// Configure status bar
await StatusBar.setStyle({ style: Style.Default });
// Configure keyboard behavior
Keyboard.addListener('keyboardWillShow', () => {
document.body.classList.add('keyboard-open');
});
Keyboard.addListener('keyboardWillHide', () => {
document.body.classList.remove('keyboard-open');
});
// Handle app state changes
App.addListener('appStateChange', ({ isActive }) => {
console.log('App state changed. Is active?', isActive);
});
// Handle back button on Android
App.addListener('backButton', ({ canGoBack }) => {
if (!canGoBack) {
App.exitApp();
} else {
window.history.back();
}
});
}
};
export const isNativePlatform = () => Capacitor.isNativePlatform();
export const getPlatform = () => Capacitor.getPlatform();
+16 -12
View File
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { type Project } from '@/lib/ProjectsManager';
import { type ChatItem } from '@/lib/ProjectsManager';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { ProjectSidebar } from '@/components/ProjectSidebar';
import { Button } from '@/components/ui/button';
@@ -9,7 +9,7 @@ import { useIsMobile } from '@/hooks/useIsMobile';
interface AppLayoutProps {
children: React.ReactNode;
selectedProject?: Project | null;
selectedProject?: ChatItem | null;
title?: string;
showSidebar?: boolean;
headerContent?: React.ReactNode;
@@ -21,7 +21,7 @@ export function AppLayout({
showSidebar = true,
headerContent
}: AppLayoutProps) {
const [_projects, setProjects] = useState<Project[]>([]);
const [_projects, setProjects] = useState<ChatItem[]>([]);
const projectsManager = useProjectsManager();
const navigate = useNavigate();
const isMobile = useIsMobile();
@@ -34,7 +34,7 @@ export function AppLayout({
const loadProjects = useCallback(async () => {
try {
await projectsManager.init();
const projectList = await projectsManager.getProjects();
const projectList = await projectsManager.getAllChatItems();
setProjects(projectList);
// Set initial sidebar state based on projects and device type
@@ -59,10 +59,14 @@ export function AppLayout({
loadProjects();
}, [loadProjects]);
const handleProjectSelect = (project: Project | null) => {
if (project) {
const handleProjectSelect = (item: ChatItem | null) => {
if (item) {
setIsSidebarVisible(false); // Collapse sidebar on mobile navigation
navigate(`/project/${project.id}`);
if (item.type === 'project') {
navigate(`/project/${item.id}`);
} else {
navigate(`/chat/${item.id}`);
}
} else {
navigate('/');
}
@@ -101,10 +105,10 @@ export function AppLayout({
{/* Sidebar - positioned above the backdrop */}
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
<ProjectSidebar
selectedProject={selectedProject}
onSelectProject={(project) => {
selectedItem={selectedProject}
onSelectItem={(item) => {
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
handleProjectSelect(project);
handleProjectSelect(item);
}}
onClose={() => setIsSidebarVisible(false)}
/>
@@ -125,8 +129,8 @@ export function AppLayout({
{showSidebar && isSidebarVisible && (
<div className="w-80 border-r bg-sidebar transition-all duration-300">
<ProjectSidebar
selectedProject={selectedProject}
onSelectProject={handleProjectSelect}
selectedItem={selectedProject}
onSelectItem={handleProjectSelect}
className="h-screen sticky top-0"
onToggleSidebar={() => setIsSidebarVisible(false)}
/>
+16 -2
View File
@@ -102,11 +102,17 @@ describe('ModelSelector', () => {
// Wait for the dropdown to open
await waitFor(() => {
expect(screen.getByText('provider1')).toBeInTheDocument();
expect(screen.getByText('provider2')).toBeInTheDocument();
});
// Recently used section should NOT be visible
expect(screen.queryByText('Recently Used')).not.toBeInTheDocument();
// provider1 should be hidden since all its models are in recently used
expect(screen.queryByText('provider1')).not.toBeInTheDocument();
// provider2 should still show with model3
expect(screen.getByText('provider2/model3')).toBeInTheDocument();
});
it('shows recently used section when less than 5 models but some recently used are not available', async () => {
@@ -198,11 +204,19 @@ describe('ModelSelector', () => {
// Wait for the dropdown to open
await waitFor(() => {
expect(screen.getByText('provider1')).toBeInTheDocument();
expect(screen.getByText('provider2')).toBeInTheDocument();
});
// Recently used section SHOULD be visible
expect(screen.getByText('Recently Used')).toBeInTheDocument();
// provider1 should be hidden since all its models are in recently used
expect(screen.queryByText('provider1')).not.toBeInTheDocument();
// provider2 and provider3 should still show
expect(screen.getByText('provider2/model3')).toBeInTheDocument();
expect(screen.getByText('provider2/model4')).toBeInTheDocument();
expect(screen.getByText('provider3/model5')).toBeInTheDocument();
});
it('hides recently used section when no recently used models exist', async () => {
+10 -2
View File
@@ -51,17 +51,25 @@ export function ModelSelector({
const recentlyUsedModels = useMemo(() => settings.recentlyUsedModels || [], [settings.recentlyUsedModels]);
// Group models by provider
// Create a Set of recently used model IDs for efficient lookup
const recentlyUsedSet = useMemo(() => new Set(recentlyUsedModels), [recentlyUsedModels]);
// Group models by provider, excluding models that are in the recently used section
const modelsByProvider = useMemo(() => {
const groups: Record<string, typeof models> = {};
for (const model of models) {
// Skip models that are already shown in recently used
if (recentlyUsedSet.has(model.fullId)) {
continue;
}
if (!groups[model.provider]) {
groups[model.provider] = [];
}
groups[model.provider].push(model);
}
return groups;
}, [models]);
}, [models, recentlyUsedSet]);
// Determine if we should show the "Recently Used" section
const shouldShowRecentlyUsed = useMemo(() => {
+3 -4
View File
@@ -1,4 +1,3 @@
import { Capacitor } from '@capacitor/core';
import { Decimal } from 'decimal.js';
import { useState, useEffect, useRef } from 'react';
import { generateSecretKey } from 'nostr-tools';
@@ -277,7 +276,7 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
<div className="space-y-6 py-4">
<div className="text-center space-y-4">
<h2 className="text-2xl font-bold">
Shakespeare is Open Source software that runs entirely {Capacitor.isNativePlatform() ? 'on your device' : 'in your web browser'}
Shakespeare is Open Source software that runs entirely in your web&nbsp;browser
</h2>
</div>
@@ -288,11 +287,11 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
</div>
<div className="flex items-start gap-3 p-3 rounded-lg bg-muted/50">
<div className="h-2 w-2 rounded-full bg-primary mt-2 flex-shrink-0" />
<p className="text-sm">Your files are stored on your device{Capacitor.isNativePlatform() ? '' : ' in your browser'}</p>
<p className="text-sm">Your files are stored on your device in your browser</p>
</div>
<div className="flex items-start gap-3 p-3 rounded-lg bg-muted/50">
<div className="h-2 w-2 rounded-full bg-primary mt-2 flex-shrink-0" />
<p className="text-sm">Be careful not to delete your {Capacitor.isNativePlatform() ? 'app' : 'browser'} data or you may lose project files</p>
<p className="text-sm">Be careful not to delete your browser data or you may lose project files</p>
</div>
<div className="flex items-start gap-3 p-3 rounded-lg bg-muted/50">
<div className="h-2 w-2 rounded-full bg-primary mt-2 flex-shrink-0" />
+12 -12
View File
@@ -54,8 +54,8 @@ describe('ProjectSidebar', () => {
render(
<TestApp>
<ProjectSidebar
selectedProject={null}
onSelectProject={vi.fn()}
selectedItem={null}
onSelectItem={vi.fn()}
/>
</TestApp>
);
@@ -70,8 +70,8 @@ describe('ProjectSidebar', () => {
render(
<TestApp>
<ProjectSidebar
selectedProject={null}
onSelectProject={vi.fn()}
selectedItem={null}
onSelectItem={vi.fn()}
onToggleSidebar={mockToggle}
/>
</TestApp>
@@ -88,8 +88,8 @@ describe('ProjectSidebar', () => {
render(
<TestApp>
<ProjectSidebar
selectedProject={null}
onSelectProject={vi.fn()}
selectedItem={null}
onSelectItem={vi.fn()}
/>
</TestApp>
);
@@ -101,8 +101,8 @@ describe('ProjectSidebar', () => {
render(
<TestApp>
<ProjectSidebar
selectedProject={null}
onSelectProject={vi.fn()}
selectedItem={null}
onSelectItem={vi.fn()}
/>
</TestApp>
);
@@ -115,8 +115,8 @@ describe('ProjectSidebar', () => {
render(
<TestApp>
<ProjectSidebar
selectedProject={null}
onSelectProject={vi.fn()}
selectedItem={null}
onSelectItem={vi.fn()}
/>
</TestApp>
);
@@ -128,8 +128,8 @@ describe('ProjectSidebar', () => {
render(
<TestApp>
<ProjectSidebar
selectedProject={null}
onSelectProject={vi.fn()}
selectedItem={null}
onSelectItem={vi.fn()}
/>
</TestApp>
);
+45 -26
View File
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle } from 'lucide-react';
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle, MessageSquare } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
@@ -9,25 +9,29 @@ import { useProjects } from '@/hooks/useProjects';
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useIsMobile } from '@/hooks/useIsMobile';
import type { Project } from '@/lib/ProjectsManager';
import type { ChatItem } from '@/lib/ProjectsManager';
import { cn } from '@/lib/utils';
import { useQueryClient } from '@tanstack/react-query';
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
interface ProjectItemProps {
project: Project;
interface ChatItemProps {
item: ChatItem;
isSelected: boolean;
onSelect: (project: Project) => void;
onSelect: (item: ChatItem) => void;
isFavorite?: boolean;
}
const ProjectItem: React.FC<ProjectItemProps> = ({ project, isSelected, onSelect, isFavorite }) => {
const ChatItemComponent: React.FC<ChatItemProps> = ({ item, isSelected, onSelect, isFavorite }) => {
const navigate = useNavigate();
const { hasRunningSessions } = useProjectSessionStatus(project.id);
const { hasRunningSessions } = useProjectSessionStatus(item.id);
const handleClick = () => {
onSelect(project);
navigate(`/project/${project.id}`);
onSelect(item);
if (item.type === 'project') {
navigate(`/project/${item.id}`);
} else {
navigate(`/chat/${item.id}`);
}
};
return (
@@ -46,6 +50,8 @@ const ProjectItem: React.FC<ProjectItemProps> = ({ project, isSelected, onSelect
<div className="flex-shrink-0">
{hasRunningSessions ? (
<Loader2 className="h-4 w-4 animate-spin text-blue-600 dark:text-blue-400" />
) : item.type === 'chat' ? (
<MessageSquare className="h-4 w-4 text-accent" />
) : (
<Folder className="h-4 w-4 text-primary" />
)}
@@ -53,7 +59,7 @@ const ProjectItem: React.FC<ProjectItemProps> = ({ project, isSelected, onSelect
<div className="flex justify-between gap-2 flex-1 min-w-0">
<div className="min-w-0 flex-1 flex items-center">
<h3 className="font-medium text-sm truncate">
{project.name}
{item.name}
</h3>
</div>
@@ -72,26 +78,26 @@ const ProjectItem: React.FC<ProjectItemProps> = ({ project, isSelected, onSelect
);
};
ProjectItem.displayName = 'ProjectItem';
ChatItemComponent.displayName = 'ChatItemComponent';
interface ProjectSidebarProps {
selectedProject: Project | null;
onSelectProject: (project: Project | null) => void;
selectedItem: ChatItem | null;
onSelectItem: (item: ChatItem | null) => void;
className?: string;
onToggleSidebar?: () => void;
onClose?: () => void;
}
export function ProjectSidebar({
selectedProject,
onSelectProject,
selectedItem,
onSelectItem,
className,
onToggleSidebar,
onClose
}: ProjectSidebarProps) {
const { t } = useTranslation();
const queryClient = useQueryClient();
const { data: projects = [], isLoading, error } = useProjects();
const { data: items = [], isLoading, error } = useProjects();
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
const isMobile = useIsMobile();
@@ -106,10 +112,15 @@ export function ProjectSidebar({
};
const handleNewProject = () => {
onSelectProject(null);
onSelectItem(null);
navigateAndClose('/');
};
const handleNewChat = () => {
onSelectItem(null);
navigateAndClose('/?mode=chat');
};
const handleToggleSidebar = () => {
if (onToggleSidebar) {
onToggleSidebar();
@@ -166,7 +177,7 @@ export function ProjectSidebar({
<div className="flex-1 overflow-y-auto">
<div className="p-2">
<div className="mb-2">
<div className="mb-2 space-y-2">
<div className="relative rounded-md bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90 transition-all duration-200">
<div className="flex">
<button
@@ -195,6 +206,14 @@ export function ProjectSidebar({
</DropdownMenu>
</div>
</div>
<Button
onClick={handleNewChat}
className="w-full bg-gradient-to-r from-accent to-primary hover:from-accent/90 hover:to-primary/90 transition-all duration-200"
size="sm"
>
<MessageSquare className="h-4 w-4 mr-2" />
{t('newChat')}
</Button>
</div>
{isLoading ? (
@@ -208,7 +227,7 @@ export function ProjectSidebar({
</div>
))}
</div>
) : projects.length === 0 ? (
) : items.length === 0 ? (
<div className="text-center p-6 text-muted-foreground">
<Folder className="h-8 w-8 mx-auto mb-2 opacity-50" />
<p className="text-sm">{t('noProjectsYet')}</p>
@@ -216,13 +235,13 @@ export function ProjectSidebar({
</div>
) : (
<div className="space-y-1">
{projects.map((project) => (
<ProjectItem
key={project.id}
project={project}
isSelected={selectedProject?.id === project.id}
onSelect={onSelectProject}
isFavorite={favorites.includes(project.id)}
{items.map((item) => (
<ChatItemComponent
key={item.id}
item={item}
isSelected={selectedItem?.id === item.id}
onSelect={onSelectItem}
isFavorite={favorites.includes(item.id)}
/>
))}
</div>
+15 -11
View File
@@ -7,7 +7,7 @@ import { Menu, Bot, GitBranch, Database, Wifi, Settings2, Info } from 'lucide-re
import { ProjectSidebar } from '@/components/ProjectSidebar';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useIsMobile } from '@/hooks/useIsMobile';
import { type Project } from '@/lib/ProjectsManager';
import { type ChatItem } from '@/lib/ProjectsManager';
import { useCallback } from 'react';
import { cn } from '@/lib/utils';
@@ -72,14 +72,14 @@ export function SettingsLayout() {
const isMobile = useIsMobile();
const projectsManager = useProjectsManager();
const [_projects, setProjects] = useState<Project[]>([]);
const [_projects, setProjects] = useState<ChatItem[]>([]);
const [isSidebarVisible, setIsSidebarVisible] = useState(!isMobile);
const [hasSetInitialState, setHasSetInitialState] = useState(false);
const loadProjects = useCallback(async () => {
try {
await projectsManager.init();
const projectList = await projectsManager.getProjects();
const projectList = await projectsManager.getAllChatItems();
setProjects(projectList);
// Set initial sidebar state based on projects and device type
@@ -104,10 +104,14 @@ export function SettingsLayout() {
loadProjects();
}, [loadProjects]);
const handleProjectSelect = (project: Project | null) => {
if (project) {
const handleProjectSelect = (item: ChatItem | null) => {
if (item) {
setIsSidebarVisible(false); // Collapse sidebar on mobile navigation
navigate(`/project/${project.id}`);
if (item.type === 'project') {
navigate(`/project/${item.id}`);
} else {
navigate(`/chat/${item.id}`);
}
} else {
navigate('/');
}
@@ -145,10 +149,10 @@ export function SettingsLayout() {
/>
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
<ProjectSidebar
selectedProject={null}
onSelectProject={(project) => {
selectedItem={null}
onSelectItem={(item) => {
setIsSidebarVisible(false);
handleProjectSelect(project);
handleProjectSelect(item);
}}
onClose={() => setIsSidebarVisible(false)}
/>
@@ -168,8 +172,8 @@ export function SettingsLayout() {
{isSidebarVisible && (
<div className="w-80 border-r bg-sidebar flex-shrink-0">
<ProjectSidebar
selectedProject={null}
onSelectProject={handleProjectSelect}
selectedItem={null}
onSelectItem={handleProjectSelect}
className="h-full"
onToggleSidebar={() => setIsSidebarVisible(false)}
/>
+10 -2
View File
@@ -55,6 +55,7 @@ interface ChatPaneProps {
isBuildLoading?: boolean;
consoleError?: ProjectPreviewConsoleError | null;
onDismissConsoleError?: () => void;
isTextChat?: boolean; // Whether this is a text chat (no tools) vs a project chat
}
export interface ChatPaneRef {
@@ -70,6 +71,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
isBuildLoading: externalIsBuildLoading,
consoleError,
onDismissConsoleError,
isTextChat = false,
}, ref) => {
const { t } = useTranslation();
const [searchParams, setSearchParams] = useSearchParams();
@@ -132,8 +134,13 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
}, [projectId, providerModel]);
// Initialize AI chat with tools
const cwd = `/projects/${projectId}`;
const cwd = isTextChat ? `/chats/${projectId}` : `/projects/${projectId}`;
const customTools = useMemo(() => {
// For text chats, return empty tools object
if (isTextChat) {
return {};
}
const baseTools = {
git_commit: new GitCommitTool(fs, cwd, git),
text_editor_view: new TextEditorViewTool(fs, cwd),
@@ -163,7 +170,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
}
return baseTools;
}, [fs, git, cwd, user, projectId]);
}, [fs, git, cwd, user, projectId, isTextChat]);
// Convert tools to OpenAI format
const tools = useMemo(() => {
@@ -215,6 +222,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
customTools,
onUpdateMetadata,
onAIError,
isTextChat,
});
// Handle console error help requests
+5 -3
View File
@@ -13,6 +13,7 @@ interface UseAIChatSessionOptions {
maxSteps?: number;
onUpdateMetadata?: (title: string, description: string) => void;
onAIError?: (error: Error) => void;
isTextChat?: boolean;
}
interface StreamingMessage {
@@ -32,7 +33,8 @@ export function useAIChat({
customTools = {},
maxSteps = 50,
onUpdateMetadata,
onAIError
onAIError,
isTextChat = false
}: UseAIChatSessionOptions) {
const sessionManager = useSessionManager();
const { isConfigured } = useAISettings();
@@ -46,14 +48,14 @@ export function useAIChat({
const initSession = useCallback(async () => {
// Load or update session
const session = await sessionManager.loadSession(projectId, tools, customTools, maxSteps);
const session = await sessionManager.loadSession(projectId, tools, customTools, maxSteps, isTextChat);
// Initialize individual state variables from existing session
setMessages([...session.messages]);
setStreamingMessage(session.streamingMessage ? { ...session.streamingMessage } : undefined);
setIsLoading(session.isLoading);
setTotalCost(session.totalCost || 0);
setLastInputTokens(session.lastInputTokens || 0);
}, [sessionManager, projectId, tools, customTools, maxSteps]);
}, [sessionManager, projectId, tools, customTools, maxSteps, isTextChat]);
// Initialize session
useEffect(() => {
+4 -1
View File
@@ -25,21 +25,24 @@ function createTestWrapper() {
vi.mock('./useProjectsManager', () => ({
useProjectsManager: () => ({
init: vi.fn().mockResolvedValue(undefined),
getProjects: vi.fn().mockResolvedValue([
getAllChatItems: vi.fn().mockResolvedValue([
{
id: 'project-1',
name: 'Project 1',
lastModified: new Date('2023-01-01'),
type: 'project' as const,
},
{
id: 'project-2',
name: 'Project 2',
lastModified: new Date('2023-01-02'),
type: 'project' as const,
},
{
id: 'project-3',
name: 'Project 3',
lastModified: new Date('2023-01-03'),
type: 'project' as const,
},
] as Project[]),
}),
+6 -6
View File
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import type { Project } from '@/lib/ProjectsManager';
import type { ChatItem } from '@/lib/ProjectsManager';
export function useProjects() {
const projectsManager = useProjectsManager();
@@ -9,12 +9,12 @@ export function useProjects() {
return useQuery({
queryKey: ['projects'],
queryFn: async (): Promise<Project[]> => {
queryFn: async (): Promise<ChatItem[]> => {
await projectsManager.init();
const projects = await projectsManager.getProjects();
// Sort projects: favorites first, then by lastModified (newest first)
return projects.sort((a, b) => {
const items = await projectsManager.getAllChatItems();
// Sort items: favorites first, then by lastModified (newest first)
return items.sort((a, b) => {
const aIsFavorite = favorites.includes(a.id);
const bIsFavorite = favorites.includes(b.id);
+2 -2
View File
@@ -8,10 +8,10 @@ export class DotAI {
readonly historyDir: string;
readonly workingDir: string;
constructor(fs: JSRuntimeFS, workingDir: string = "/") {
constructor(fs: JSRuntimeFS, workingDir: string = "/", customHistoryDir?: string) {
this.fs = fs;
this.workingDir = workingDir;
this.historyDir = join(workingDir, ".git", "ai", "history");
this.historyDir = customHistoryDir || join(workingDir, ".git", "ai", "history");
}
/** Generate a unique session name based on the current date and time */
-2
View File
@@ -80,7 +80,6 @@ export class LightningFSAdapter implements JSRuntimeFS {
async stat(path: string): Promise<{
isDirectory(): boolean;
isFile(): boolean;
isSymbolicLink(): boolean;
size?: number;
mtimeMs?: number;
}> {
@@ -90,7 +89,6 @@ export class LightningFSAdapter implements JSRuntimeFS {
async lstat(path: string): Promise<{
isDirectory(): boolean;
isFile(): boolean;
isSymbolicLink(): boolean;
size?: number;
mtimeMs?: number;
}> {
+199
View File
@@ -17,8 +17,19 @@ export interface Project {
name: string;
path: string;
lastModified: Date;
type: 'project';
}
export interface TextChat {
id: string;
name: string;
path: string;
lastModified: Date;
type: 'chat';
}
export type ChatItem = Project | TextChat;
export interface ProjectsManagerOptions {
fs: JSRuntimeFS;
git: Git;
@@ -28,11 +39,13 @@ export class ProjectsManager {
fs: JSRuntimeFS;
git: Git;
dir: string;
chatsDir: string;
constructor(options: ProjectsManagerOptions) {
this.fs = options.fs;
this.git = options.git;
this.dir = '/projects';
this.chatsDir = '/chats';
}
async init() {
@@ -41,6 +54,11 @@ export class ProjectsManager {
} catch {
// Directory might already exist
}
try {
await this.fs.mkdir(this.chatsDir);
} catch {
// Directory might already exist
}
}
async createProject(name: string, customId?: string): Promise<Project> {
@@ -264,6 +282,7 @@ export class ProjectsManager {
name: projectName,
path: projectPath,
lastModified: timestamp,
type: 'project' as const,
};
} catch (error) {
// Clean up on error (only if this was a new project creation)
@@ -317,6 +336,7 @@ export class ProjectsManager {
name: this.formatProjectName(id), // Use formatted directory name
path: projectPath,
lastModified: timestamp,
type: 'project' as const,
};
} catch (error) {
// Clean up the directory that was created if cloning fails
@@ -348,6 +368,7 @@ export class ProjectsManager {
name: this.formatProjectName(dir), // Convert directory name to readable format
path: projectPath,
lastModified: modifiedDate,
type: 'project' as const,
};
projects.push(project);
@@ -375,6 +396,7 @@ export class ProjectsManager {
name: this.formatProjectName(id), // Convert directory name to readable format
path: projectPath,
lastModified: modifiedDate,
type: 'project' as const,
};
}
@@ -508,6 +530,7 @@ export class ProjectsManager {
name: this.formatProjectName(newId),
path: newPath,
lastModified: timestamp,
type: 'project' as const,
};
}
@@ -658,4 +681,180 @@ export class ProjectsManager {
return '/' + normalized.join('/');
}
// Text Chat Methods
async createTextChat(name: string): Promise<TextChat> {
const id = await this.generateUniqueChatId(name);
const chatPath = `${this.chatsDir}/${id}`;
// Create the chat directory
await this.fs.mkdir(chatPath, { recursive: true });
// Create a metadata file
const metadata = {
name,
createdAt: new Date().toISOString(),
};
await this.fs.writeFile(`${chatPath}/metadata.json`, JSON.stringify(metadata, null, 2));
const stats = await this.fs.stat(chatPath);
const timestamp = stats.mtimeMs ? new Date(stats.mtimeMs) : new Date();
return {
id,
name,
path: chatPath,
lastModified: timestamp,
type: 'chat',
};
}
async getTextChats(): Promise<TextChat[]> {
try {
const chatDirs = await this.fs.readdir(this.chatsDir);
const chats: TextChat[] = [];
for (const dir of chatDirs) {
const chatPath = `${this.chatsDir}/${dir}`;
try {
const stats = await this.fs.stat(chatPath);
if (stats.isDirectory()) {
// Try to read metadata
let name = this.formatProjectName(dir);
try {
const metadataContent = await this.fs.readFile(`${chatPath}/metadata.json`, 'utf8');
const metadata = JSON.parse(metadataContent);
name = metadata.name || name;
} catch {
// If metadata doesn't exist, use formatted directory name
}
const modifiedDate = stats.mtimeMs ? new Date(stats.mtimeMs) : new Date();
const chat: TextChat = {
id: dir,
name,
path: chatPath,
lastModified: modifiedDate,
type: 'chat',
};
chats.push(chat);
}
} catch {
// Skip if we can't stat the directory
}
}
return chats.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
} catch {
return [];
}
}
async getTextChat(id: string): Promise<TextChat | null> {
try {
const chatPath = `${this.chatsDir}/${id}`;
const stats = await this.fs.stat(chatPath);
if (stats.isDirectory()) {
// Try to read metadata
let name = this.formatProjectName(id);
try {
const metadataContent = await this.fs.readFile(`${chatPath}/metadata.json`, 'utf8');
const metadata = JSON.parse(metadataContent);
name = metadata.name || name;
} catch {
// If metadata doesn't exist, use formatted directory name
}
const modifiedDate = stats.mtimeMs ? new Date(stats.mtimeMs) : new Date();
return {
id,
name,
path: chatPath,
lastModified: modifiedDate,
type: 'chat',
};
}
return null;
} catch {
return null;
}
}
async deleteTextChat(chatId: string): Promise<void> {
const chatPath = `${this.chatsDir}/${chatId}`;
await this.deleteDirectory(chatPath);
}
async renameTextChat(oldId: string, newName: string): Promise<TextChat> {
const oldChat = await this.getTextChat(oldId);
if (!oldChat) {
throw new Error(`Chat with ID "${oldId}" does not exist`);
}
const chatPath = `${this.chatsDir}/${oldId}`;
// Update metadata with new name
const metadata = {
name: newName,
createdAt: new Date().toISOString(),
};
await this.fs.writeFile(`${chatPath}/metadata.json`, JSON.stringify(metadata, null, 2));
// Use current timestamp for modification time
const timestamp = new Date();
return {
id: oldId,
name: newName,
path: chatPath,
lastModified: timestamp,
type: 'chat',
};
}
async getAllChatItems(): Promise<ChatItem[]> {
const [projects, textChats] = await Promise.all([
this.getProjects(),
this.getTextChats(),
]);
// Add type field to projects
const projectsWithType: Project[] = projects.map(p => ({ ...p, type: 'project' as const }));
// Combine and sort by lastModified
const allItems: ChatItem[] = [...projectsWithType, ...textChats];
return allItems.sort((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
}
private async generateUniqueChatId(name: string): Promise<string> {
const baseSlug = name
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
let slug = baseSlug;
let counter = 1;
while (await this.chatExists(slug)) {
slug = `${baseSlug}-${counter}`;
counter++;
}
return slug;
}
private async chatExists(id: string): Promise<boolean> {
try {
const chatPath = `${this.chatsDir}/${id}`;
await this.fs.stat(chatPath);
return true;
} catch {
return false;
}
}
}
+13 -5
View File
@@ -35,6 +35,7 @@ export interface SessionState {
abortController?: AbortController;
totalCost?: number; // Total cost in USD for this session
lastInputTokens?: number; // Input tokens from the last AI request
isTextChat?: boolean; // Whether this is a text chat (no tools) vs a project chat
}
export interface SessionManagerEvents {
@@ -72,20 +73,23 @@ export class SessionManager {
}
/**
* Create a new session for a project
* Create a new session for a project or text chat
*/
async loadSession(
projectId: string,
tools: Record<string, OpenAI.Chat.Completions.ChatCompletionTool>,
customTools: Record<string, Tool<unknown>>,
maxSteps?: number
maxSteps?: number,
isTextChat?: boolean
): Promise<SessionState> {
let messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [];
let sessionName = DotAI.generateSessionName();
// Try to load existing history
try {
const dotAI = new DotAI(this.fs, `/projects/${projectId}`);
const workingDir = isTextChat ? `/chats/${projectId}` : `/projects/${projectId}`;
const historyDir = isTextChat ? `${workingDir}/history` : undefined;
const dotAI = new DotAI(this.fs, workingDir, historyDir);
const lastSession = await dotAI.readLastSessionHistory();
if (lastSession) {
messages = lastSession.messages;
@@ -104,6 +108,7 @@ export class SessionManager {
lastActivity: new Date(),
totalCost: 0,
lastInputTokens: 0,
isTextChat,
...this.sessions.get(projectId),
messages,
sessionName,
@@ -226,8 +231,9 @@ export class SessionManager {
tool_calls: undefined
};
const cwd = session.isTextChat ? `/chats/${projectId}` : `/projects/${projectId}`;
const systemPrompt = await makeSystemPrompt({
cwd: `/projects/${projectId}`,
cwd,
fs: this.fs,
mode: "agent",
name: "Shakespeare",
@@ -549,7 +555,9 @@ export class SessionManager {
if (!session) return;
try {
const dotAI = new DotAI(this.fs, `/projects/${session.projectId}`);
const workingDir = session.isTextChat ? `/chats/${session.projectId}` : `/projects/${session.projectId}`;
const historyDir = session.isTextChat ? `${workingDir}/history` : undefined;
const dotAI = new DotAI(this.fs, workingDir, historyDir);
await dotAI.setHistory(session.sessionName, session.messages);
} catch (error) {
console.warn('Failed to save session history:', error);
+6
View File
@@ -84,6 +84,7 @@ const resources = {
// Project Sidebar
newProject: 'New Project',
newChat: 'New Chat',
importRepository: 'Import Repository',
noProjectsYet: 'No projects yet',
createFirstProject: 'Create your first project to get started',
@@ -395,6 +396,7 @@ const resources = {
// Project Sidebar
newProject: 'Novo Projeto',
newChat: 'Nova Conversa',
importRepository: 'Importar Repositório',
noProjectsYet: 'Nenhum projeto ainda',
createFirstProject: 'Crie seu primeiro projeto para começar',
@@ -706,6 +708,7 @@ const resources = {
// Project Sidebar
newProject: '新项目',
newChat: '新对话',
importRepository: '导入仓库',
noProjectsYet: '还没有项目',
createFirstProject: '创建您的第一个项目开始使用',
@@ -1017,6 +1020,7 @@ const resources = {
// Project Sidebar
newProject: 'Sabon Aikin',
newChat: 'Sabuwar Hira',
importRepository: 'Shigo da Repository',
noProjectsYet: 'Babu ayyuka har yanzu',
createFirstProject: 'Ƙirƙiri aikin farko don farawa',
@@ -1328,6 +1332,7 @@ const resources = {
// Project Sidebar
newProject: 'Iṣẹ akanṣe Tuntun',
newChat: 'Ibaraẹnisọrọ Tuntun',
importRepository: 'Gbe Repository wọle',
noProjectsYet: 'Ko si awọn iṣẹ akanṣe sibẹsibẹ',
createFirstProject: 'Ṣẹda iṣẹ akanṣe akọkọ rẹ lati bẹrẹ',
@@ -1634,6 +1639,7 @@ const resources = {
// Project Sidebar
newProject: 'Ọrụ Ọhụrụ',
newChat: 'Mkparịta Ụka Ọhụrụ',
importRepository: 'Bubata Repository',
noProjectsYet: 'Enwebeghị ọrụ ọ bụla',
createFirstProject: 'Mepụta ọrụ mbụ gị iji malite',
+1 -7
View File
@@ -12,10 +12,4 @@ import './index.css';
// Using Inter Variable font for modern, clean typography
import '@fontsource-variable/inter';
// Initialize Capacitor for mobile platforms
import { initializeCapacitor } from './capacitor';
// Initialize Capacitor before rendering the app
initializeCapacitor().then(() => {
createRoot(document.getElementById("root")!).render(<App />);
});
createRoot(document.getElementById("root")!).render(<App />);
+21 -24
View File
@@ -1,4 +1,3 @@
import { Capacitor } from '@capacitor/core';
import { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
@@ -338,29 +337,27 @@ export function DataSettings() {
)}
{/* Persist Data */}
{!Capacitor.isNativePlatform() && (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Shield className="h-5 w-5" />
{t('persistData')}
</CardTitle>
<CardDescription>
{t('persistDataDescription')}
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex items-center justify-start">
<Switch
id="persistent-storage"
checked={isPersistent === true}
onCheckedChange={handlePersistentStorageToggle}
disabled={isRequestingPersistent || isPersistent === null}
/>
</div>
</CardContent>
</Card>
)}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Shield className="h-5 w-5" />
{t('persistData')}
</CardTitle>
<CardDescription>
{t('persistDataDescription')}
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex items-center justify-start">
<Switch
id="persistent-storage"
checked={isPersistent === true}
onCheckedChange={handlePersistentStorageToggle}
disabled={isRequestingPersistent || isPersistent === null}
/>
</div>
</CardContent>
</Card>
{/* Export Files */}
<Card>
+71 -4
View File
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useAIProjectId } from '@/hooks/useAIProjectId';
@@ -25,6 +25,8 @@ import { ShakespeareLogo } from '@/components/ShakespeareLogo';
export default function Index() {
const { t } = useTranslation();
const [searchParams] = useSearchParams();
const mode = searchParams.get('mode'); // 'chat' for text chat, null for project
const [prompt, setPrompt] = useState('');
const [isCreating, setIsCreating] = useState(false);
const [storedPrompt, setStoredPrompt] = useLocalStorage('shakespeare-draft-prompt', '');
@@ -184,11 +186,76 @@ export default function Index() {
const handleCreateProject = async () => {
if (!prompt.trim() || !providerModel.trim()) return;
// Clear stored prompt when creating project
// Clear stored prompt when creating project/chat
setStoredPrompt('');
setIsCreating(true);
try {
// For text chat mode, create a text chat instead of a project
if (mode === 'chat') {
// Create text chat
const chat = await projectsManager.createTextChat(prompt.trim());
// Build message content as text parts
const contentParts: Array<OpenAI.Chat.Completions.ChatCompletionContentPartText> = [];
// Add user input as text part if present
if (prompt.trim()) {
contentParts.push({
type: 'text',
text: prompt.trim()
});
}
// Process attached files and add as separate text parts
if (attachedFiles.length > 0) {
const filePromises = attachedFiles.map(async (file) => {
try {
const savedPath = await saveFileToTmp(fs, file);
return `Added file: ${savedPath}`;
} catch (error) {
console.error('Failed to save file:', error);
return `Failed to save file: ${file.name}`;
}
});
const fileResults = await Promise.all(filePromises);
// Add each file as a separate text part
fileResults.forEach(fileResult => {
contentParts.push({
type: 'text',
text: fileResult
});
});
}
// Store the initial message in chat history using DotAI
const dotAI = new DotAI(fs, chat.path);
const sessionName = DotAI.generateSessionName();
// Create initial message with content parts
const initialMessage: AIMessage = {
role: 'user',
content: contentParts.length === 1 ? contentParts[0].text : contentParts
};
await dotAI.setHistory(sessionName, [initialMessage]);
// Add model to recently used
addRecentlyUsedModel(providerModel.trim());
// Clear attached files after successful creation
setAttachedFiles([]);
// Navigate to the chat with autostart parameter and model
const searchParams = new URLSearchParams({
autostart: 'true',
...(providerModel.trim() && { model: providerModel.trim() })
});
navigate(`/chat/${chat.id}?${searchParams.toString()}`);
return;
}
// Use AI to generate project ID
const projectId = await generateProjectId(providerModel, prompt.trim());
@@ -272,10 +339,10 @@ export default function Index() {
<ShakespeareLogo className="w-20 h-20 md:w-24 md:h-24 mx-auto" />
</div>
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
{t('buildNostrApps')}
{mode === 'chat' ? 'Start a new chat' : t('buildNostrApps')}
</h1>
<p className="text-lg md:text-xl text-muted-foreground">
{t('whatToBuild')}
{mode === 'chat' ? 'What would you like to talk about?' : t('whatToBuild')}
</p>
</div>
+19 -11
View File
@@ -193,13 +193,17 @@ export function ProjectView() {
{/* Sidebar - positioned above the backdrop */}
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
<ProjectSidebar
selectedProject={project}
onSelectProject={(selectedProject) => {
setProject(selectedProject);
selectedItem={project}
onSelectItem={(selectedItem) => {
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
if (selectedProject) {
setMobileView('chat'); // Switch to chat view when selecting a project
navigate(`/project/${selectedProject.id}`);
if (selectedItem) {
if (selectedItem.type === 'project') {
setProject(selectedItem);
setMobileView('chat'); // Switch to chat view when selecting a project
navigate(`/project/${selectedItem.id}`);
} else {
navigate(`/chat/${selectedItem.id}`);
}
} else {
navigate('/');
}
@@ -308,11 +312,15 @@ export function ProjectView() {
{/* Fixed Sidebar */}
<div className={`w-80 border-r bg-sidebar duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
<ProjectSidebar
selectedProject={project}
onSelectProject={(selectedProject) => {
setProject(selectedProject);
if (selectedProject) {
navigate(`/project/${selectedProject.id}`);
selectedItem={project}
onSelectItem={(selectedItem) => {
if (selectedItem) {
if (selectedItem.type === 'project') {
setProject(selectedItem);
navigate(`/project/${selectedItem.id}`);
} else {
navigate(`/chat/${selectedItem.id}`);
}
} else {
navigate('/');
}
+224
View File
@@ -0,0 +1,224 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { useParams } from 'react-router-dom';
import type { TextChat } from '@/lib/ProjectsManager';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { ChatPane, type ChatPaneRef } from '@/components/Shakespeare/ChatPane';
import { ProjectSidebar } from '@/components/ProjectSidebar';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { ArrowLeft, Menu } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
import { useIsMobile } from '@/hooks/useIsMobile';
export function TextChatView() {
const { chatId } = useParams<{ chatId: string }>();
const [chat, setChat] = useState<TextChat | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [isAILoading, setIsAILoading] = useState(false);
const projectsManager = useProjectsManager();
const chatPaneRef = useRef<ChatPaneRef>(null);
const navigate = useNavigate();
const isMobile = useIsMobile();
const [isSidebarVisible, setIsSidebarVisible] = useState(!isMobile);
const loadChat = useCallback(async () => {
if (!chatId) return;
try {
const chatData = await projectsManager.getTextChat(chatId);
setChat(chatData);
} catch (error) {
console.error('Failed to load chat:', error);
} finally {
setIsLoading(false);
}
}, [chatId, projectsManager]);
useEffect(() => {
loadChat();
}, [loadChat]);
const handleNewChat = () => {
if (chatPaneRef.current) {
chatPaneRef.current.startNewSession();
}
};
const handleAILoadingChange = (loading: boolean) => {
setIsAILoading(loading);
};
if (!chat && !isLoading) {
return (
<div className="min-h-screen bg-background flex items-center justify-center">
<div className="text-center">
<h1 className="text-2xl font-bold mb-2">Chat Not Found</h1>
<Button onClick={() => navigate('/')} variant="outline">
<ArrowLeft className="mr-2 h-4 w-4" />
Back to Home
</Button>
</div>
</div>
);
}
if (isMobile) {
return (
<div className="h-dvh flex flex-col bg-background">
<header className="pt-safe bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 backdrop-blur">
<div className="h-12 border-b px-4 py-3 flex items-center justify-between">
<div className="flex items-center space-x-2 overflow-hidden">
<Button
variant="ghost"
size="sm"
onClick={() => setIsSidebarVisible(!isSidebarVisible)}
>
<Menu className="h-4 w-4" />
</Button>
<div className="flex min-w-0 flex-1">
{chat ? (
<h1 className="text-sm font-semibold truncate">
{chat.name}
</h1>
) : (
<Skeleton className="h-5 w-32" />
)}
</div>
</div>
</div>
</header>
{/* Mobile Sidebar Overlay */}
{isSidebarVisible && (
<div className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm">
<div
className="absolute inset-0"
onClick={() => setIsSidebarVisible(false)}
/>
<div className="relative left-0 top-0 h-full w-80 max-w-[80vw] bg-background border-r shadow-lg z-10">
<ProjectSidebar
selectedItem={chat}
onSelectItem={(selectedItem) => {
setIsSidebarVisible(false);
if (selectedItem) {
if (selectedItem.type === 'project') {
navigate(`/project/${selectedItem.id}`);
} else {
navigate(`/chat/${selectedItem.id}`);
}
} else {
navigate('/');
}
}}
onClose={() => setIsSidebarVisible(false)}
/>
</div>
</div>
)}
<div className="flex-1 overflow-hidden">
{chat ? (
<ChatPane
ref={chatPaneRef}
projectId={chat.id}
onNewChat={handleNewChat}
onLoadingChange={handleAILoadingChange}
isLoading={isAILoading}
isTextChat={true}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-12 w-full" />
<Skeleton className="h-8 w-3/4" />
<Skeleton className="h-8 w-1/2" />
<Skeleton className="h-32 w-full" />
</div>
)}
</div>
</div>
);
}
return (
<div className="h-screen flex bg-background">
{/* Fixed Sidebar */}
<div className={`w-80 border-r bg-sidebar duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
<ProjectSidebar
selectedItem={chat}
onSelectItem={(selectedItem) => {
if (selectedItem) {
if (selectedItem.type === 'project') {
navigate(`/project/${selectedItem.id}`);
} else {
navigate(`/chat/${selectedItem.id}`);
}
} else {
navigate('/');
}
}}
onToggleSidebar={() => setIsSidebarVisible(!isSidebarVisible)}
className="h-full"
/>
</div>
{/* Main Content Area */}
<div className="flex-1 flex flex-col overflow-hidden bg-background">
<div className="flex-1 overflow-hidden">
<div className="h-full flex flex-col">
{/* Chat Header */}
<div className="h-12 px-4 border-b flex-shrink-0">
<div className="flex items-center justify-between h-12">
<div className="flex items-center gap-3 overflow-hidden">
{!isSidebarVisible && (
<Button
variant="ghost"
size="sm"
onClick={() => setIsSidebarVisible(true)}
className="h-8 w-8 p-0"
aria-label="Open sidebar"
>
<Menu className="h-4 w-4" />
</Button>
)}
<div className="flex flex-1 min-w-0 truncate">
{chat ? (
<h1 className="font-semibold text-lg truncate">
{chat.name}
</h1>
) : (
<Skeleton className="h-6 w-40" />
)}
</div>
</div>
</div>
</div>
{/* Chat Content */}
<div className="flex-1 overflow-hidden">
{chat ? (
<ChatPane
ref={chatPaneRef}
projectId={chat.id}
onNewChat={handleNewChat}
onLoadingChange={handleAILoadingChange}
isLoading={isAILoading}
isTextChat={true}
/>
) : (
<div className="h-full p-4 space-y-4">
<Skeleton className="h-12 w-full" />
<Skeleton className="h-8 w-3/4" />
<Skeleton className="h-8 w-1/2" />
<Skeleton className="h-32 w-full" />
</div>
)}
</div>
</div>
</div>
</div>
</div>
);
}