Compare commits

...

14 Commits

Author SHA1 Message Date
b588f113e3 fix bug
Some checks failed
backend / cross (arm) (push) Failing after 31s
backend / cross (i686) (push) Failing after 1m31s
backend / cross (mips) (push) Failing after 6m31s
backend / cross (mips64) (push) Failing after 2m48s
backend / cross (mipsel) (push) Failing after 36m43s
backend / cross (win32) (push) Failing after 16m35s
docker / build (push) Failing after 2m37s
backend / cross (aarch64) (push) Failing after 3m20s
backend / cross (armhf) (push) Failing after 31s
backend / cross (mips64el) (push) Failing after 6m37s
backend / cross (s390x) (push) Failing after 38m17s
backend / cross (x86_64) (push) Failing after 6m31s
2025-10-30 22:26:10 +08:00
a9c827fa4c fix bug
Some checks failed
backend / cross (i686) (push) Failing after 17m35s
backend / cross (win32) (push) Failing after 4m40s
backend / cross (mips) (push) Failing after 14m39s
backend / cross (x86_64) (push) Failing after 19m22s
backend / cross (mips64) (push) Failing after 6m38s
docker / build (push) Failing after 15m6s
backend / cross (aarch64) (push) Failing after 16m29s
backend / cross (mips64el) (push) Failing after 14m16s
backend / cross (arm) (push) Failing after 6m33s
backend / cross (mipsel) (push) Failing after 9m27s
backend / cross (armhf) (push) Failing after 13m14s
backend / cross (s390x) (push) Failing after 1m32s
2025-10-29 23:09:03 +08:00
e4f2c5a844 fix bug
Some checks failed
backend / cross (arm) (push) Failing after 18m24s
backend / cross (win32) (push) Failing after 33s
backend / cross (armhf) (push) Failing after 11s
docker / build (push) Failing after 12m11s
backend / cross (x86_64) (push) Failing after 13m41s
backend / cross (i686) (push) Failing after 1m32s
backend / cross (mips) (push) Failing after 31s
backend / cross (mips64) (push) Failing after 1m38s
backend / cross (mips64el) (push) Failing after 31s
backend / cross (mipsel) (push) Failing after 33s
backend / cross (aarch64) (push) Failing after 17m0s
backend / cross (s390x) (push) Failing after 31s
2025-10-29 11:39:54 +08:00
0675ce138f fix bug 2025-10-29 11:36:50 +08:00
66c0fe3ad0 fix bug
Some checks failed
backend / cross (mips64) (push) Failing after 21m30s
backend / cross (mips64el) (push) Failing after 10s
backend / cross (arm) (push) Failing after 1m33s
backend / cross (mipsel) (push) Failing after 31s
backend / cross (s390x) (push) Failing after 32s
backend / cross (armhf) (push) Failing after 1m33s
backend / cross (win32) (push) Failing after 31s
backend / cross (x86_64) (push) Failing after 31s
docker / build (push) Failing after 36s
backend / cross (i686) (push) Failing after 31s
backend / cross (aarch64) (push) Failing after 13m18s
backend / cross (mips) (push) Failing after 22m12s
2025-10-29 08:41:29 +08:00
e0fbf4f434 fix bug
Some checks failed
backend / cross (armhf) (push) Has been cancelled
docker / build (push) Has been cancelled
backend / cross (aarch64) (push) Failing after 1m31s
backend / cross (arm) (push) Failing after 1m34s
backend / cross (mips64) (push) Has been cancelled
backend / cross (mips64el) (push) Has been cancelled
backend / cross (mipsel) (push) Has been cancelled
backend / cross (s390x) (push) Has been cancelled
backend / cross (win32) (push) Has been cancelled
backend / cross (x86_64) (push) Has been cancelled
backend / cross (i686) (push) Has been cancelled
backend / cross (mips) (push) Has been cancelled
2025-10-29 08:32:18 +08:00
22b99c3562 fix bug
Some checks failed
backend / cross (win32) (push) Failing after 14m55s
backend / cross (aarch64) (push) Failing after 9m39s
backend / cross (arm) (push) Failing after 11s
backend / cross (mips64el) (push) Failing after 31s
backend / cross (armhf) (push) Failing after 1m32s
backend / cross (i686) (push) Failing after 32s
backend / cross (mips) (push) Failing after 11s
backend / cross (mips64) (push) Failing after 30s
backend / cross (mipsel) (push) Failing after 32s
backend / cross (s390x) (push) Failing after 34s
backend / cross (x86_64) (push) Failing after 7m4s
docker / build (push) Failing after 56s
2025-10-28 22:03:51 +08:00
a03c1a8ee4 fix bug
Some checks failed
docker / build (push) Failing after 10m58s
2025-10-28 18:09:33 +08:00
2bf050cff9 fix bug
Some checks failed
backend / cross (arm) (push) Failing after 31s
backend / cross (armhf) (push) Failing after 31s
backend / cross (i686) (push) Failing after 31s
backend / cross (mips64el) (push) Failing after 11s
backend / cross (aarch64) (push) Failing after 3m14s
backend / cross (mips) (push) Failing after 31s
backend / cross (mips64) (push) Failing after 31s
backend / cross (s390x) (push) Failing after 13m3s
backend / cross (win32) (push) Failing after 1m31s
backend / cross (x86_64) (push) Failing after 6m39s
backend / cross (mipsel) (push) Failing after 4m36s
docker / build (push) Failing after 1h16m25s
2025-10-22 22:52:39 +08:00
46d308ce35 fix bug
Some checks failed
backend / cross (aarch64) (push) Failing after 18m22s
backend / cross (arm) (push) Failing after 31s
backend / cross (i686) (push) Failing after 31s
backend / cross (mips64) (push) Failing after 31s
backend / cross (mips64el) (push) Failing after 31s
backend / cross (armhf) (push) Failing after 1m31s
backend / cross (mips) (push) Failing after 31s
backend / cross (mipsel) (push) Failing after 14m31s
backend / cross (s390x) (push) Failing after 40m18s
backend / cross (win32) (push) Failing after 26m5s
backend / cross (x86_64) (push) Failing after 34m16s
docker / build (push) Failing after 5m50s
2025-10-22 11:59:58 +08:00
7cd85a3315 add postAttachCommand feature
Some checks are pending
docker / build (push) Waiting to run
2025-10-19 01:13:49 +08:00
fd338d2dad show differences
Some checks failed
backend / cross (aarch64) (push) Waiting to run
backend / cross (arm) (push) Waiting to run
backend / cross (armhf) (push) Waiting to run
backend / cross (i686) (push) Waiting to run
backend / cross (mips) (push) Waiting to run
backend / cross (mips64) (push) Waiting to run
backend / cross (mips64el) (push) Waiting to run
backend / cross (mipsel) (push) Waiting to run
backend / cross (s390x) (push) Waiting to run
backend / cross (win32) (push) Waiting to run
backend / cross (x86_64) (push) Waiting to run
frontend / build (push) Waiting to run
docker / build (push) Has been cancelled
2025-10-18 16:35:39 +08:00
6dbe2f6e20 Show differences
Some checks failed
backend / cross (aarch64) (push) Has been cancelled
backend / cross (arm) (push) Has been cancelled
backend / cross (armhf) (push) Has been cancelled
backend / cross (i686) (push) Has been cancelled
backend / cross (mips) (push) Has been cancelled
backend / cross (mips64) (push) Has been cancelled
backend / cross (mips64el) (push) Has been cancelled
backend / cross (mipsel) (push) Has been cancelled
backend / cross (s390x) (push) Has been cancelled
backend / cross (win32) (push) Has been cancelled
backend / cross (x86_64) (push) Has been cancelled
docker / build (push) Has been cancelled
frontend / build (push) Has been cancelled
2025-10-18 16:33:31 +08:00
36d23c3d74 add log
Some checks failed
backend / cross (mips64el) (push) Has been cancelled
backend / cross (mipsel) (push) Has been cancelled
backend / cross (s390x) (push) Has been cancelled
backend / cross (win32) (push) Has been cancelled
backend / cross (x86_64) (push) Has been cancelled
backend / cross (aarch64) (push) Has been cancelled
backend / cross (arm) (push) Has been cancelled
backend / cross (armhf) (push) Has been cancelled
backend / cross (i686) (push) Has been cancelled
backend / cross (mips) (push) Has been cancelled
backend / cross (mips64) (push) Has been cancelled
docker / build (push) Has been cancelled
2025-10-18 13:18:15 +08:00
4 changed files with 16248 additions and 16229 deletions

