Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
npm ci --ignore-scripts
npx playwright install --with-deps chromium webkit

- name: Real touch taps preserve terminal input and focus
- name: Touch key bar and upload status message in real browsers
working-directory: tests/browser
run: npm test

Expand Down
9 changes: 9 additions & 0 deletions claude-terminal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.5.11

### πŸ› οΈ Improvement - Upload Message Fades
- **The header no longer keeps the full path of the last upload**: after a paste, drop or πŸ“Ž upload, the panel typed the path at the prompt and also showed it in the header until something else replaced it. The path is already at the prompt, and on a phone the message took up half the header
- When the path is typed at the prompt, the header now shows `πŸ“‹ Inserted <file name>` for 5 seconds, like other messages
- Only when the path couldn't be typed at the prompt does the full path stay, and a tap copies it
- **Fixed: tapping the header could copy an old path**: the tap-to-copy action stayed after a later message replaced the upload message. It now goes with the message, and an earlier message's 5-second timer can no longer clear a newer one
- New browser test (Chromium and WebKit) covering both cases

## 2.5.10

### πŸ“š Documentation - Running More Than One Claude
Expand Down
2 changes: 1 addition & 1 deletion claude-terminal/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "Claude Terminal Pro"
description: "Enhanced terminal interface for Anthropic's Claude Code CLI with persistent auth, package management, and image paste support. Fork of heytcass/home-assistant-addons"
version: "2.5.10"
version: "2.5.11"
slug: "claude_terminal_pro"
init: false

Expand Down
109 changes: 35 additions & 74 deletions claude-terminal/image-service/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,42 @@
const fileInput = document.getElementById('file-input');
const dropZone = document.getElementById('drop-zone');

let statusTimer = null;

// A message fades after 5 s unless persistent. Each message replaces
// the last one completely: its fade timer and any tap-to-copy
// handler go too, so an old timer can't clear a newer message and a
// tap never copies a path that is no longer shown.
function setStatus(message, type = '', persistent = false) {
clearTimeout(statusTimer);
status.textContent = message;
status.className = type;
status.onclick = null;
status.style.cursor = '';
status.style.userSelect = '';
if (message && !persistent) {
setTimeout(() => setStatus(''), 5000);
statusTimer = setTimeout(() => setStatus(''), 5000);
}
}

// Only when a path could not be typed at the prompt: it stays until
// replaced, and a tap copies it, so it can still be pasted.
function showCopyablePath(filePath) {
setStatus(`πŸ“‹ ${filePath} (tap to copy)`, 'success', true);
status.style.cursor = 'pointer';
status.style.userSelect = 'text';
status.onclick = async () => {
if (await copyToClipboard(filePath)) {
setStatus('βœ“ Copied', 'success', true);
statusTimer = setTimeout(() => showCopyablePath(filePath), 2000);
} else {
// Left selectable, so it can be copied by hand
setStatus(`πŸ“‹ ${filePath} (select and copy)`, 'error', true);
status.style.userSelect = 'text';
}
};
}

// Files on the clipboard. A copied image, or files copied in Finder or
// Explorer (Safari and recent Chrome/Edge). Text pastes return none.
function pastedFiles(e) {
Expand Down Expand Up @@ -1246,77 +1274,9 @@
const result = await response.json();

if (result.success) {
const filePath = result.path;

// Display full path persistently with click-to-copy functionality
setStatus(`πŸ“‹ ${filePath} (click to select)`, 'success', true);
console.log('File uploaded:', filePath);

// Make status clickable to select text (works in iframes)
status.style.cursor = 'pointer';
status.style.userSelect = 'text';

status.onclick = () => {
// Try modern clipboard API first
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(filePath)
.then(() => {
const originalText = status.textContent;
setStatus('βœ“ Copied!', 'success', false);
setTimeout(() => {
setStatus(originalText, 'success', true);
}, 2000);
})
.catch(() => {
selectText();
});
} else {
// Fallback: select the text so user can copy with Cmd+C
selectText();
}
};

// Insert the path at the terminal prompt
autoCopyAndPaste(filePath);

// Helper to select text (works in all contexts)
function selectText() {
const range = document.createRange();
const selection = window.getSelection();

// Clear any existing selection
selection.removeAllRanges();

// Create a temporary text node with just the path
const tempDiv = document.createElement('div');
tempDiv.style.position = 'absolute';
tempDiv.style.left = '-9999px';
tempDiv.textContent = result.path;
document.body.appendChild(tempDiv);

// Select the path text
range.selectNodeContents(tempDiv);
selection.addRange(range);

// Try execCommand as fallback for copying
try {
const copied = document.execCommand('copy');
if (copied) {
setStatus('βœ“ Copied! (Cmd+C)', 'success', false);
} else {
setStatus('βœ“ Selected! Press Cmd+C to copy', 'success', false);
}
} catch (err) {
setStatus('βœ“ Selected! Press Cmd+C to copy', 'success', false);
}

// Clean up and restore message
setTimeout(() => {
document.body.removeChild(tempDiv);
selection.removeAllRanges();
setStatus(`πŸ“‹ ${result.path} (click to select)`, 'success', true);
}, 3000);
}
console.log('File uploaded:', result.path);
// Type the path at the prompt
autoCopyAndPaste(result.path);
} else {
setStatus(result.error || 'Upload failed', 'error');
}
Expand Down Expand Up @@ -1397,13 +1357,14 @@
if (term && typeof term.paste === 'function') {
term.paste(filePath + ' ');
term.focus();
setStatus(`πŸ“‹ ${filePath} - inserted at prompt`, 'success', true);
// The prompt shows the full path, so the name is enough
setStatus(`πŸ“‹ Inserted ${filePath.split('/').pop()}`, 'success');
return;
}
} catch (err) {
console.log('Cannot reach terminal for auto-insert:', err);
}
setStatus(`πŸ“‹ ${filePath} (click to copy)`, 'success', true);
showCopyablePath(filePath);
}

