Summary:
Made UI fixes to Network Plugin (mostly to Route screens) to continue migration to the new design framework. This consisted mostly of replacing FlexColumn and FlexRow with Layout.Container and Layout.Horizontal.
Also, contains some cosmetic changes to "Mock Network Response" page.
Here is the screenshot with UI changes:

This was the old screen for comparison:

## Changelog
Network Plugin - UI changes to continue migration to Sandy design framework
Pull Request resolved: https://github.com/facebook/flipper/pull/1864
Test Plan: Manual testing to ensure that all data still displayed with new UI changes (especially the Data and Headers info in the "Route Info" section)
Reviewed By: passy
Differential Revision: D26125656
Pulled By: mweststrate
fbshipit-source-id: a25104274ed25788e5c0738ac0a9609f2cead751
Summary:
In the network plugin, add features to import and export routes as described in issue https://github.com/facebook/flipper/issues/1651
Primary use case is that external testers (such as QA teams) would be able to create test data, convert it to mocks and save the mocks to make bug fixes easier for devs.
Here is a screenshot showing location of buttons to perform import/export (and clearing) of mock routes:

Here is another screenshot showing export dialog:

Changelog: [Network] Mock routes can now be imported and exported. Thanks bizzguy!
Pull Request resolved: https://github.com/facebook/flipper/pull/1855
Test Plan:
Performed manual testing
- create new mocks
- export mocks
- clear mocks
- import mocks
- verify that mocks still work by making GET/POST requests in sample app
Performed various permutations of above manual tests, including restarting Flipper at various points to ensure that test plan still worked. Also performed visual inspection of exported files to verify correctness.
Would be very interested in learning how to create automated tests for this functionality.
Reviewed By: passy
Differential Revision: D26072928
Pulled By: mweststrate
fbshipit-source-id: 51bd5e19e78d830b94add850d5dc9b9e45fa6fad
Summary:
The Network Plugin does not properly handle network requests that return an empty body (because of the body actually being empty or because the network call returns something like a 404 status).
Also, the creation of mocks using the "Copy Highlighted" command when the original response returns an empty body is not handled properly.
## Fix
The Android plugin now returns a response when the body length is 0.
The client plugin creates a body containing an empty string instead of null when the body is empty.
## Changelog
Fix problem in Network Plugin when original call or mock has an empty body in the response.
Pull Request resolved: https://github.com/facebook/flipper/pull/1776
Test Plan:
The following screen output for the Network Plugin shows that the call is now being handled correctly. The fields for "status", "size" and "duration" are now populated.
Also, the mock calls are properly defined and shown in yellow.

