Skip to content

Commit

Permalink
fix(training): terminal no longer working (AmadeusITGroup#2520)
Browse files Browse the repository at this point in the history
## Proposed change

`withLatestFrom` doesn't emit if the promise is already resolved, need
to use `combineLatestWith` instead

## Related issues

<!--
Please make sure to follow the [contribution
guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md)
-->

*- No issue associated -*

<!-- * 🐛 Fix #issue -->
<!-- * 🐛 Fix resolves #issue -->
<!-- * 🚀 Feature #issue -->
<!-- * 🚀 Feature resolves #issue -->
<!-- * :octocat: Pull Request #issue -->
  • Loading branch information
fpaul-1A authored Nov 27, 2024
2 parents 7b7c3b7 + 3d926e8 commit 5f1b7cf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions apps/showcase/src/services/webcontainer/webcontainer-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ import { Terminal } from '@xterm/xterm';
import {
BehaviorSubject,
combineLatest,
from,
fromEvent,
Observable,
of
} from 'rxjs';
import {
combineLatestWith,
distinctUntilChanged,
filter,
from,
fromEvent,
map,
Observable,
of,
skip,
switchMap,
take,
timeout
} from 'rxjs';
import { withLatestFrom } from 'rxjs/operators';
} from 'rxjs/operators';
import { createTerminalStream, killTerminal, makeProcessWritable } from './webcontainer.helpers';

@Injectable({
Expand Down Expand Up @@ -119,7 +120,7 @@ export class WebContainerRunner {
combineLatestWith(
this.shell.cwd.pipe(filter((cwd): cwd is string => !!cwd))
),
withLatestFrom(this.instancePromise),
combineLatestWith(this.instancePromise),
takeUntilDestroyed()
).subscribe(async ([[writer, processCwd], instance]) => {
try {
Expand All @@ -134,7 +135,7 @@ export class WebContainerRunner {
combineLatestWith(
this.shell.terminal.pipe(filter((terminal): terminal is Terminal => !!terminal))
),
withLatestFrom(this.instancePromise),
combineLatestWith(this.instancePromise),
switchMap(([[_, terminal], instance]) => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const spawn = instance.spawn('jsh', [], {env: {O3R_METRICS: false}});
Expand Down

0 comments on commit 5f1b7cf

Please sign in to comment.