// Helper to copy text to clipboard
Expand Down
2 changes: 1 addition & 1 deletion tests/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "claude-terminal-browser-tests",
"private": true,
"scripts": {
"test": "node test-key-bar.mjs"
"test": "node test-key-bar.mjs && node test-upload-status.mjs"
},
"devDependencies": {
"playwright": "1.64.1"
Expand Down
108 changes: 108 additions & 0 deletions tests/browser/test-upload-status.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// The header message after an upload: a short note that fades when the path
// was typed at the prompt, and a tap-to-copy path that stays only when it
// could not be. Runs the real panel page against a fake terminal and upload.
import assert from 'node:assert/strict';
import http from 'node:http';
import path from 'node:path';
import { readFile } from 'node:fs/promises';
import { chromium, webkit } from 'playwright';

const publicDir = new URL('../../claude-terminal/image-service/public/', import.meta.url);
const types = { '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript' };
// ?paste=0 gives a terminal without term.paste, so the path can't be inserted
const terminal = (canPaste) => `<!doctype html><script>
window.pasted = [];
window.term = { focus() {}, ${canPaste ? 'paste(text) { pasted.push(text); },' : ''}
textarea: null, parser: { registerOscHandler() {} }, attachCustomKeyEventHandler() {} };
</script>`;
let canPaste = true;

const server = http.createServer(async (req, res) => {
const url = new URL(req.url, 'http://x');
if (url.pathname === '/upload') {
req.resume();
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({ success: true, path: '/data/uploads/20261126-003753-pasted.png' }));
} else if (url.pathname === '/config') {
res.setHeader('Content-Type', 'application/json');
res.end('{"ttydPort":7681,"uploadDir":"/data/uploads"}');
} else if (url.pathname.startsWith('/terminal')) {
res.setHeader('Content-Type', 'text/html');
res.end(terminal(canPaste));
} else {
const file = url.pathname === '/' ? 'index.html' : url.pathname.slice(1);
try {
const body = await readFile(new URL(file, publicDir));
res.setHeader('Content-Type', types[path.extname(file)] || 'application/octet-stream');
res.end(body);
} catch {
res.statusCode = 404;
res.end('{}');
}
}
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
const base = `http://127.0.0.1:${server.address().port}/`;

async function openPanel(browser) {
const page = await browser.newPage();
await page.clock.install();
await page.goto(base);
await page.waitForFunction(() => document.getElementById('terminal-frame').contentWindow.term);
return page;
}

async function upload(page) {
await page.setInputFiles('#file-input', { name: 'pasted.png', mimeType: 'image/png', buffer: Buffer.from('png') });
}

const statusText = (page) => page.locator('#status').textContent();

try {
for (const engine of [chromium, webkit]) {
const browser = await engine.launch();
const name = engine.name();
try {
// Inserted: a short note with the file name, which fades
canPaste = true;
let page = await openPanel(browser);
await upload(page);
await page.waitForFunction(() => document.getElementById('status').textContent.includes('Inserted'));
assert.equal(await statusText(page), 'πŸ“‹ Inserted 20261126-003753-pasted.png', `${name}: inserted note`);
const frame = page.frames().find(f => f.url().includes('/terminal'));
assert.deepEqual(await frame.evaluate(() => window.pasted), ['/data/uploads/20261126-003753-pasted.png '],
`${name}: path typed at the prompt once`);
assert.equal(await page.evaluate(() => document.getElementById('status').onclick), null,
`${name}: the inserted note is not tap-to-copy`);
await page.clock.runFor(5100);
assert.equal(await statusText(page), '', `${name}: the inserted note fades`);
await page.close();

// Not inserted: the full path stays and a tap copies it
canPaste = false;
page = await openPanel(browser);
await upload(page);
await page.waitForFunction(() => document.getElementById('status').textContent.includes('tap to copy'));
assert.equal(await statusText(page), 'πŸ“‹ /data/uploads/20261126-003753-pasted.png (tap to copy)',
`${name}: copyable path`);
await page.clock.runFor(60000);
assert.match(await statusText(page), /tap to copy/, `${name}: the copyable path stays`);
assert.equal(await page.evaluate(() => typeof document.getElementById('status').onclick), 'function',
`${name}: the path is tap-to-copy`);

// A later message replaces it completely: no tap handler left
// behind, and the old path's restore can't overwrite it
await page.evaluate(() => setStatus('πŸ“₯ Pasted into the terminal', 'success'));
assert.equal(await page.evaluate(() => document.getElementById('status').onclick), null,
`${name}: a later message drops the old tap-to-copy handler`);
await page.clock.runFor(5100);
assert.equal(await statusText(page), '', `${name}: the later message fades as usual`);
await page.close();
console.log(`PASS ${name}: upload note fades, copyable path only when not inserted, no stale tap handler`);
} finally {
await browser.close();
}
}
} finally {
await new Promise(resolve => server.close(resolve));
}
Loading