Reviewed By: mweststrate
Differential Revision: D25804212
Pulled By: passy
fbshipit-source-id: b31cc87619c604b4df76e05bca5c86554a1cabff
Summary:
Some exploratory testing on all iOS and Android plugins, to see how they behave inside Sandy, and fixed some layout glitches (some were also present without Sandy)
General fixes:
* Introduced some niceties like searchbox resizing properly, and toolbars wrapping automatically in Sandy, rather than buttons becoming invisible
* Containers don't grow anymore by default, but take size of contents
* ScrollContainer child is now a Layout.Vertical. Layout.Vertical should be used as default container everywhere (e.g. Tabs, Panels) in the future
* Fixed layout issue if a split container had only 1 visible child
* DetailsSidebar now scrolls vertically by default
* Details sidebar would sometimes render content in-place rather than in the reserved area
* AppSelector dropdown and Plugin list will now properly ellipse (...) if there is not enough space
Plugin fixes:
* Long database / table names in Database plugin would break layout
Also fixes https://github.com/facebook/flipper/issues/1611
Reviewed By: passy
Differential Revision: D24454188
fbshipit-source-id: c60c867270900a1d4f28587d47067c6ec1072ede
Summary:
Changelog: [Network] Non-binary request are not properly utf-8 decoded on both iOS and Android, both when gzipped and when not gzipped
This diff fixes a long standing / ping-pong issue regarding network decoding differences between
* iOS vs Android
* binary vs utf-8
* gzipped vs uncompressed
The changes aren't too big, but the underlying investigating is :)
The primary contribution to this diff is:
First, adding test cases for know problematic cases. This is done by grabbing the messages that are send from the flipper client to flipper using the flipper messages plugin. This is the base64 data that is stored in the `.txt` files. Beyond that, for all tests public endpoints are used, so that we can both get a hold of the raw original files, and how we expect them to be displayed in flipper.
For testing a simple RN app was build, with a button that fires a bunch requests. The first 3 are captured in unit tests, the last one is not idempotent, but a case reported in #1466, so just left it there as manual verification.
```
const fetchData = async () => {
await fetch(
'https://raw.githubusercontent.com/SangKa/MobX-Docs-CN/master/docs/donating.md',
{
headers: {
'Accept-Encoding': 'identity', // signals that we don't want gzip
},
},
);
await fetch('https://reactnative.dev/img/tiny_logo.png?x=' + Math.random());
await fetch(
'https://raw.githubusercontent.com/SangKa/MobX-Docs-CN/master/docs/donating.md',
);
await fetch(
'https://ex.ke.com/sdk/recommend/html/100001314?hdicCityId=110000¶mMap[source]=&id=100001314&mediumId=100000037&elementId=&resblockId=1111027381003&templateConfig=%5Bobject%20Object%5D&fbExpoId=346620976471638017&fbQueryId=&required400=true&unique=1111027381003&parentSceneId=',
);
};
```
The second contribution of this diff is that it doesn't use weird URLencoder hacks to convert base64 to utf8, but rather a proper library. The problem with our original solution, using `atob` is that it converts to ASCII, not to utf-8, which is the source of the original bugs. See for more background on this: https://www.npmjs.com/package/js-base64#decode-vs-atob-and-encode-vs-btoa-
Solves:
https://github.com/facebook/flipper/issues/1466https://github.com/facebook/flipper/pull/1541https://github.com/facebook/flipper/issues/1458
Supersedes D23837750
Future work: we don't inspect the `content-type=xxx;charset` header yet, which we should do for less common encodings, to make sure that they get displayed correctly as well
Future work: in feature like copy data and curl, we always call decode body, without check if we are actually dealing with non-binary data. Probably it is better to keep binary data in base64, rather than decoding it, as that will assume the data is an utf-8 string, which might fail.
An assumption in these changes is that binary data is never gzipped, which is generally correct; gzip is not applied by webserver to things like images, as it would increase, not decrease their size, and waste a lot of computation power.
Reviewed By: cekkaewnumchai
Differential Revision: D23403095
fbshipit-source-id: 5099cc4a7503f0f63bd10585dc6590ba893f3dde
Summary:
This diff tries to address T74467181, where Flipper (Electron) crash hard with a segfault. Although I failed to find the root issue, I noticed that this typically happened when switching to the network plugin after a long time.
Switching the network plugin causes all rows to be rebuild, and during the process all request and response bodies are deserialized which can take very long and fully blocks Flipper making it totally unresponsive.
This diff fixes that issue, by making sure the lately added lazy evaluation of copyText is used, and that requests aren't deserialized during row generation, which is only needed for full body search purposes, by making that lazily as well.
While at it fixed D21929666 (which I never finished) as well, which is a Sandy prerequisite, since it coupled the generic search table to hardcoded networking concepts like request and response. "body" search, has now been rebranded "contents" search. That is generic and makes sense in both the network and qpl plugin. Probably will make these labelings better customisable when revisiting the grids in Sandy
N.B. I thought the issue might maybe that during the blocking process the garbage collector can't run, and the process would OOM. But that doesn't seem the case (or at least not without some other factor contribution as well), as in a quick test I can trivally allocate 30 GB of memory (making the system swap), but still the process runs stably. So even with this diff I can't satisfactory explain the crash, but at least it avoids a common circumstance in which they happen, and it significantly improves the user experience.
changelog: [Network] Fixed issue where Flipper would hang for seconds or even crash when opening the Network plugin
Reviewed By: jknoxville
Differential Revision: D23599338
fbshipit-source-id: 52164fe6997b879c91907e0afe42e08ca3f315b4
Summary: In the attached task an IPv6 address ended up in the URL send from IG. Since that URL couldn't be parsed, it crashed the network plugin. This change makes sure the plugin doesn't crash on invalid urls.
Reviewed By: cekkaewnumchai
Differential Revision: D23344503
fbshipit-source-id: c7ac2068e407a764d59e632bef1be7c4239c8c8a
Summary:
This is a replacement for PR https://github.com/facebook/flipper/pull/1486 which had the wrong username
When the network plugin is loaded, the route table in the device is empty. It needs to be populated with whatever routes have already been created and saved in local storage. Otherwise, the user would need to modify the routes to force an update.
Issue is described here - https://github.com/facebook/flipper/issues/1476
## Changelog
Routes updated in device when plugin is initialized
Pull Request resolved: https://github.com/facebook/flipper/pull/1491
Test Plan:
1. Create a mock for the get request in the sample Android app
2. Kill the app
3. Start the app
4. Issue the get request in the app
5. Verify that the request is mocked in the Network plugin