View File

@@ -61,9 +61,10 @@ export class Terminal extends Component<Props, State> {
if (data.status !== '-1') {
if (options.get('type') === 'docker') {
this.xterm.open(this.container);
this.xterm.changeContainerStatus(data.status);
this.xterm.connect();
} else {
this.intervalID = setInterval(this.loadOutput, 3000);
this.intervalID = setInterval(this.loadOutput, 8000);
this.xterm.open(this.container);
this.xterm.changeUrl(this.currentDevcontainer.ip, this.currentDevcontainer.port)
this.xterm.changeStatus(true);

View File

@@ -103,10 +103,12 @@ export class Xterm {
private closeOnDisconnect = false;
private intervalID: NodeJS.Timeout;
private writeFunc = (data: ArrayBuffer) => this.writeData(new Uint8Array(data));
private status = false;
private titleStatus = false;
private checkStatus = false;
private connectStatus = false;
private hostTitle = "";
private postAttachCommand = [];
private postAttachCommandStatus = false;
private workdir = "";
private containerStatus = "";
private beforeCommand?: string;
constructor(
private options: XtermOptions,
@@ -186,7 +188,7 @@ export class Xterm {
register(
terminal.onData(data =>
{
if (this.status) {
if (this.connectStatus) {
sendData(data);
} else {
this.writeData('\b \b');
@@ -266,7 +268,7 @@ export class Xterm {
@bind
public changeStatus(v: boolean){
this.status = v;
this.connectStatus = v;
}
@bind
@@ -281,7 +283,11 @@ export class Xterm {
register(addEventListener(socket, 'error', () => (this.doReconnect = false)));
const options = new URLSearchParams(decodeURIComponent(window.location.search));
if (options.get('type') === 'docker') {
this.intervalID = setInterval(this.loadCommand, 3000);
if(this.containerStatus === '4' || this.containerStatus === '-1'){
this.intervalID = setInterval(this.loadCommand, 1000);
}else{
this.intervalID = setInterval(this.loadCommand, 8000);
}
}
}
@@ -352,26 +358,23 @@ export class Xterm {
)
.then(response => response.json())
.then(data => {
if (this.workdir === ''){
this.workdir = data.workdir;
}
if (data.status !== '4' && data.status !== '0') {
this.sendData(data.command);
if(this.containerStatus !== data.status){
this.sendData(data.command);
}
this.containerStatus = data.status;
} else {
clearInterval(this.intervalID);
if(this.containerStatus !== '4'){
this.writeData("\x1b[31mCreation completed. Please refresh the page to connect to the devcontainer\x1b[0m");
}
this.containerStatus = data.status;
if (data.status === '4') {
fetch(
'http://' + options.get('domain') + ':'+ options.get('port') +'/' +
options.get('user') +
'/' +
options.get('repo') +
'/devcontainer/command?' +
params
)
.then(response => response.json())
.then(data => {
this.sendData(data.command);
})
.catch(error => {
console.error('Error:', error);
});
const parts = data.command.split('\n');
this.sendData(parts[0]+"\n");
this.postAttachCommand = parts;
}
}
})
@@ -379,7 +382,10 @@ export class Xterm {
console.error('Error:', error);
});
}
@bind
public changeContainerStatus(v: string){
this.containerStatus = v;
}
@bind
private parseOptsFromUrlQuery(query: string): Preferences {
const { terminal } = this;
@@ -422,43 +428,43 @@ export class Xterm {
const data = rawData.slice(1);
switch (cmd) {
case Command.OUTPUT:
console.log('[ttyd] output:', textDecoder.decode(data));
const options = new URLSearchParams(decodeURIComponent(window.location.search));
const params = new URLSearchParams({
repo: options.get('repoid') as string,
user: options.get('userid') as string,
});
if (options.get('type') === 'docker') {
// 保存host的标题
if (this.hostTitle === ""){
this.hostTitle = textDecoder.decode(data).replace(/\s/g, '');
}
// 检测是否退出devcontainer标题等于host的标题
if (this.connectStatus && textDecoder.decode(data).replace(/\s/g, '').includes(this.hostTitle)){
this.connectStatus = false
}
// this.connectStatus = true 连接完成
if (
this.status === false &&
textDecoder.decode(data).replace(/\s/g, '').includes('Successfully connected to the container'.replace(/\s/g, ''))
this.connectStatus === false &&
textDecoder.decode(data).replace(/\s/g, '').includes('Successfully connected to the devcontainer'.replace(/\s/g, ''))
) {
if(this.connectStatus == true){
this.status = true;
}
this.connectStatus = true;
clearInterval(this.intervalID);
}
if (this.checkStatus) {
if (textDecoder.decode(data).replace(/\s/g, '').includes('You have out the container. Please refresh the terminal to reconnect.'.replace(/\s/g, ''))) {
this.checkStatus = false;
this.status = false;
this.connectStatus = false;
}
if(textDecoder.decode(data).includes('\x1b')){
this.checkStatus = false;
}
}
if (this.titleStatus && textDecoder.decode(data).includes('\x1b')) {
this.titleStatus = false;
this.checkStatus = true;
this.sendData(
`echo $WEB_TERMINAL\n`
);
}
// 连接完成之前不输出标题和docker命令
if (
!(this.status === false && (textDecoder.decode(data).includes('\x1b') || textDecoder.decode(data).replace(/\s/g, '').includes('docker'))) &&
this.titleStatus !== true &&
this.checkStatus !== true
!(this.connectStatus === false &&
(textDecoder.decode(data).includes('\x1b') ||
textDecoder.decode(data).replace(/\s/g, '').includes('docker-H')))
){
this.writeFunc(data);
}
if (textDecoder.decode(data).replace(/\s/g, '').includes('exit')) {
this.titleStatus = true;
// 连接完成且出现容器的标题且没有执行过postAttach命令
if (this.connectStatus && textDecoder.decode(data).replace(/\s/g, '').includes(this.workdir) && !this.postAttachCommandStatus){
for (let i = 1; i < this.postAttachCommand.length; i++){
this.sendData(this.postAttachCommand[i]+"\n");
}
this.postAttachCommandStatus = true;
}
} else {

2
package-lock.json generated
View File

@@ -1,5 +1,5 @@
{
"name": "ttyd",
"name": "webTerminal",
"lockfileVersion": 3,
"requires": true,
"packages": {}

32364
src/html.h generated

File diff suppressed because it is too large Load Diff