Skip to content

Bugfix for Albert load workflow opt - #1433

Merged
zuozhiw merged 13 commits into
masterfrom
albert-load_workflow_opt
Feb 7, 2022
Merged

zuozhiw merged 13 commits into
masterfrom
albert-load_workflow_opt

Conversation

@MysteriousChallenger

@MysteriousChallenger MysteriousChallenger commented Feb 6, 2022 •

Copy link
Copy Markdown
Contributor

Continuation of #1398

The bug:

There is an event listener responsible for adding the link breakpoint button to all links:

getJointLinkCellAddStream().subscribe(link => {
    const linkView = link.findView(this.getJointPaper());
    ...
    linkView.hideTools(); // hides breakpoint icon
});

In async mode, the link cell is added to the graph but not drawn to the webpage (This avoids an expensive DOM reflow)

Since it's not drawn to the webpage, hideTools doesn't work right (for reasons unknown, it fails silently)

The solution:

We can't draw the link cells: the whole point is to avoid DOM reflows
Instead, we modify the event stream getJointLinkCellAddStream() to buffer its events while the jointgraph is in async mode and emit them all at once afterwards.

I adapted the method from https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22)

merge(
  source$.pipe( bufferToggle(off$, ()=>on$)  ),
  source$.pipe( windowToggle(on$,  ()=>off$) )
).pipe(
  // then flatten buffer arrays and window Observables
  flatMap(x => x)
)

bufferToggle starts buffering on off$, and emits on on$
windowToggle starts emitting on on$ and stops emitting on off$

P.S.
https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22)
this article had another cool trick for rate-limiting for bursty events

MysteriousChallenger and others added 9 commits January 20, 2022 22:38
...by freezing joint paper until all updates are complete,
skipping unnecesarry rendering
...by batching the addition of new operators
with one addcells() / resetcells() call
ContextManager with RXJS event streams
it now buffers input while the joint graph wrapper
is in an async context
@MysteriousChallenger MysteriousChallenger changed the title Albert load workflow opt Bugfix for Albert load workflow opt Feb 6, 2022
accidentally made SyncTexeraGraph listeners asynchronous via
createContextAwareStream(jointCellAddStream) .

This caused them to not be disabled by
this.setSyncTexeraGraph(false);
which is commonly used internally to temporarily
sidestep synchronization .

I've applied the context awareness more specifically to
handleLinkBreakpointToolAttachment(), where it's specifically needed.

@zuozhiw zuozhiw left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async rendering causes many unexpected bugs and we need to further investigate it. I have disabled async rendering by default, so we can merge it and fix the master. We'll re-enable it after fixing the related bugs.

@zuozhiw
zuozhiw merged commit 1dd1c39 into master Feb 7, 2022
@zuozhiw
zuozhiw deleted the albert-load_workflow_opt branch February 7, 2022 22:02
@MysteriousChallenger
MysteriousChallenger restored the albert-load_workflow_opt branch February 8, 2022 07:38
zuozhiw added a commit that referenced this pull request Mar 11, 2022
# Continuation of #1433

Thanks @zuozhiw for fixing a breakpoint related bug. I don't actually know how to test that yet.

### REFACTORS
- createContextAwareStream --> custom RXJS pipeable operator named bufferWhileAsync: I.E `source$.pipe(bufferWhileAsynce)` 
- ContextManager enter/exit are now protected (from public).

### BUGS

- Bug: Anomalous rendering when changing workflows
Fix: re-add request an updateView() after the async period (mistakenly removed)

- Bug: Can't highlight element because it doesn't exist (yet)
Fix: Buffer highlight events to run after the async period. Introduce more bugs

- Bug: Can't unhighlight element because it doesn't exist (anymore) (due to previous "fix")
WontFix: Update highlighed list but don't actually call unhighlight() (it's already deleted after all)
>   A unhighlight event is emitted when an element is deleted. Due to buffering, it will only be handled after the async period, after the element is deleted (This behavior can be changed if needed)
> However, It was never a documented guarantee that an unhighlighted element would still exist at the time it's event is handled. I don't think this is a big loss, so from now on, it's explicitly NOT GUARANTEED

Co-authored-by: zuozhiw <[email protected]>
@Yicong-Huang Yicong-Huang added frontend Changes related to the frontend GUI and removed gui labels Jul 6, 2025
@Yicong-Huang Yicong-Huang removed the bug label Oct 4, 2025
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
# Continuation of apache#1398

# The bug:

There is an event listener responsible for adding the link breakpoint button to all links:
```
getJointLinkCellAddStream().subscribe(link => {
    const linkView = link.findView(this.getJointPaper());
    ...
    linkView.hideTools(); // hides breakpoint icon
});
```