Reviewed By: passy
Differential Revision: D23292355
Pulled By: mweststrate
fbshipit-source-id: 2fe16e9067a627cae02a4b1db422952d364fd036
Summary:
There's a bug in the network inspector.
Messages come in in batches for performance reasons.
These batches can include both requests and responses, but the code assumes only one or the other.
This fixes it to make it not mutually exclusive.
This bug only affects row building in the table, so when you click on the row, you can still see the response and everything.
Reviewed By: cekkaewnumchai
Differential Revision: D23102575
fbshipit-source-id: 47e8c6b0f1c9cf0d5860b6f349a7d9fe225c73ae
Summary:
It's common for responses to be completely missing in the network inspector. This is because they are larger than can be serialized in one go on some devices, so we drop all messages larger than 1MB.
This changes the android client to send large responses in individually serialized batches. This way we avoid running out of memory and can still send arbitrarily large payloads.
Changelog: Android network inspector can now handle responses large than 1MB.
Reviewed By: passy
Differential Revision: D22999905
fbshipit-source-id: ff4eb8fa72a7e42ea90d12ffe0f20c6d1e58b7e5
Summary:
This adds support for handling incoming deeplinks in a Sandy plugin, which can be done by using a `client.onDeepLink(deepLink => { } )` listener
Also generalized deeplinks to not just support strings, but also richer objects, which is beneficial to plugin to plugin linking.
Reviewed By: jknoxville
Differential Revision: D22524749
fbshipit-source-id: 2cbe8d52f6eac91a1c1c8c8494706952920b9181
Summary:
Added "id" field to Flipper plugin manifest which is used to match native and desktop plugin parts. Before that, "name" field was used both as npm package name and as plugin id.
The problem is that currently there are a lot of plugins which has invalid values in "name", e.g. not starting with "flipper-package-", or containing upper cased letters.
Simple renaming of "name" field can be very problematic, so we need a new field to avoid any breaking changes and keep historical analytics data which is also bound to plugin id.
Reviewed By: mweststrate
Differential Revision: D21129689
fbshipit-source-id: efd143c82a6a802cc0b5438fd3f509bd99aded0e
Summary:
Added versioning for plugin format.
The first version is where "main" points to source code entry and plugins are bundled by Flipper in run-time on loading them.
The second version is where "main" points to the already existing bundle and Flipper just loads it without bundling. The plugins of version 2 must be bundled using "flipper-pkg" tool before publishing.
Changelog: Support new packaging format for plugins.
Reviewed By: mweststrate
Differential Revision: D21074173
fbshipit-source-id: 7b70250e48e5bd5d359c96149fb5b14e67783c4d
Summary:
Quick notes:
- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.
Close https://github.com/facebook/flipper/pull/915
Reviewed By: jknoxville
Differential Revision: D20594929
fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
Summary:
1) moved "sonar/desktop/src" to "sonar/desktop/app/src", so "app" is now a separate package containing the core Flipper app code
2) Configured yarn workspaces with the root in "sonar/desktop": app, static, pkg, doctor, headless-tests. Plugins are not included for now, I plan to do this later.
Reviewed By: jknoxville
Differential Revision: D20535782
fbshipit-source-id: 600b2301960f37c7d72166e0d04eba462bec9fc1
Summary:
- Add mock button if a client supports the function
- Open the dialog when clicking the button
Note:
- This is a part of this PR: https://github.com/facebook/flipper/pull/488
Reviewed By: mweststrate
Differential Revision: D20440145
fbshipit-source-id: 750099020e0b2d6ed10bb20e883f6b3be664ae79
Summary:
This diff added dummy state handler for route, which appeared in the next diffs. Routes will be used to render components for mocking handler and determine data on the client side.
State and other variables will appear on the next diffs.
Note:
- This is a part of this PR: https://github.com/facebook/flipper/pull/488
Reviewed By: mweststrate
Differential Revision: D20440150
fbshipit-source-id: d441ae1d53caf7280bef78d937aaa71617e2da9f