generated from nhcarrigan/template
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
0903033180
|
|||
|
ef7f74a919
|
|||
|
42b4958c2a
|
|||
| 662d6119fa |
+1
-1
@@ -22,7 +22,7 @@
|
||||
"@nhcarrigan/typescript-config": "4.0.0",
|
||||
"@tauri-apps/cli": "2.5.0",
|
||||
"@types/react": "19.1.2",
|
||||
"@types/react-dom": "19.2.3",
|
||||
"@types/react-dom": "19.1.2",
|
||||
"autoprefixer": "10.4.21",
|
||||
"eslint": "9.25.1",
|
||||
"postcss": "8.5.3",
|
||||
|
||||
Generated
+6
-6
@@ -37,8 +37,8 @@ importers:
|
||||
specifier: 19.1.2
|
||||
version: 19.1.2
|
||||
'@types/react-dom':
|
||||
specifier: 19.2.3
|
||||
version: 19.2.3(@types/react@19.1.2)
|
||||
specifier: 19.1.2
|
||||
version: 19.1.2(@types/react@19.1.2)
|
||||
'@vitejs/plugin-react':
|
||||
specifier: 4.4.1
|
||||
version: 4.4.1(vite@6.3.2(jiti@1.21.7)(yaml@2.8.3))
|
||||
@@ -685,10 +685,10 @@ packages:
|
||||
'@types/normalize-package-data@2.4.4':
|
||||
resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==}
|
||||
|
||||
'@types/react-dom@19.2.3':
|
||||
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
|
||||
'@types/react-dom@19.1.2':
|
||||
resolution: {integrity: sha512-XGJkWF41Qq305SKWEILa1O8vzhb3aOo3ogBlSmiqNko/WmRb6QIaweuZCXjKygVDXpzXb5wyxKTSOsmkuqj+Qw==}
|
||||
peerDependencies:
|
||||
'@types/react': ^19.2.0
|
||||
'@types/react': ^19.0.0
|
||||
|
||||
'@types/react@19.1.2':
|
||||
resolution: {integrity: sha512-oxLPMytKchWGbnQM9O7D67uPa9paTNxO7jVoNMXgkkErULBPhPARCfkKL9ytcIJJRGjbsVwW4ugJzyFFvm/Tiw==}
|
||||
@@ -2940,7 +2940,7 @@ snapshots:
|
||||
|
||||
'@types/normalize-package-data@2.4.4': {}
|
||||
|
||||
'@types/react-dom@19.2.3(@types/react@19.1.2)':
|
||||
'@types/react-dom@19.1.2(@types/react@19.1.2)':
|
||||
dependencies:
|
||||
'@types/react': 19.1.2
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 364 KiB |
+14
-10
@@ -83,22 +83,26 @@ fn build_user_gemini_parts(
|
||||
user_image_base64: &Option<String>,
|
||||
user_image_mime: &Option<String>,
|
||||
) -> Vec<Value> {
|
||||
if mode == "replace" && user_image_base64.is_some() {
|
||||
if let Some(image_data) = user_image_base64.as_deref() {
|
||||
let mime = user_image_mime.as_deref().unwrap_or("image/png");
|
||||
let data = user_image_base64.as_deref().unwrap_or("");
|
||||
let base_text = user_text.as_deref().unwrap_or("");
|
||||
let final_text = if base_text.is_empty() {
|
||||
REPLACE_MODE_APPEND.to_string()
|
||||
let final_text = if mode == "replace" {
|
||||
if base_text.is_empty() {
|
||||
REPLACE_MODE_APPEND.to_string()
|
||||
} else {
|
||||
format!("{}\n{}", base_text, REPLACE_MODE_APPEND)
|
||||
}
|
||||
} else {
|
||||
format!("{}\n{}", base_text, REPLACE_MODE_APPEND)
|
||||
base_text.to_string()
|
||||
};
|
||||
|
||||
vec![
|
||||
json!({"inlineData": {"mimeType": mime, "data": data}}),
|
||||
json!({"text": final_text}),
|
||||
]
|
||||
let mut parts = vec![json!({"inlineData": {"mimeType": mime, "data": image_data}})];
|
||||
if !final_text.is_empty() {
|
||||
parts.push(json!({"text": final_text}));
|
||||
}
|
||||
parts
|
||||
} else {
|
||||
// Art/avatar mode, or replace mode follow-up correction (text only)
|
||||
// No image: text-only message
|
||||
let text = user_text.as_deref().unwrap_or("");
|
||||
vec![json!({"text": text})]
|
||||
}
|
||||
|
||||
@@ -256,7 +256,8 @@ const inputArea = ({
|
||||
if (isInitialReplace && imageBase64 === undefined) {
|
||||
return;
|
||||
}
|
||||
if (!isInitialReplace && text.trim().length === 0) {
|
||||
const hasContent = text.trim().length > 0 || imageBase64 !== undefined;
|
||||
if (!isInitialReplace && !hasContent) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -332,6 +333,9 @@ const inputArea = ({
|
||||
: dropZoneInactiveClass,
|
||||
].join(" ");
|
||||
|
||||
const hasNoContent = text.trim().length === 0 && imageBase64 === undefined;
|
||||
const isSendDisabled = isLoading || hasNoContent;
|
||||
|
||||
return (
|
||||
<div className="border-t border-purple-900/30 p-4 bg-[#0f0a1a]">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
@@ -397,6 +401,15 @@ const inputArea = ({
|
||||
type="file"
|
||||
/>
|
||||
|
||||
<textarea
|
||||
className={textareaClass}
|
||||
disabled={isLoading}
|
||||
onChange={handleTextChange}
|
||||
placeholder="Add notes to include with the image (optional)..."
|
||||
rows={2}
|
||||
value={text}
|
||||
/>
|
||||
|
||||
<button
|
||||
className={replaceButtonClass}
|
||||
disabled={isLoading || imageBase64 === undefined}
|
||||
@@ -414,41 +427,40 @@ const inputArea = ({
|
||||
</div>
|
||||
|
||||
: <div className="flex flex-col gap-3">
|
||||
{mode === "replace"
|
||||
? <div className="flex flex-col gap-2">
|
||||
{imagePreview === undefined
|
||||
? <button
|
||||
className={pasteButtonClass}
|
||||
onClick={handlePasteButtonClick}
|
||||
<div className="flex flex-col gap-2">
|
||||
{imagePreview === undefined
|
||||
? <button
|
||||
className={pasteButtonClass}
|
||||
onClick={handlePasteButtonClick}
|
||||
type="button"
|
||||
>
|
||||
{mode === "replace"
|
||||
? "๐ Paste replacement image (optional)"
|
||||
: "๐ Paste image (optional)"}
|
||||
</button>
|
||||
|
||||
: <div className="relative inline-block">
|
||||
<img
|
||||
alt="Upload preview"
|
||||
className="max-h-32 rounded-lg border border-purple-700/40"
|
||||
src={imagePreview}
|
||||
/>
|
||||
<button
|
||||
className={clearButtonClass}
|
||||
onClick={clearImage}
|
||||
type="button"
|
||||
>
|
||||
{"๐ Paste replacement image (optional)"}
|
||||
{"ร"}
|
||||
</button>
|
||||
|
||||
: <div className="relative inline-block">
|
||||
<img
|
||||
alt="Upload preview"
|
||||
className="max-h-32 rounded-lg border border-purple-700/40"
|
||||
src={imagePreview}
|
||||
/>
|
||||
<button
|
||||
className={clearButtonClass}
|
||||
onClick={clearImage}
|
||||
type="button"
|
||||
>
|
||||
{"ร"}
|
||||
</button>
|
||||
</div>}
|
||||
<input
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
onChange={handleFileChange}
|
||||
ref={fileInputReference}
|
||||
type="file"
|
||||
/>
|
||||
</div>
|
||||
|
||||
: null}
|
||||
</div>}
|
||||
<input
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
onChange={handleFileChange}
|
||||
ref={fileInputReference}
|
||||
type="file"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-3 items-end">
|
||||
<textarea
|
||||
@@ -464,7 +476,7 @@ const inputArea = ({
|
||||
/>
|
||||
<button
|
||||
className={sendButtonClass}
|
||||
disabled={isLoading || text.trim().length === 0}
|
||||
disabled={isSendDisabled}
|
||||
onClick={handleSend}
|
||||
type="button"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user