In async mode, the link cell is added to the graph but not drawn to the webpage (This avoids an expensive DOM reflow)

Since it's not drawn to the webpage, hideTools doesn't work right (for reasons unknown, it fails silently)

# The solution:
We can't draw the link cells: the whole point is to avoid DOM reflows
Instead, we modify the event stream getJointLinkCellAddStream() to buffer its events while the jointgraph is in async mode and emit them all at once afterwards.

I adapted the method from https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22)
```
merge(
  source$.pipe( bufferToggle(off$, ()=>on$)  ),
  source$.pipe( windowToggle(on$,  ()=>off$) )
).pipe(
  // then flatten buffer arrays and window Observables
  flatMap(x => x)
)
```
bufferToggle starts buffering on **_off$_**, and emits on **_on$_**
windowToggle starts emitting on **_on$_** and stops emitting on **_off$_**


P.S. 
https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22) 
this article had another cool trick for rate-limiting for bursty events

Co-authored-by: zuozhiw <[email protected]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
# Continuation of apache#1433

Thanks @zuozhiw for fixing a breakpoint related bug. I don't actually know how to test that yet.

### REFACTORS
- createContextAwareStream --> custom RXJS pipeable operator named bufferWhileAsync: I.E `source$.pipe(bufferWhileAsynce)` 
- ContextManager enter/exit are now protected (from public).

### BUGS

- Bug: Anomalous rendering when changing workflows
Fix: re-add request an updateView() after the async period (mistakenly removed)

- Bug: Can't highlight element because it doesn't exist (yet)
Fix: Buffer highlight events to run after the async period. Introduce more bugs

- Bug: Can't unhighlight element because it doesn't exist (anymore) (due to previous "fix")
WontFix: Update highlighed list but don't actually call unhighlight() (it's already deleted after all)
>   A unhighlight event is emitted when an element is deleted. Due to buffering, it will only be handled after the async period, after the element is deleted (This behavior can be changed if needed)
> However, It was never a documented guarantee that an unhighlighted element would still exist at the time it's event is handled. I don't think this is a big loss, so from now on, it's explicitly NOT GUARANTEED

Co-authored-by: zuozhiw <[email protected]>
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Sep 27, 2026
…e#8695)

### What changes were proposed in this PR?

Deletes `ObservableContextManager` and re-parents its only subclass,
`JointGraphContext`, onto `ContextManager`. **+8/−223 lines.** There is
no behaviour change: the removed layer only emitted enter/exit events on
Subjects nothing subscribes to, and `JointGraphContext`'s own `enter` /
`exit` overrides still call `super`.

### History

| | |
| --- | --- |
| **Introduced by** | apache#1433 (2022-02-07), "Bugfix for Albert load
workflow opt". `JointGraphContext` used the change stream to buffer
JointJS events in async mode |
| **Usage removed by** | apache#1810 (2023-01-27), "Fix buffering events in
JointJS async context". It deleted both `getChangeContextStream()`
subscribers |

It has been dead for over three and a half years. Every paper-context
enter/exit since then has emitted into streams with no reader.

> Reviewer note: `context.spec.ts` goes from 23 cases to 12. The 11
stream-only cases are deleted. 4 others move into
`describe("ContextManager")` with their stream assertions dropped,
because they cover `ContextManager` paths the original 8 cases did not:
object-identity contexts, nested unwinding when a callable throws, falsy
return values, and re-entering the same value.

### Any related issues, documentation, discussions?

Closes apache#8694

### How was this PR tested?

No new tests. The kept `ContextManager` cases cover the surviving code.

From `frontend/`:

- `npx ng test --watch=false --include='**/context.spec.ts'
--include='**/joint-graph-wrapper.spec.ts'
--include='**/workflow-editor.component.spec.ts'`: 3 files, 199 tests,
all pass.
- `yarn format:ci`: clean.
- `npx ng build`: success.

To re-check:

```
git grep -n "ObservableContextManager\|getChangeContextStream\|getEnterStream\|getExitStream" -- frontend   # no hits
```

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 26, 2026
### What changes were proposed in this PR?

Remove code that nothing uses from the workflow persistence service, the
dashboard's workflow list, the canvas graph wrapper, a context-menu spec
and the Parca deployment files (**+48/−274 lines**). There is no
behavior change.

