diff --git a/server.js b/server.js index b9bdb00a3..97678f406 100644 --- a/server.js +++ b/server.js @@ -267,6 +267,13 @@ function buildDockerStreamRequest(path, target, body = '') { ); } +// Mirrors translateAttachInput in docker-stream-core.ts: for non-TTY attach map a lone +// \r (xterm Enter) to \n (no pty to do it); exec / TTY attach pass through. Keep in sync. +function translateAttachInput(data, nonTtyAttach) { + if (!nonTtyAttach) return data; + return data.replace(/\r(?!\n)/g, '\n'); +} + function createDockerStreamState(multiplexed = false) { return { headersStripped: false, @@ -538,7 +545,8 @@ async function handleTerminalConnection(ws, url, connId) { try { const msg = JSON.parse(data.toString()); if (msg.type === 'input' && msg.data) { - dockerStream.write(msg.data); + // Non-TTY attach has no pty to convert Enter (\r) to a newline. + dockerStream.write(translateAttachInput(msg.data, multiplexed)); } else if (msg.type === 'resize' && msg.cols && msg.rows) { if (mode === 'attach') { if (typeof globalThis.__terminalResizeContainer === 'function') { @@ -644,10 +652,12 @@ function handleEdgeExec(ws, connId, containerId, shell, user, environmentId, mod try { const msg = JSON.parse(data.toString()); if (msg.type === 'input' && msg.data) { + // Non-TTY attach has no pty to convert Enter (\r) to a newline. + const inputData = translateAttachInput(msg.data, attach && multiplexed); const inputMsg = JSON.stringify({ type: 'exec_input', execId, - data: Buffer.from(msg.data).toString('base64') + data: Buffer.from(inputData).toString('base64') }); globalThis.__hawserSendMessage(environmentId, inputMsg); } else if (msg.type === 'resize' && msg.cols && msg.rows) { diff --git a/src/lib/components/WhatsNewModal.svelte b/src/lib/components/WhatsNewModal.svelte index f9e044ace..7bc108859 100644 --- a/src/lib/components/WhatsNewModal.svelte +++ b/src/lib/components/WhatsNewModal.svelte @@ -3,6 +3,7 @@ import { Button } from '$lib/components/ui/button'; import { Sparkles, Bug, Zap, CheckCircle, ScrollText } from 'lucide-svelte'; import { compareVersions } from '$lib/utils/version'; + import { releasedEntries } from '$lib/utils/changelog-filter'; import ChangelogText from '$lib/components/ChangelogText.svelte'; interface ChangelogEntry { @@ -10,6 +11,7 @@ date: string; changes: Array<{ type: string; text: string }>; imageTag?: string; + comingSoon?: boolean; } interface Props { @@ -22,9 +24,11 @@ let { open = $bindable(), version, changelog, lastSeenVersion, onDismiss }: Props = $props(); - // Filter to show versions newer than lastSeenVersion, limited to 3 most recent + // Versions newer than lastSeenVersion, 3 most recent. Coming-soon (unreleased) + // entries are excluded: the user is on a released build, so an unreleased version + // must never appear as something they "missed". const missedReleases = $derived( - changelog + releasedEntries(changelog) .filter((r) => { if (!lastSeenVersion) return true; // Show all if first time return compareVersions(r.version, lastSeenVersion.replace(/^v/, '')) > 0; diff --git a/src/lib/data/changelog.json b/src/lib/data/changelog.json index f7f3693dd..f7b687cb9 100644 --- a/src/lib/data/changelog.json +++ b/src/lib/data/changelog.json @@ -13,7 +13,9 @@ { "type": "fix", "text": "stop password managers from offering to save stack secret env-var fields (#1517)" }, { "type": "fix", "text": "repository stats no longer fail on the backups screen (#1561)" }, { "type": "fix", "text": "dashboard image disk usage no longer counts shared layers multiple times (PR#1461, @omggga)" }, - { "type": "feature", "text": "add a docker attach terminal mode (#1078, PR#1377, @ivanjx)" } + { "type": "feature", "text": "add a docker attach terminal mode (#1078, PR#1377, @ivanjx)" }, + { "type": "fix", "text": "stack action buttons show for stopped and freshly created stacks, regression (#1565)" }, + { "type": "fix", "text": "the update dialog no longer shows an unreleased version as the target (#1566)" } ], "imageTag": "fnsys/dockhand:v1.0.48" }, diff --git a/src/lib/server/docker-stream-core.ts b/src/lib/server/docker-stream-core.ts index f14d329d5..fb505c12a 100644 --- a/src/lib/server/docker-stream-core.ts +++ b/src/lib/server/docker-stream-core.ts @@ -136,3 +136,18 @@ export function processDockerStreamChunk(data: Buffer | Uint8Array | string, sta return output; } + +/** + * Translate terminal input before writing it to the container's stdin. xterm sends a + * carriage return (\r) when Enter is pressed; with a TTY the pty converts that to a + * newline, but attach to a container started without a tty has no pty, so a shell + * `read` never sees an end-of-line and the session looks unresponsive. When + * `nonTtyAttach` is set, map a lone \r to \n (leaving an existing \r\n alone) so Enter + * ends a line. For exec and TTY attach (nonTtyAttach false) the input passes through + * verbatim. The gate lives here so it is unit-tested alongside the transform, rather + * than only in the inline call-site ternaries. + */ +export function translateAttachInput(data: string, nonTtyAttach: boolean): string { + if (!nonTtyAttach) return data; + return data.replace(/\r(?!\n)/g, '\n'); +} diff --git a/src/lib/server/git-deletions.ts b/src/lib/server/git-deletions.ts index 44378fe64..b21f6c977 100644 --- a/src/lib/server/git-deletions.ts +++ b/src/lib/server/git-deletions.ts @@ -376,6 +376,39 @@ export function buildNextManifest(newCommit: string, newFiles: Record 0 && + sameCommit(manifestCommit, diffBaselineCommit) + ); +} + // ============================================================================= // Sync summary (per-file status table) // ============================================================================= diff --git a/src/lib/server/git.ts b/src/lib/server/git.ts index ccd98d511..d8b90710e 100644 --- a/src/lib/server/git.ts +++ b/src/lib/server/git.ts @@ -34,6 +34,7 @@ import { hashDirFiles, computeDeletions, buildNextManifest, + canSkipTreeRehash, buildSyncChangeSummary, formatChangeTable, skipReasonMessage, @@ -470,13 +471,34 @@ async function computeSyncDeletionPlan(options: { composeDir: string; // absolute path inside the clone composeFileName: string | undefined; // compose file relative to composeDir rawManifest: string | null | undefined; + // When the caller's git diff proved NOTHING changed in the compose dir between + // the deployed commit and the new clone, hashing the whole tree is pure waste: + // no file changed, so none was deleted. Large trees (tens of thousands of files) + // otherwise block the event loop re-hashing unchanged files on every deploy. + // undefined = unknown -> hash (safe default; e.g. new clone / diff failed). + changedInComposeDir?: boolean; + // The commit the git diff was taken against. Skipping is only safe when this + // equals the manifest's own commit; otherwise the diff baseline has drifted + // from the manifest (e.g. a bare Sync advanced lastCommit without persisting + // the manifest) and a full re-hash is required to stay correct. + diffBaselineCommit?: string | null; }): Promise<{ plan: DeletionPlan; newFiles: Record; previousManifest: SyncManifest }> { - const { logPrefix, composeDir, composeFileName, rawManifest } = options; + const { logPrefix, composeDir, composeFileName, rawManifest, changedInComposeDir, diffBaselineCommit } = options; const previousManifest = parseManifest(rawManifest); + const manifestSize = Object.keys(previousManifest.files).length; + + // Fast path: git proved no compose-dir file changed, the diff baseline matches + // the manifest's commit, and we have a prior manifest. Nothing can have been + // added/modified/deleted, so carry the manifest forward verbatim instead of + // re-hashing the entire tree. + if (canSkipTreeRehash(changedInComposeDir, manifestSize, previousManifest.commit, diffBaselineCommit)) { + console.log(`${logPrefix} Deletion sync: no compose-dir changes, skipping full re-hash of ${manifestSize} file(s)`); + return { plan: { toDelete: [], skipped: [] }, newFiles: { ...previousManifest.files }, previousManifest }; + } + const newFiles = hashDirFiles(composeDir); - const manifestSize = Object.keys(previousManifest.files).length; console.log(`${logPrefix} Deletion sync: manifest has ${manifestSize} file(s)${manifestSize === 0 ? ' (first sync — nothing will be deleted)' : ''}`); // First sync / legacy manifest: nothing was recorded, so nothing can be deleted @@ -1236,12 +1258,17 @@ export async function syncGitStack(stackId: number): Promise { console.log(`${logPrefix} No env file path configured`); } - // Deletion sync (#966): manifest-vs-clone deletion plan + // Deletion sync (#966): manifest-vs-clone deletion plan. + // `updated` is the dir-scoped git-diff result (false when the commit didn't + // change OR no compose-dir file changed) - lets the plan skip re-hashing an + // unchanged tree. const deletionData = await computeSyncDeletionPlan({ logPrefix, composeDir, composeFileName, - rawManifest: gitStack.syncedFiles + rawManifest: gitStack.syncedFiles, + changedInComposeDir: updated, + diffBaselineCommit: previousCommit }); // Update git stack status @@ -1875,13 +1902,17 @@ export async function deployGitStackWithProgress( } } - // Deletion sync (#966): manifest-vs-clone deletion plan + // Deletion sync (#966): manifest-vs-clone deletion plan. `updated` is the + // dir-scoped git-diff result; when nothing changed the plan skips re-hashing + // the whole tree. const logPrefix = `[Stack:${gitStack.stackName}]`; const deletionData = await computeSyncDeletionPlan({ logPrefix, composeDir, composeFileName: progressComposeFileName, - rawManifest: gitStack.syncedFiles + rawManifest: gitStack.syncedFiles, + changedInComposeDir: updated, + diffBaselineCommit: previousCommit }); // Update git stack status diff --git a/src/lib/utils/changelog-filter.ts b/src/lib/utils/changelog-filter.ts new file mode 100644 index 000000000..c173fcb13 --- /dev/null +++ b/src/lib/utils/changelog-filter.ts @@ -0,0 +1,13 @@ +// A coming-soon changelog entry (comingSoon: true) is an unreleased placeholder +// used for the webpage's "what's next" section. It must never appear in the app's +// released-version surfaces (About list, What's New, self-update release notes), +// which otherwise render it as the latest shipped version. + +export interface ChangelogEntryLike { + comingSoon?: boolean; +} + +/** Drop unreleased (comingSoon) entries, keeping only shipped releases. */ +export function releasedEntries(entries: T[]): T[] { + return entries.filter((e) => !e.comingSoon); +} diff --git a/src/lib/utils/stack-actions.ts b/src/lib/utils/stack-actions.ts new file mode 100644 index 000000000..4c3cfe77c --- /dev/null +++ b/src/lib/utils/stack-actions.ts @@ -0,0 +1,11 @@ +// Whether the stack row's management actions (edit / logs / start / restart / +// stop) should render. They show for a stack in ANY state EXCEPT a git stack that +// has not been deployed yet - that one shows only its dedicated deploy button, so +// the management actions would be redundant. A non-git stack that is stopped or +// freshly created still needs its Start button, so deploy status must not hide the +// management actions. `status` is the raw stack status; a git stack that has never +// deployed is raw "created" (shown as "not deployed" elsewhere). + +export function showsManagementActions(sourceType: string | undefined, status: string): boolean { + return !(sourceType === 'git' && status === 'created'); +} diff --git a/src/routes/settings/about/AboutTab.svelte b/src/routes/settings/about/AboutTab.svelte index 32ff1a377..f52dbf812 100644 --- a/src/routes/settings/about/AboutTab.svelte +++ b/src/routes/settings/about/AboutTab.svelte @@ -1,6 +1,7 @@