Skip to content

i1083 f5 in wti fails with remote server#1199

Merged
johnbrvc merged 33 commits intopc2ccs:developfrom
clevengr:i1083_F5_in_WTI_fails_with_remote_server
Feb 12, 2026
Merged

i1083 f5 in wti fails with remote server#1199
johnbrvc merged 33 commits intopc2ccs:developfrom
clevengr:i1083_F5_in_WTI_fails_with_remote_server

Conversation

@clevengr
Copy link
Contributor

@clevengr clevengr commented Dec 27, 2025

Description of what the PR does

Fixes the problem identified in Issue #1083 where pressing F5 in the WTI causes the contest clocks to freeze. Specifically:

  • Restructures the Angular Single-Page_App (SPA) initialization sequence, specifically:
    • Adds a new file app-init.service.ts in app>modules>core services. This file contains a new AppInitService class which handles all initialization for the SPA.
    • Restructures app.module.ts so that it invokes AppInitService.initializeApp() at Angular bootstrap time. This ensures that all SPA initializations occur prior to display of any SPA components. (This matches what, according at least to ChatGPT, is Angular "best practice" for SPA initialization since Angular 14.)
  • Adds a call to ContestService.updateLocalContestClockFromServer() to AppInitService. (It is this addition which actually fixes the bug described in F5 in WTI fails with remote server #1083 .
  • Moves all SessionStorage handling to a new session-storage.utils service in `app>modules>core>services. While not strictly necessary, this code refactor is included as part of "Continuous Improvement" (CI).
  • Implements several additional CI/cleanup steps such as fixing existing typos, removing initialization constraints in HTML code made unnecessary by the new AppInit structure, adding an exception handler for a parseInt in the ContestController; making debug/tracing output on the browser console conditional, and updating app-header.component to handle clock updates more efficiently.
  • Disabling browser console tracing (in preparation for distribution release).

Issue which the PR addresses

Fixes #1083.

Environment in which the PR was developed:

Windows 11, Eclipse Version: 2021-12 (4.22.0), Java 1.8.0_381.

Precise steps for testing the PR:

NOTE: it is important to test this PR under the condition that the WTI Server is NOT running on the same machine as the web browser used to login to the WTI; or, alternatively, that the WTI Server listens on a different port than the default port (8080). Failure to observe these test conditions will invalidate the test (because the failure which this PR fixes -- as identified in Issue #1083 -- only occurs when the connection to the WTI server is NOT via the default http://localhost:8080.)

Setup

  • Download the PR distribution and unzip it.
  • Start a PC2 Server, loading a known contest (e.g. sumithello). Be sure the contest you use does not start automatically (sumithello does not).
  • Start a PC2 admin; use it to make sure the contest problems are configured properly. (In particular, if you use sumithello, update the problems to read from stdin (instead of FileIO) if you want to use the "standard in" versions of the samples for submissions. See Issue Problems in sample contests should not specify "FileIO" input mode. #1198.)
  • Start a PC2 AutoJudge to judge the problems in the contest. (For sumithello, logging in as judge3 or judge4 will work.)
  • In the PC2 Projects folder, unzip the WebteamInterface-1.2.zip file, then cd into the resulting folder.
  • Ensure that the WTI's pc2v9.ini file does not contain an entry wtiboardUseDivisions=true (either set it to false, delete it entirely, or else assign a Division to every team in the contest since sumithello does not do this by default).
  • Start the WTI Server (./bin/pc2wti).
  • On a different machine, start a web browser and connect to the WTI Server (e.g. using http://<ip>:<port> where <ip> is the address of the other machine -- the one running the WTI Server -- and <port> is the port on which the WTI Server is listening (the default port, configured in the pc2v9.ini file in the WTI project folder, is 8080)). If you have used this browser to connect to WTI previously, be sure to clear the browser's cache (or, use Incognito mode).
    • An alternative to using a separate machine to run the web browser is to change the wtiport=8080 entry in the WTI Server's startup folder to specify a different port. This change must be done before starting the WTI Server.

Test correct Pre-Contest operations

  • Login to the WTI using the browser. (For sumithello, "team1" through "team10" with joe passwords will work.)
  • Verify:
    • The contest clocks ("Elapsed" and "Remaining") are correct and are not changing (because the contest hasn't started yet).
    • The contest problems are not visible on any of the WTI screens (again, because the contest has not yet started).

Test for Regressions in normal operations

  • On the PC2 Admin Configure Contest > Times tab, click Start All.
  • On the team login (browser), verify:
    • The header "Elapsed" clock starts counting up and the "Remaining" clock starts counting down.
    • All of the WTI "Select Problem" dropdowns now show the contest problems.
  • Submit a correct solution for one of the problems using the WTI "Runs" tab, then verify:
    • A green "Run submitted successfully" message is displayed.
    • A "Yes" judgement notification is received.
    • The run is correctly displayed in the WTI Runs grid as having received a "Yes".
  • Submit a clarification request using the WTI "Clarifications" tab, then verify:
    • A green "Clarification successfully submitted" notification is received.
    • The clarification request is correctly displayed in the WTI Clarifications grid, with an Answer of "Answer Pending".
  • Use the PC2 Admin to answer the clarification, then verify:
    • A "Clarification Reply Received" notification pops up on the WTI browser.
    • The Answer appears on the Clarifications grid.
  • Test disabling pop-ups:
    • Select the "Options" tab on the WTI screen and disable clarification popups.
    • Submit another clarification.
    • Verify that the clarification shows up on the WTI Clarifications grid, as "Answer Pending".
    • Switch to a different WTI tab (e.g. Runs).
    • Answer the Clarification using the PC2 Admin. Verify:
      • the clarification does NOT cause a pop-up to appear.
      • when you switch back to the Clarifications tab the clarification answer does appear on the WTI Clarifications grid.
  • Click the Scoreboard tab on the WTI, then verify that the displayed scoreboard matches whatever submissions you have made (this is why you should submit at least one "Yes" run as noted above...)

Test Correct Operation after F5.

  • Hit F5 on the browser.
  • Verify:
    • Whatever WTI page you were on is still the current page.
    • The Elapsed and Remaining time clocks in the header are accurate and are counting as expected.
    • Every test listed under "Regressions", above, still works correctly.
  • On the PC2 Admin, STOP the contest.
  • On the browser, verify the header clocks have stopped counting.
  • Hit F5; verify the header clocks retain the same time and remain stopped.
  • On the PC2 Admin, restart the contest, then verify that the clocks on the WTI browser continue appropriately.

clevengr and others added 30 commits April 29, 2025 16:47
page saving is not needed due to the restructuring with APP_INITIALIZER
-- AppInit automatically uses the browser's most-recent page URL.
add support for better handling of Run/Clar popup notifications.
added better support for saving/loading options in sessionStorage.
@clevengr clevengr added this to the 9.11.0 milestone Dec 27, 2025
@clevengr clevengr added bug Something isn't working WTI-UI This bug or feature request applies to the WTI-UI (browser-side). CI - Continuous Improvement Continuously improve pc2 code quality, features and testing Refactor Refactor source, CI activity NEXT Contest Consider fixing for next contet labels Dec 27, 2025
Copy link
Collaborator

@kkarakas kkarakas left a comment

Choose a reason for hiding this comment

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

For this I ran the develop branch to see if I can observe the bug. I managed to observe the bug. However when I ran this branch, when I refresh I get a blank screen. I don't know why I will further test this.

Copy link
Collaborator

@johnbrvc johnbrvc left a comment

Choose a reason for hiding this comment

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

I will not pretend to completely understand how the Angular stuff works. I did look over the code, and for the most part, I don't really follow what is going on in the typescript. That being said, I did not see any glaring things that bothered me. I did notice a CI that was not mentioned in the PR (unless I missed it), and that's an exception handler was added for a parseInt in the ContestController; Handling error cases is almost always a good thing.

I did to a FULL test as per the PR, including all the regression tests (3 times). 1) test normal operations, 2) press F5 and repeat the tests, periodically pressing F5 3) restart, and essentially do the part 2 tests (pressing F5 during regression testing). I can confirm it works as described; I did not notice any anomalies.

Approved.

@clevengr
Copy link
Contributor Author

I will not pretend to completely understand how the Angular stuff works. I did look over the code, and for the most part, I don't really follow what is going on in the typescript. That being said, I did not see any glaring things that bothered me. I did notice a CI that was not mentioned in the PR (unless I missed it), and that's an exception handler was added for a parseInt in the ContestController; Handling error cases is almost always a good thing.

Well, the PR description does include the statement

Implements several additional CI/cleanup steps such as... 

However, I will grant that the specific CI you mentioned (adding an exception handler) was not explicitly mentioned in the description. I've added it, mostly for posterity's sake... although it's not really a "CI" in that previously the code assumed that the value was an int (so parseInt couldn't fail; now, it might not be an int so I added the exception handler to cover the possibility. In other words, it's actually an important part of the code changes. So maybe I should have mentioned it separately...

@clevengr
Copy link
Contributor Author

For this I ran the develop branch to see if I can observe the bug. I managed to observe the bug. However when I ran this branch, when I refresh I get a blank screen. I don't know why I will further test this.

@kkarakas :
I can think of a couple of reasons why this "blank screen" might happen. One would be if the browser doesn't have the correct IP/port for the WTI Server. You could re-enable the DEBUG_MODE option in the WTI-UI constants.ts file, rebuild the system, and look at the value of baseUrl: in the environment values in the browser console output. The default value for that is baseUrl: 'http://localhost:8080/api', but if you have properly set up the test then instead of localhost it should contain the IP address of the machine on which the WTI Server is running. If not, your networking isn't set up to properly perform the test.

Another reason (perhaps more likely) is that your browser is reusing cached values instead of hard-refreshing when you hit F5. To avoid this, try using a browser running it "Incognito" mode (or "InPrivate" mode, or whatever term your particular browser uses). (In Chrome you would run "Incognito Mode".)

@kkarakas
Copy link
Collaborator

Using incognito solved the issue. I thought cmd + shift + R (hard refresh) would be sufficient alas it wasn't. When I looked in the console it appears that the websocket url is stuck in the old local IP address. I am not sure if it counts as a bug.

Anyways I was able to run and observe that this branch fixed the bug.

Copy link
Collaborator

@kkarakas kkarakas left a comment

Choose a reason for hiding this comment

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

Code looks good to me. The bug seems to be solved. Although I once ran into an error when I was testing with multiple logins but was not able to replicate. Because of the bug I was not able to login anymore until I restarted WTI. Do you know why this might happen?
Screenshot 2026-01-11 at 10 28 31 PM

Also realized that when the contest is stopped submit a clarification button is enabled but if you send a clarification you receive an error. Is that intentional? I imagine these are not related to this PR so If you want I can create an issue.

@johnbrvc
Copy link
Collaborator

Code looks good to me. The bug seems to be solved. Although I once ran into an error when I was testing with multiple logins but was not able to replicate. Because of the bug I was not able to login anymore until I restarted WTI. Do you know why this might happen? Screenshot 2026-01-11 at 10 28 31 PM

Also realized that when the contest is stopped submit a clarification button is enabled but if you send a clarification you receive an error. Is that intentional? I imagine these are not related to this PR so If you want I can create an issue.

The "ContestClock" errors are likely the result of JS running (IE TS) and the client has logged out. It is trying to query the PC2 server for the time left in the contest, and if no one is logged in, that will, of course fail. It's probably not a problem per se'. It sounds to me like you were logging out and logging in to different account? It could be this happens because of the switching. @clevengr can probably shed more light on it.

@johnbrvc johnbrvc merged commit 367bf21 into pc2ccs:develop Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CI - Continuous Improvement Continuously improve pc2 code quality, features and testing NEXT Contest Consider fixing for next contet Refactor Refactor source, CI activity WTI-UI This bug or feature request applies to the WTI-UI (browser-side).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F5 in WTI fails with remote server

3 participants