- **Workflow search clients:** `WorkflowPersistService.searchWorkflows`
and `retrieveWorkflowsBySessionUser` have no caller. apache#1988 removed the
last call to the first, and apache#7463 removed the project feature that
called the second. Their private response formatter, the unused
`WORKFLOW_LIST_URL`, `WORKFLOW_SEARCH_URL` and `WORKFLOW_USER_ACCESS`
constants, and the test stub's `searchWorkflows` forwarder go with them,
along with their spec cases.
- **Dashboard workflow list:** `UserWorkflowComponent` loses five dead
pieces.
- A private `nameWorkflow` copy that nothing has called since apache#2920
moved ZIP downloads into `DownloadService`, which keeps its own.
  - An unused `ExecutionMode` import.
  - An empty `next` handler around a commented-out call.
  - An unread error argument.
- A class comment whose steps name functions the component no longer
has, such as `searchWorkflows()`, `synchronousSearch()` and
`asyncSearch()`.
- **Graph wrapper:** `JointGraphWrapper` loses four unused pieces.
- The event-tuple detail, unused since apache#2301 removed the drag stream
typed with it.
  - Exports nothing imports, which become file-local.
  - A static `_async` helper that only returned `context.async`.
- A coeditor argument that `removeCurrentEditing` and
`removePropertyChanged` never read; `CoeditorPresenceService` stops
passing it.
- **Context-menu spec:** `ReactiveFormsModule`, `NzDropDownModule` and
`NzModalModule` in its two test beds are not needed. `NzModalService`
stays.
- **Parca:** `parca-agent.env` sets `PARCA_AGENT_*` variables that the
pinned agent never reads; the Compose command already passes every value
as a flag. The env file and its `env_file` entry go. The Compose
comments, README, `ParcaConfigSpec` and the release-tarball test now
point at the command's values.

| Event | PR / Commit |
| --- | --- |
| Introduced by | Workflow search clients: apache#1885 (2023-04-20);
`nameWorkflow`: apache#1629 (2022-08-17); graph wrapper: the coeditor argument
apache#1676 (2022-10-06), the context helper apache#1433 (2022-02-07); context-menu
spec: apache#2901 (2024-10-06); Parca env file: apache#5377 (2026-10-28) |
| Usage removed by | `searchWorkflows`: apache#1988 (2023-06-12).
`retrieveWorkflowsBySessionUser`: apache#7463 (2026-08-29). `nameWorkflow`:
apache#2920 (2024-10-11). Graph event detail: apache#2301 (2024-01-28). Everything
else: unused since introduction. |

As of 2026-11-25:
- The coeditor argument has gone unread for over 4 years, and the search
client has had no caller for over 2 years.
- The event-tuple detail has been unread for almost 2 years, and
`nameWorkflow` uncalled for over a year.
- The session-user client has been unused for almost 3 months, and the
Parca variables unread for the month since they were added.

### Any related issues, documentation, discussions?

Closes apache#9713.

### How was this PR tested?

Ran on this branch and on `main` at `f4adf7f588` (Windows 11; Node 24
with Yarn 4.14.1; JDK 17):

```bash
cd frontend
npx ng test --watch=false --include='**/workflow-persist.service.spec.ts' --include='**/user-workflow.component.spec.ts' --include='**/context-menu.component.spec.ts' --include='**/coeditor-presence.service.spec.ts' --include='**/joint-graph-wrapper.spec.ts'
npx tsc --noEmit -p src/tsconfig.app.json
npx tsc --noEmit -p src/tsconfig.spec.json
npx ngc -p src/tsconfig.app.json --noEmit
yarn prettier-eslint --list-different $(git diff --name-only --relative origin/main -- src)
yarn eslint $(git diff --name-only --relative origin/main -- src | grep -E '\.(ts|html)$')
cd ..
sbt "Config/testOnly org.apache.texera.observability.ParcaConfigSpec" Config/scalafmtCheckAll "Config/scalafixAll --check"
bash .github/scripts/test_create_release_tarballs.sh
(cd bin/single-node && docker compose config -q)
```

- **Frontend:** the five specs run 301 tests on this branch and 304 on
`main`, all passing.
- The three extra on `main` are the deleted methods' own cases
(`searchWorkflows`, `retrieveWorkflowsBySessionUser` and
`nameWorkflow`). Every other test keeps its name and outcome.
  - Both typechecks, the AOT compile, prettier-eslint and ESLint pass.
- **Parca:** `ParcaConfigSpec` runs 9 tests, all passing on both sides;
four of them now read the Compose command instead of the env file.
scalafmt and scalafix pass. The release-tarball regression test passes,
and `docker compose config` accepts the single-node file.

To re-check, this returns no hits on this branch:

```bash
git grep -nwE "searchWorkflows|retrieveWorkflowsBySessionUser|makeRequestAndFormatWorkflowResponse|WORKFLOW_SEARCH_URL|_async|parca-agent\.env" -- frontend/src bin common/config
```

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants